2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-18 04:10:46 +00:00

remove switch object, use node object to represent a switch

This commit is contained in:
linggao
2015-06-23 14:12:24 -04:00
parent cfd4d88a20
commit b964d1d9ae
2 changed files with 61 additions and 85 deletions

View File

@ -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',
},
);
###################################################

View File

@ -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";