<%doc> -- Add Host form -- % <%attr> title => 'Add Host' % % %####################################################################### %# %# Args section %# %####################################################################### <%args> $add_host_block $address => undef # Can be passed optionally $user => $ui->get_current_user($r) $zone_id => undef $name => undef $aliases => undef $expiration => undef $cpu => undef $other_cpu => undef $os => undef $other_os => undef $site_id => undef $site_name => undef $room_id => undef $room_number => undef $ethernet => undef $duid => undef $submit => undef $contact_name => undef $contact_email => undef $contact_phone => undef $v6_assign => undef % % % %####################################################################### %# %# INIT section %# %####################################################################### % <%init> my $DEBUG = 0; print '%ARGS is
', Dumper(%ARGS), '

' if $DEBUG; my $manager = $ui->get_permission_manager($r); my $block = Ipblock->retrieve($add_host_block); unless ( $block ){ $m->comp('/generic/error.mhtml', error=>"Could not retrieve Ipblock: $add_host_block"); } unless ( $manager && $manager->can($user, "edit", $block) ){ $m->comp('/generic/error.mhtml', error=>"You don't have permission to edit ".$block->get_label); } my $zone; if ( $zone_id ){ $zone = Zone->retrieve($zone_id); } if ( $submit ){ unless ( $zone ){ $m->comp('/generic/error.mhtml', error=>"A DNS Domain (Zone) is required"); } unless ( $name ){ $m->comp('/generic/error.mhtml', error=>"A hostname is required"); } my %args; # For RR->add_host() foreach my $key ( qw(name expiration ethernet duid aliases) ){ $args{$key} = $ARGS{$key}; } # Hostname validation if ( $args{name} ) { eval { RR->validate_name($args{name}); }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>"$e"); } } my $person = $ui->get_user_person($user); $args{person} = $person; $args{zone} = $zone; $args{subnet} = $block; if ( $address ){ $args{address} = $address; }else{ if ( $block->version == 6 && $v6_assign eq 'manual' ){ if ( $ui->config->get('IPV6_ADDRESS_USER_ENTRY_HOST_ONLY') ){ # We need to construct the address my %parts; foreach my $key ( %ARGS ){ if ( $key =~ /^v6_(\d+)$/o ){ my $val = $ARGS{$key}; if ( defined $val && $val ne "" ){ $parts{$1} = $val; }else{ $m->comp('/generic/error.mhtml', error=>"You must fill all the address parts"); } } } my $addr = $block->address; $addr =~ s/:$//; $addr .= join(':', map { $parts{$_} } sort { $a <=> $b } keys %parts); $args{address} = $addr; } } } # Hardware Info $args{cpu} = $cpu || $other_cpu; $args{os} = $os || $other_os; # Lines to go in the info field my @info; # Location if ( $room_id || $room_number || $site_id || $site_name ){ my $info; if ( my $room = Room->retrieve($room_id) ){ $info = "LOC: ".$room->get_label; # the room label includes the site name }elsif ( $room_number ){ $info = "LOC: ".$room_number; if ( my $site = Site->retrieve($site_id) ){ $info .= " ".$site->get_label; }elsif ( $site_name ){ $info .= " ".$site_name; } }else{ if ( my $site = Site->retrieve($site_id) ){ $info = $site->get_label; }elsif ( $site_name ){ $info = $site_name; } } push @info, $info if ( $info ); } # Contacts if ( $person ){ # Add the current user as a contact my $info = "CON: ".$person->get_label; $info .= " (".$person->email.")" if $person->email; $info .= ", ".$person->office if $person->office; push @info, $info if ( $info ); } # Add additional contact info if ( $contact_name ){ my $info = ""; $info = "CON: ".$contact_name; $info .= " (".$contact_email.")" if $contact_email; $info .= ", ".$contact_phone if $contact_phone; push @info, $info if ( $info ); } my $info_text = join "\n", @info; $args{info} = $info_text if ( $info_text ); my $rr; eval { $rr = RR->add_host(%args); }; if ( my $e = $@ ){ $m->comp("/generic/error.mhtml", error=>$e); }else{ $m->comp("../management/host.html", rr=>$rr); } } % if ( !$submit ){ % my $subnet_description = $block->get_label; % $subnet_description .= " (".$block->description.")" if $block->description; % % my $cpu_defaults = $ui->config->get('DEFAULT_HINFO_CPU_VALUES'); % my $os_defaults = $ui->config->get('DEFAULT_HINFO_OS_VALUES'); <%doc> Opens a new window showing subnet addresses to choose from
Add New Host in <% $subnet_description %>
% if ( $address ){ % }

(*) Field is required

Help is available for some fields by clicking on the field name.


Host Identification % if ( $address ){

<% $address %>

% }else{ % if ( $manager && $manager->can($user, 'choose_ip', $block) ){ % if ( $block->version == 6 ){

% }else{

% } % }else{

An available address will be automatically assigned.

% } % }

% if ( $zone ){ <% $zone->get_label %> % }else{ % }

% if ( $block->version == 4 || % ($block->version == 6 && Netdot->config->get('DHCPD_ALLOW_ETHERNET_FOR_IPV6_HOST_DECL')) ){

% }elsif ( $block->version == 6 ){

% }

<% $ui->date_field(table=>"RR", column=>"expiration", edit=>1, shortFieldName=>1, returnAsVar=>1) %>

Hardware Information

(if not listed)

(if not listed)

Location

(if not listed)

(if not listed)

Contact (other than you)

% }