diff --git a/perl-xCAT/xCAT/FSPvm.pm b/perl-xCAT/xCAT/FSPvm.pm index 9922fc2fb..6eda34c46 100644 --- a/perl-xCAT/xCAT/FSPvm.pm +++ b/perl-xCAT/xCAT/FSPvm.pm @@ -16,7 +16,7 @@ use xCAT::Usage; use xCAT::NodeRange; use xCAT::FSPUtils; use xCAT::VMCommon; -#use Data::Dumper; +use Data::Dumper; use xCAT::MsgUtils qw(verbose_message); ############################################## # Globals @@ -719,7 +719,7 @@ sub lsvm_parse_args { $Getopt::Long::ignorecase = 0; Getopt::Long::Configure( "bundling" ); - if ( !GetOptions( \%opt, qw(V|verbose l|long p775) )) { + if ( !GetOptions( \%opt, qw(V|verbose l|long p775 updatedb) )) { return( usage() ); } if (exists($opt{l}) && !exists($opt{p775})) { @@ -758,6 +758,7 @@ sub modify { return op_extra_cmds ($request, $hash) if ($request->{opt}->{lparname} || $request->{opt}->{huge_page}); return ([["Error", "Miss argument\n".$usage_string, 1]]); } + sub do_op_extra_cmds { my $request = shift; my $hash = shift; @@ -1672,9 +1673,10 @@ sub parse_part_get_info { $hash->{bus}->{$3}->{cur_lparid} = $1; $hash->{bus}->{$3}->{bus_slot} = $2; $hash->{bus}->{$3}->{des} = $4; + push @{$hash->{lpar_phy_bus}}, $3; } elsif ($line =~ /Phy drc_index:(\w+), Port group: (\w+), Phy port id: (\w+)/) { $hash->{phy_drc_group_port}->{$1}->{$2}->{$3} = '1'; - } elsif ($line =~ /adapter_id=(\w+),lpar_id=([\d|-]+).*port_group=(\d+),phys_port_id=(\d+).*drc_index=(\w+),.*/) { + #} elsif ($line =~ /adapter_id=(\w+),lpar_id=([\d|-]+).*port_group=(\d+),phys_port_id=(\d+).*drc_index=(\w+),.*/) { if (($2 == -1) && ($4 == 255)) { $hash->{logic_drc_phydrc}->{$3}->{$5} = $1; #$hash->{logic_drc_phydrc}->{$5}->{$1} = [$2,$3,$4]; @@ -1687,12 +1689,49 @@ sub parse_part_get_info { $hash->{lpar0_used_mem} = $2; $hash->{phy_min_mem_req} = $3; #print "===>lpar0_used_mem:$hash->{lpar0_used_mem}.\n"; - } elsif ($line =~ /Curr Memory Req:[^\(]*\((\d+)\s*regions\)/) { - $hash->{lpar_used_regions} = $1; + } elsif ($line =~ /Curr Memory (Min|Req|Max):\s*([\d]*)[^\(]*\((\d+)\s*regions\)/) { + if ($1 eq 'Min') { + $hash->{lpar_mem_min} = $2 + } elsif ($1 eq 'Max') { + $hash->{lpar_mem_max} = $2; + } else { + $hash->{lpar_mem_req} = $2; + $hash->{lpar_used_regions} = $3; + } + } elsif ($line =~ /Curr Processor (Min|Req|Max):\s*(\d+)/) { + if ($1 eq 'Min') { + $hash->{lpar_cpu_min} = $2; + } elsif ($1 eq 'Max') { + $hash->{lpar_cpu_max} = $2; + } else { + $hash->{lpar_cpu_req} = $2; + } + } elsif ($line =~ /\s*lpar_id=(\d+),type=vSCSI,slot=(\d+),attr=(\d+).*remote_lpar_id=0x(\w+),remote_slot_num=0x(\w+)/) { + if ($3 eq '0') { + my $lparid = hex($4); + my $slotid = hex($5); + push @{$hash->{lpar_vmstorage_client}}, "$lparid:$slotid"; + } else { + if (exists($hash->{lpar_vmstorage_server})) { + $hash->{lpar_vmstorage_server}++; + } else { + $hash->{lpar_vmstorage_server} = 1; + } + } + } elsif ($line =~ /\s*lpar_id=(\d+),type=(vEth),slot=(\d+).*port_vlan_id=(\d+),mac_addr=(\w+)/) { + push @{$hash->{lpar_vmnics}}, "vlan$4"; } elsif ($line =~ /Available huge page memory\(in pages\):\s*(\d+)/) { $hash->{huge_page_avail} = $1; } elsif ($line =~ /Available BSR array:\s*(\d+)/) { $hash->{cec_bsr_avail} = $1; + } elsif ($line =~ /^\d+\/(\d+)\/\d+$/) { + if ($1 ne 0) { + push @{$hash->{lpar_othersetting}}, "hugepage:$1"; + } + } elsif ($line =~ /^(\d+)\.$/) { + if ($1 ne 0) { + push @{$hash->{lpar_othersetting}}, "bsr:$1"; + } } } } @@ -1703,6 +1742,7 @@ sub query_cec_info_actions { my $td = shift; my $usage = shift; my $action_array = shift; + my $lpar_hash = shift; my $lparid = @$td[0]; my $data; my @array = (); @@ -1722,7 +1762,11 @@ sub query_cec_info_actions { if (@$values[1] =~ /^$/) { next; } - if ($usage eq 0) { + if ($usage eq 1 or $usage eq 2) { + &parse_part_get_info(\%hash, @$values[1]); + } + + if ($usage eq 0 or $usage eq 2) { if ($lparid) { if ($action eq "lpar_lhea_mac") { my @output = split /\n/,@$values[1]; @@ -1777,18 +1821,58 @@ sub query_cec_info_actions { } #$data .= "@$values[1]\n\n"; push @array, [$name, @$values[1], @$values[2]]; - } else { - &parse_part_get_info(\%hash, @$values[1]); - } + } } - if ($usage eq 0) { + if ($usage eq 0 or $usage eq 2) { #return $data; + if ($usage eq 2) { + %$lpar_hash = %hash; + } return \@array; } else { return \%hash; } } +sub update_vm_db { + my $request = shift; + my $lpar_hash = shift; + my $vm_hd = xCAT::Table->new('vm'); + my %name_id_map = (); + foreach (keys (%$lpar_hash)) { + my %db_update = (); + my $node_hash = $lpar_hash->{$_}; + $db_update{cpus} = "$node_hash->{lpar_cpu_min}/$node_hash->{lpar_cpu_req}/$node_hash->{lpar_cpu_max}"; + $db_update{memory} = "$node_hash->{lpar_mem_min}/$node_hash->{lpar_mem_req}/$node_hash->{lpar_mem_max}"; + if (exists($node_hash->{lpar_vmstorage_server})) { + $db_update{storage} = $node_hash->{lpar_vmstorage_server}; + } elsif (exists($node_hash->{lpar_vmstorage_client})) { + my @tmp_array = (); + foreach (@{$node_hash->{lpar_vmstorage_client}}) { + if (/(\d+):(\d+)/) { + if (exists($name_id_map{$1})) { + push @tmp_array, "$name_id_map{$1}:$2"; + } else { + my $vios_name = &find_lpar_name($request, $node_hash->{parent}, $1); + if (defined($vios_name)) { + $name_id_map{$1} = $vios_name; + push @tmp_array, "$vios_name:$2"; + } + } + } + } + $db_update{storage} = join(",",@tmp_array); + } + $db_update{nics} = join(",",@{$node_hash->{lpar_vmnics}}); + $db_update{physlots} = join(",",@{$node_hash->{lpar_phy_bus}}); + if (exists($node_hash->{lpar_othersetting})) { + $db_update{othersettings} = join(",",@{$node_hash->{lpar_othersetting}}); + } + $vm_hd->setNodeAttribs($_,\%db_update); + } + $vm_hd->commit; +} + #my @partition_query_actions = qw(part_get_partition_cap part_get_num_of_lpar_slots part_get_hyp_config_process_and_mem part_get_hyp_avail_process_and_mem part_get_service_authority_lpar_id part_get_shared_processing_resource part_get_all_vio_info lpar_lhea_mac part_get_all_io_bus_info part_get_lpar_processing part_get_lpar_memory get_huge_page get_cec_bsr); sub query_cec_info { my $request = shift; @@ -1796,25 +1880,36 @@ sub query_cec_info { my $args = $request->{opt}; my @td = (); my @result = (); + my $usage = 0; + my %lpar_hash = (); #print Dumper($request); #print Dumper($hash); while (my ($mtms,$h) = each(%$hash) ) { while (my ($name, $d) = each (%$h)) { + my %tmp_hash = (); @td = @$d; if (@$d[0] == 0 && @$d[4] !~ /lpar|vios/) { last; } #my $rethash = query_cec_info_actions($request, $name, $d, 0, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_vio_info","lpar_lhea_mac","part_get_all_io_bus_info","get_huge_page","get_cec_bsr"]); - my $rethash = query_cec_info_actions($request, $name, $d, 0, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_io_bus_info","part_get_all_vio_info","get_huge_page","get_cec_bsr"]); + if ($args->{updatedb}) { + $usage = 2; + } + my $rethash = query_cec_info_actions($request, $name, $d, $usage, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_io_bus_info","part_get_all_vio_info","get_huge_page","get_cec_bsr"], \%tmp_hash); #push @result, [$name, $rethash, 0]; push @result, @$rethash; + $lpar_hash{$name} = \%tmp_hash; + $lpar_hash{$name}->{parent} = @$d[3]; } if (@td[0] == 0) { - my $rethash = query_cec_info_actions($request, @td[3],\@td, 0); + my $rethash = query_cec_info_actions($request, @td[3],\@td, $usage); #push @result, [@td[3], $rethash, 0]; push @result, @$rethash; } } + if ($args->{updatedb} and %lpar_hash) { + update_vm_db($request, \%lpar_hash); + } return \@result; } @@ -1931,6 +2026,19 @@ sub find_lpar_id { return undef; } +sub find_lpar_name { + my $request = shift; + my $parent = shift; + my $id = shift; + my %mapping = %{$request->{ppc}->{$parent}->{mapping}}; + foreach (keys %mapping) { + if ($mapping{$_} eq $id) { + return $_; + } + } + return undef; +} + sub create_lpar { my $request = shift; my $name = shift; @@ -2126,9 +2234,9 @@ sub mkspeclpar { return([[$name, "Parameter for 'vmmemory' is invalid", 1]]); } my $memsize = $memhash->{mem_region_size}; - $mmin = ($mmin + $memsize) / $memsize; - $mcur = ($mcur + $memsize) / $memsize; - $mmax = ($mmax + $memsize) / $memsize; + $mmin = ($mmin + $memsize - 1) / $memsize; + $mcur = ($mcur + $memsize - 1) / $memsize; + $mmax = ($mmax + $memsize - 1) / $memsize; $tmp_ent->{memory} = "$mmin/$mcur/$mmax"; $tmp_ent->{mem_region_size} = $memsize; } else { @@ -2178,21 +2286,27 @@ sub mkspeclpar { $tmp_ent->{storage} = \@array; } } else { - if (exists($tmp_ent->{storage}) and $tmp_ent->{storage} !~ /^[\w_-]*:\d+$/) { - return ([[$name, "Parameter for 'vmstorage' is invalid", 1]]); - } elsif (exists($tmp_ent->{storage})) { - if ($tmp_ent->{storage} =~ /([\w_-]*):(\d+)/) { - my $vios = &find_lpar_id($request, @$d[3], $1); - my $r_slotid = $2; - if (!defined($vios)) { - return ([[$name, "Cannot find lparid for Server lpar:$1"]]); + if (exists($tmp_ent->{storage})) { + my @tmp_array = split ",",$tmp_ent->{storage}; + my $storage_array = undef; + foreach (@tmp_array) { + if (/([\w_-]*):(\d+)/) { + my $vios = &find_lpar_id($request, @$d[3], $1); + my $r_slotid = $2; + if (defined($vios)) { + push @$storage_array, "0,$vios,$r_slotid"; + } else { + return ([[$name, "Cannot find lparid for Server lpar:$1"]]); + } + } else { + return ([[$name, "Parameter for 'vmstorage' is invalid", 1]]); } - $tmp_ent->{storage} = ["0,$vios,$r_slotid"]; } + $tmp_ent->{storage} = $storage_array; + } } - $tmp_ent->{hyp_config_mem} = $memhash->{hyp_config_mem}; $tmp_ent->{hyp_avail_mem} = $memhash->{hyp_avail_mem}; if (exists($tmp_ent->{othersettings})) { diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index cbf4ede50..003b1bd98 100644 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -222,7 +222,7 @@ my %usage = ( lsvm [-a|--all] PPC (using Direct FSP Management) specific: lsvm [-l|--long] --p775 - lsvm + lsvm [--updatedb] zVM specific: lsvm noderange lsvm noderange --getnetworknames diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index d45f53f1a..2861206e3 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -14,6 +14,7 @@ use xCAT::Schema; use Data::Dumper; use xCAT::Utils; use xCAT::SvrUtils; +use xCAT::Scope; use xCAT::Usage; use Storable qw(dclone); use xCAT::TableUtils; @@ -188,6 +189,7 @@ sub preprocess_updatenode my @requests = (); my $installdir = xCAT::TableUtils->getInstallDir(); + my $localhost = hostname(); # subroutine to display the usage sub updatenode_usage @@ -252,6 +254,59 @@ sub preprocess_updatenode return; } + # preprocess generate mypostscripts files (-g) for hierarchy + # if no sharedtftp then we need to broadcast this updatenode -g to all service nodes inorder + # to be able to support service node pools + # + if ($::GENMYPOST) + { + # precreatemypostscript has to be yes/1 or do nothing + my @entries = xCAT::TableUtils->get_site_attribute("precreatemypostscripts"); + if ($entries[0] ) { + $entries[0] =~ tr/a-z/A-Z/; + if ($entries[0] =~ /^(1|YES)$/ ) { + # now check if sharedtftp = 0, if it is we need to broadcast to all the servicenode + # if there are service nodes + my @entries = xCAT::TableUtils->get_site_attribute("sharedtftp"); + my $t_entry = $entries[0]; + if ( defined($t_entry) and ($t_entry eq "0" or $t_entry eq "no" or $t_entry eq "NO")) { + # see if there are any servicenodes. If so then run updatenode -g on all of them + my @SN; + my @CN; + my $nodes = $request->{node}; + xCAT::ServiceNodeUtils->getSNandCPnodes(\@$nodes, \@SN, \@CN); + if (@CN >0 ) { # if compute nodes broadcast to all servicenodes + return xCAT::Scope->get_broadcast_scope($request,@_); + } + } else { # sharedtftp=yes, just run on MN + my $notmpfiles=1; + my $nofiles=0; + xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles); + my $rsp = {}; + $rsp->{data}->[0] = "Generated new mypostscript files on $localhost"; + $callback->($rsp); + return 0; + } + } else { # not valid unless precreatemypostscripts enabled + my $rsp = {}; + $rsp->{error}->[0] = + "This option is only valid if site table precreatemypostscripts attribute is 1 or YES"; + $rsp->{errorcode}->[0] =1; + $callback->($rsp); + return ; + } + } else { # precreatemypostscripts not in the site table + my $rsp = {}; + $rsp->{error}->[0] = + "This option is only valid if site table precreatemypostscripts attribute is 1 or YES"; + $rsp->{errorcode}->[0] =1; + $callback->($rsp); + return ; + } + } # end GENMYPOST + + + # -c must work with -S for AIX node if ($::CMDLINE && !$::SWMAINTENANCE) { @@ -1045,7 +1100,7 @@ sub updatenode my $nofiles=0; xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles); my $rsp = {}; - $rsp->{data}->[0] = "Generated new mypostscript files"; + $rsp->{data}->[0] = "Generated new mypostscript files on $localhostname"; $callback->($rsp); } else { # not valid unless precreatemypostscripts enabled my $rsp = {}; diff --git a/xCAT-server/lib/xcat/plugins/zone.pm b/xCAT-server/lib/xcat/plugins/zone.pm index da98e528b..0ccfbffc2 100644 --- a/xCAT-server/lib/xcat/plugins/zone.pm +++ b/xCAT-server/lib/xcat/plugins/zone.pm @@ -131,6 +131,16 @@ sub process_request &usage($callback,$command); exit 1; } + # if the ARGS still have data we have invalid input + if (@ARGV) { + my $args=join(',', @ARGV); + my $rsp = {}; + $rsp->{error}->[0] = + "The input to the command: $command contained invalid arguments: $args."; + xCAT::MsgUtils->message("E", $rsp, $callback, 1); + exit 1; + } + if ($options{'help'}) { &usage($callback,$command); @@ -170,6 +180,14 @@ sub process_request } } } + # cannot enter -K and -k + if (($options{'sshkeypath'}) && ($options{'gensshkeys'})) { + my $rsp = {}; + $rsp->{error}->[0] = + "The input of -k and -K is not valid on the command : $command."; + xCAT::MsgUtils->message("E", $rsp, $callback); + exit 1; + } # check for site.sshbetweennodes attribute, put out a warning it will not be used as long # as zones are defined in the zone table. @@ -473,6 +491,18 @@ sub rmzone xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } + # see if they input invalid flags + if (($$options{'sshkeypath'}) || ($$options{'gensshkeys'}) || + ( $$options{'addnoderange'}) || ( $$options{'rmnoderange'}) || + ( $$options{'defaultzone'}) || + ($$options{'sshbetweennodes'})) { + + my $rsp = {}; + $rsp->{error}->[0] = + "The following flags are not valid input for the rmzone command: -k,-K,-a,-r,-f,-s "; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } # check to see if the input zone already exists # cannot remove it if it is not defined my $zonename=$request->{zonename}; @@ -705,6 +735,9 @@ sub addtozonetable my $curdefaultzone = xCAT::Zone->getdefaultzone($callback); if (!(defined ($curdefaultzone))) { # no default defined $tb_cols{defaultzone} ="yes"; + $tab->setAttribs({zonename => $zonename}, \%tb_cols); + $tab->commit(); + $tab->close(); } else { # already a default if ($$options{'force'}) { # force the default $tb_cols{defaultzone} ="yes"; @@ -780,6 +813,9 @@ sub updatezonetable my $curdefaultzone = xCAT::Zone->getdefaultzone($callback); if (!(defined ($curdefaultzone))) { # no default defined $tb_cols{defaultzone} ="yes"; + $tab->setAttribs({zonename => $zonename}, \%tb_cols); + $tab->commit(); + $tab->close(); } else { # already a default if ($$options{'force'}) { # force the default $tb_cols{defaultzone} ="yes"; diff --git a/xCAT-server/xCAT-wsapi/genrestapidoc.pm b/xCAT-server/xCAT-wsapi/genrestapidoc.pm index 3ea638504..43eefde34 100755 --- a/xCAT-server/xCAT-wsapi/genrestapidoc.pm +++ b/xCAT-server/xCAT-wsapi/genrestapidoc.pm @@ -19,37 +19,6 @@ my @apigroups = ( 'updating','filesyncing','software_maintenance','postscript', 'nodeshell', 'nodecopy', ] }, - { - groupname => 'groups', - header => "Group Resources", - desc => "The URI list which can be used to create, query, change and manage group objects.", - resources => ['all_groups','group_allattr','group_attr', - ] - }, - { - groupname => 'services', - header => "Services Resources", - desc => "The URI list which can be used to manage the dns and dhcp services on xCAT MN.", - resources => ['dns','dhcp','host', 'slpnodes', 'specific_slpnodes',] - }, - { - groupname => 'policy', - header => "Policy Resources", - desc => "The URI list which can be used to create, query, change and manage policy entries.", - resources => ['policy', 'policy_allattr', 'policy_attr'] - }, - { - groupname => 'globalconf', - header => "Global Configuration Resources", - desc => "The URI list which can be used to create, query, change global configuration.", - resources => ['all_site', 'site'] - }, - { - groupname => 'table', - header => "Table Resources", - desc => "URI list which can be used to create, query, change global configuration.", - resources => ['table_nodes', 'table_rows'] - }, { groupname => 'osimages', header => "Osimage resources", @@ -63,6 +32,37 @@ my @apigroups = ( resources => ['allnetwork', 'network_allattr','network_attr'] }, + { + groupname => 'policy', + header => "Policy Resources", + desc => "The URI list which can be used to create, query, change and manage policy entries.", + resources => ['policy', 'policy_allattr', 'policy_attr'] + }, + { + groupname => 'groups', + header => "Group Resources", + desc => "The URI list which can be used to create, query, change and manage group objects.", + resources => ['all_groups','group_allattr','group_attr', + ] + }, + { + groupname => 'globalconf', + header => "Global Configuration Resources", + desc => "The URI list which can be used to create, query, change global configuration.", + resources => ['all_site', 'site'] + }, + { + groupname => 'services', + header => "Service Resources", + desc => "The URI list which can be used to manage the dns and dhcp services on xCAT MN.", + resources => ['dns','dhcp','host', 'slpnodes', 'specific_slpnodes',] + }, + { + groupname => 'table', + header => "Table Resources", + desc => "URI list which can be used to create, query, change global configuration.", + resources => ['table_nodes', 'table_rows'] + }, ); my %formathdl = ( diff --git a/xCAT-server/xCAT-wsapi/restapi.pl b/xCAT-server/xCAT-wsapi/restapi.pl index 14046eb6b..6d7b4ccde 100755 --- a/xCAT-server/xCAT-wsapi/restapi.pl +++ b/xCAT-server/xCAT-wsapi/restapi.pl @@ -356,7 +356,7 @@ my %URIdef = ( }, }, inventoryattr => { - desc => "[URI:/nodes/{nodename}/inventory/{pci;model...}] - The specific inventory attributes for the node {nodename}", + desc => "[URI:/nodes/{nodename}/inventory/{pci|model...}] - The specific inventory attributes for the node {nodename}", matcher => '^/nodes/[^/]*/inventory/\S+$', GET => { desc => "Get the specific inventory attibutes.", @@ -809,12 +809,12 @@ my %URIdef = ( }, }, osimage_attr => { - desc => "[URI:/osimages/{imgname}/attrs/attr1;attr2;attr3 ...] - The attributes resource for the osimage {imgname}", + desc => "[URI:/osimages/{imgname}/attrs/attr1,attr2,attr3 ...] - The attributes resource for the osimage {imgname}", matcher => '^\/osimages\/[^\/]*/attrs/\S+$', GET => { desc => "Get the specific attributes for the osimage {imgname}.", usage => "||Json format: An array of attr:value pairs for the specified osimage.|", - example => "|Get the specified attributes.|GET|/osimages/sles11.2-ppc64-install-compute/attrs/imagetype;osarch;osname;provmethod|{\n \"sles11.2-ppc64-install-compute\":{\n \"provmethod\":\"install\",\n \"osname\":\"Linux\",\n \"osarch\":\"ppc64\",\n \"imagetype\":\"linux\"\n }\n}|", + example => "|Get the specified attributes.|GET|/osimages/sles11.2-ppc64-install-compute/attrs/imagetype,osarch,osname,provmethod|{\n \"sles11.2-ppc64-install-compute\":{\n \"provmethod\":\"install\",\n \"osname\":\"Linux\",\n \"osarch\":\"ppc64\",\n \"imagetype\":\"linux\"\n }\n}|", cmd => "lsdef", fhandler => \&defhdl, outhdler => \&defout, @@ -861,82 +861,66 @@ my %URIdef = ( matcher => '^\/policy$', GET => { desc => "Get all the policies in xCAT.", - desc1 => "It will dislplay all the policies defined in policy table.", + desc1 => "It will dislplay all the policy resource.", usage => "||$usagemsg{objreturn}|", example => "|Get all the policy objects.|GET|/policy|[\n \"1\",\n \"1.2\",\n \"2\",\n \"4.8\"\n]|", cmd => "lsdef", fhandler => \&defhdl, outhdler => \&defout_remove_appended_type, }, - POST_back => { - desc => "Create a new policy on xCAT MN.", - usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|", - example => "|Create |?|?|?|", - cmd => "chdef", - fhandler => \&defhdl, - }, }, policy_allattr => { desc => "[URI:/policy/{policy_priority}] - The policy resource", matcher => '^\/policy\/[^\/]*$', GET => { desc => "Get all the attibutes for a policy {policy_priority}.", - desc1 => "It will display all the policy attributes for one policy entry defined in policy table.", + desc1 => "It will display all the policy attributes for one policy resource.", usage => "||$usagemsg{objreturn}|", - example => "|Get all the attribute for policy 1.|GET|/policy/1|[\n {\n \"name\":\"root\",\n \"rule\":\"allow\"\n }\n]|", + example => "|Get all the attribute for policy 1.|GET|/policy/1|{\n \"1\":{\n \"name\":\"root\",\n \"rule\":\"allow\"\n }\n}|", cmd => "lsdef", fhandler => \&defhdl, outhdler => \&defout, }, PUT => { desc => "Change the attibutes for the policy {policy_priority}.", - desc1 => "It will change one or more attributes defined in policy table.", + desc1 => "It will change one or more attributes for a policy.", usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|", - example => "|Set the name attribute for policy 3.|PUT|/policy/3 {\"name\":\"root\"}|[\n \"1 object definitions have been created or modified.\"\n]|", + example => "|Set the name attribute for policy 3.|PUT|/policy/3 {\"name\":\"root\"}||", cmd => "chdef", fhandler => \&defhdl, outhdler => \&noout, }, POST => { desc => "Create the policy {policyname}. DataBody: {attr1:v1,att2:v2...}.", - desc1 => "It will creat a new policy entry in policy table.", + desc1 => "It will creat a new policy resource.", usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|", - example => "|Create a new policy 10.|POST|/policy/10 {\"name\":\"root\",\"commands\":\"rpower\"}|[\n \"1 object definitions have been created or modified.\"\n]|", + example => "|Create a new policy 10.|POST|/policy/10 {\"name\":\"root\",\"commands\":\"rpower\"}||", cmd => "chdef", fhandler => \&defhdl, outhdler => \&noout, }, DELETE => { desc => "Remove the policy {policy_priority}.", - desc1 => "Remove one or more policys defined in policy table.", + desc1 => "Remove one or more policy resource.", usage => "||$usagemsg{non_getreturn}|", - example => "|Delete the policy 10.|DELETE|/policy/10|[\n \"1 object definitions have been removed.\"\n]|", + example => "|Delete the policy 10.|DELETE|/policy/10||", cmd => "rmdef", fhandler => \&defhdl, outhdler => \&noout, }, }, policy_attr => { - desc => "[URI:/policy/{policyname}/attrs/{attr1;attr2;attr3,...}] - The attributes resource for the policy {policy_priority}", + desc => "[URI:/policy/{policyname}/attrs/{attr1,attr2,attr3,...}] - The attributes resource for the policy {policy_priority}", matcher => '^\/policy\/[^\/]*/attrs/\S+$', GET => { desc => "Get the specific attributes for the policy {policy_priority}.", - desc1 => "It will get one or more attributes defined in policy table.", + desc1 => "It will get one or more attributes of a policy.", usage => "||$usagemsg{objreturn}|", - example => "|Get the name and rule attributes for policy 1.|GET|/policy/1/attrs/name;rule|[\n {\n \"name\":\"root\",\n \"rule\":\"allow\"\n }\n]|", + example => "|Get the name and rule attributes for policy 1.|GET|/policy/1/attrs/name,rule|{\n \"1\":{\n \"name\":\"root\",\n \"rule\":\"allow\"\n }\n}|", cmd => "lsdef", fhandler => \&defhdl, outhdler => \&defout, }, - PUT => { - desc => "Change the attibutes for the policy {policy_priority}.", - desc1 => "It will change one or more attributes defined in policy table.", - usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|", - example => "|Set the name attribute for policy 3.|PUT|/policy/3 {\"name\":\"root\"}|[\n \"1 object definitions have been created or modified.\"\n]|", - cmd => "chdef", - fhandler => \&defhdl, - outhdler => \&noout, - }, }, }, #### definition for global setting resources @@ -947,16 +931,16 @@ my %URIdef = ( matcher => '^\/globalconf$', GET => { desc => "Get all the xCAT global configuration.", - desc1=> "It will display all the attributes defined in site table.", + desc1=> "It will display all the global attributes.", usage => "||$usagemsg{objreturn}|", - example => "|Get all the global configuration|GET|/globalconf|{\n \"clustersite\":{\n \"xcatconfdir\":\"/etc/xcat\",\n \"tftpdir\":\"/tftpboot\",\n ...\n }\n]|", + example => "|Get all the global configuration|GET|/globalconf|{\n \"clustersite\":{\n \"xcatconfdir\":\"/etc/xcat\",\n \"tftpdir\":\"/tftpboot\",\n ...\n }\n}|", cmd => "lsdef", fhandler => \&sitehdl, outhdler => \&defout, }, POST_backup => { desc => "Add the site attributes. DataBody: {attr1:v1,att2:v2...}.", - desc1 => "One or more attributes could be added/modified to site table.", + desc1 => "One or more global attributes could be added/modified.", usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|", example => "|Add one or more attributes to xCAT database|POST|/globalconf {\"domain\":\"cluster.com\",\"mydomain\":\"mycluster.com\"}||", cmd => "chdef", @@ -970,19 +954,19 @@ my %URIdef = ( desc => "Get the specific configuration in global.", desc1 => "It will display one or more global attributes.", usage => "||$usagemsg{objreturn}|", - example => "|Get the \'master\' and \'domain\' configuration.|GET|/globalconf/attrs/master,domain|[\n {\n \"master\":\"192.168.1.1\",\n \"domain\":\"/cluster.com\",\n }\n|", + example => "|Get the \'master\' and \'domain\' configuration.|GET|/globalconf/attrs/master,domain|{\n \"clustersite\":{\n \"domain\":\"cluster.com\",\n \"master\":\"192.168.1.15\"\n }\n}|", cmd => "lsdef", fhandler => \&sitehdl, outhdler => \&defout, }, PUT => { - desc => "Change the attributes for the site table.", + desc => "Change the global attributes.", desc1 => "It can be used for changing/adding global attributes.", usage => "|$usagemsg{objchparam} DataBody: {attr1:v1,att2:v2,...}.|$usagemsg{non_getreturn}|", - example => "|Change/Add the domain attribute.|PUT|/globalconf/attrs/domain {\"domain\":\"cluster.com\"||", + example => "|Change/Add the domain attribute.|PUT|/globalconf/attrs/domain {\"domain\":\"cluster.com\"}||", cmd => "chdef", fhandler => \&sitehdl, - outhdler => \&noout, + outhdler => \&noout, }, POST_backup => { desc => "Create the global configuration entry. DataBody: {name:value}.", @@ -990,16 +974,16 @@ my %URIdef = ( example => "|Create the domain attribute|POST|/globalconf/attrs/domain {\"domain\":\"cluster.com\"}|?|", cmd => "chdef", fhandler => \&sitehdl, - outhdler => \&noout, + outhdler => \&noout, }, DELETE => { desc => "Remove the site attributes.", - desc1 => "Used for femove one or more global attributes defined in site table.", + desc1 => "Used for femove one or more global attributes.", usage => "||$usagemsg{non_getreturn}|", example => "|Remove the domain configure.|DELETE|/globalconf/attrs/domain||", cmd => "chdef", fhandler => \&sitehdl, - outhdler => \&noout, + outhdler => \&noout, }, }, }, @@ -1874,13 +1858,13 @@ sub sitehdl { # push the -t args push @args, '-t'; push @args, 'site'; - if (isGET()) { + if (isGET()) { push @args, 'clustersite'; - } + } if (defined ($urilayers[2])){ if (isGET()) { push @args, ('-i', $urilayers[2]); - } + } } if (isDelete()) { if (defined ($urilayers[2])){