From b964d1d9aedffe4a9471615b36ebf060cfd280eb Mon Sep 17 00:00:00 2001 From: linggao Date: Tue, 23 Jun 2015 14:12:24 -0400 Subject: [PATCH] remove switch object, use node object to represent a switch --- perl-xCAT/xCAT/Schema.pm | 130 ++++++++---------- .../lib/xcat/plugins/switchdiscover.pm | 16 +-- 2 files changed, 61 insertions(+), 85 deletions(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index a21af96e0..7f53f67c7 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -1755,7 +1755,6 @@ foreach my $tabname (keys(%xCAT::ExtTab::ext_tabspec)) { osdistro=> { attrs => [], attrhash => {}, objkey => 'osdistroname' }, osdistroupdate=> { attrs => [], attrhash => {}, objkey => 'osupdatename' }, zone=> { attrs => [], attrhash => {}, objkey => 'zonename' }, - switch=> { attrs => [], attrhash => {}, objkey => 'switch' }, ); @@ -2696,6 +2695,60 @@ my @nodeattrs = ( tabentry => 'hwinv.disksize', access_tabentry => 'hwinv.node=attr:node', }, + +######################### +## switches table # +######################### + {attr_name => 'snmpusername', + only_if => 'nodetype=switch', + tabentry => 'switches.username', + access_tabentry => 'switches.switch=attr:node', + }, + {attr_name => 'snmppassword', + only_if => 'nodetype=switch', + tabentry => 'switches.password', + access_tabentry => 'switches.switch=attr:node', + }, + {attr_name => 'snmpversion', + only_if => 'nodetype=switch', + tabentry => 'switches.snmpversion', + access_tabentry => 'switches.switch=attr:node', + }, + {attr_name => 'snmpprivacy', + only_if => 'nodetype=switch', + tabentry => 'switches.privacy', + access_tabentry => 'switches.switch=attr:node', + }, + {attr_name => 'snmpauth', + only_if => 'nodetype=switch', + tabentry => 'switches.auth', + access_tabentry => 'switches.switch=attr:node', + }, + {attr_name => 'linkports', + only_if => 'nodetype=switch', + tabentry => 'switches.linkports', + access_tabentry => 'switches.switch=attr:node', + }, + {attr_name => 'username', + only_if => 'nodetype=switch', + tabentry => 'switches.sshusername', + access_tabentry => 'switches.switch=attr:node', + }, + {attr_name => 'password', + only_if => 'nodetype=switch', + tabentry => 'switches.sshpassword', + access_tabentry => 'switches.switch=attr:node', + }, + {attr_name => 'protocol', + only_if => 'nodetype=switch', + tabentry => 'switches.protocol', + access_tabentry => 'switches.switch=attr:node', + }, + {attr_name => 'switchtype', + only_if => 'nodetype=switch', + tabentry => 'switches.switchtype', + access_tabentry => 'switches.switch=attr:node', + }, ); # end of @nodeattrs that applies to both nodes and groups @@ -3778,81 +3831,6 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs); ); -############################# -# switch object # -############################# -# switch table # -############################# -@{$defspec{switch}->{'attrs'}} = ( - {attr_name => 'switch', - tabentry => 'switches.switch', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'groups', - tabentry => 'nodelist.groups', - access_tabentry => 'nodelist.node=attr:node', - }, - {attr_name => 'ip', - tabentry => 'hosts.ip', - access_tabentry => 'hosts.node=attr:node', - }, - {attr_name => 'nodetype', - tabentry => 'nodetype.nodetype', - access_tabentry => 'nodetype.node=attr:node', - }, - {attr_name => 'mgt', - tabentry => 'nodehm.mgt', - access_tabentry => 'nodehm.node=attr:node', - }, - {attr_name => 'snmpusername', - tabentry => 'switches.username', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'snmppassword', - tabentry => 'switches.password', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'snmpversion', - tabentry => 'switches.snmpversion', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'privacy', - tabentry => 'switches.privacy', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'auth', - tabentry => 'switches.auth', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'linkports', - tabentry => 'switches.linkports', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'sshusername', - tabentry => 'switches.sshusername', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'sshpassword', - tabentry => 'switches.sshpassword', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'protocol', - tabentry => 'switches.protocol', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'switchtype', - tabentry => 'switches.switchtype', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'comments', - tabentry => 'switches.comments', - access_tabentry => 'switches.switch=attr:switch', - }, - {attr_name => 'disable', - tabentry => 'switches.disable', - access_tabentry => 'switches.switch=attr:switch', - }, - ); ################################################### diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index ff64d271d..ee5cc3979 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -894,13 +894,13 @@ sub xCATdB { # otherwise, use mkdef to add this switch to # switch table ################################################## - $ret = xCAT::Utils->runxcmd( { command => ['lsdef'], arg => ['-t','switch','-o',$host] }, $sub_req, 0, 1); + $ret = xCAT::Utils->runxcmd( { command => ['lsdef'], arg => ['-t','node','-o',$host] }, $sub_req, 0, 1); if ($::RUNCMD_RC == 0) { - $ret = xCAT::Utils->runxcmd({ command => ['chdef'], arg => ['-t','switch','-o',$host,"ip=$ip","comments=$vendor",'nodetype=switch','mgt=switch',"switchtype=$stype"] }, $sub_req, 0, 1); - $ret = xCAT::Utils->runxcmd({ command => ['chdef'], arg => ['-t','switch','-o',$host,'-p','groups=switch'] }, $sub_req, 0, 1); + $ret = xCAT::Utils->runxcmd({ command => ['chdef'], arg => ['-t','node','-o',$host,"ip=$ip",'nodetype=switch','mgt=switch',"switchtype=$stype"] }, $sub_req, 0, 1); + $ret = xCAT::Utils->runxcmd({ command => ['chdef'], arg => ['-t','node','-o',$host,'-p','groups=switch'] }, $sub_req, 0, 1); } else { - $ret = xCAT::Utils->runxcmd( { command => ['mkdef'], arg => ['-t','switch','-o',$host,'groups=switch',"ip=$ip","comments=$vendor",'nodetype=switch','mgt=switch',"switchtype=$stype"] }, $sub_req, 0, 1); + $ret = xCAT::Utils->runxcmd( { command => ['mkdef'], arg => ['-t','node','-o',$host,'groups=switch',"ip=$ip",'nodetype=switch','mgt=switch',"switchtype=$stype"] }, $sub_req, 0, 1); } if ($::RUNCMD_RC != 0) { @@ -978,8 +978,7 @@ sub format_stanza { $mac = " "; } - $result .= "$host:\n\tobjtype=switch\n"; - $result .= "\tcomments=$vendor\n"; + $result .= "$host:\n\tobjtype=node\n"; $result .= "\tgroups=switch\n"; $result .= "\tip=$ip\n"; $result .= "\tmac=$mac\n"; @@ -987,7 +986,7 @@ sub format_stanza { $result .= "\tnodetype=switch\n"; $result .= "\tswitchtype=$stype\n"; } - return ($result); + return ($result); } #-------------------------------------------------------------------------------- @@ -1019,8 +1018,7 @@ sub format_xml { } $result .= "hostname=$host\n"; - $result .= "objtype=switch\n"; - $result .= "comments=$vendor\n"; + $result .= "objtype=node\n"; $result .= "groups=switch\n"; $result .= "ip=$ip\n"; $result .= "mac=$mac\n";