From b21ee18901881d2571a27c2cd6a5a5ea954a0ac3 Mon Sep 17 00:00:00 2001 From: jjhua Date: Fri, 25 Oct 2013 14:45:37 -0400 Subject: [PATCH] add a new postscript configbr-ex to configure the external bridge for Cloud --- xCAT-OpenStack/lib/perl/xCAT/Cloud.pm | 13 +++++++++++-- xCAT-server/lib/perl/xCAT/Postage.pm | 5 +++-- xCAT/postscripts/confignics | 26 +++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/xCAT-OpenStack/lib/perl/xCAT/Cloud.pm b/xCAT-OpenStack/lib/perl/xCAT/Cloud.pm index 171b7ad4b..72b71d844 100644 --- a/xCAT-OpenStack/lib/perl/xCAT/Cloud.pm +++ b/xCAT-OpenStack/lib/perl/xCAT/Cloud.pm @@ -58,12 +58,14 @@ sub getcloudinfo xCAT::MsgUtils->message("E", "Unable to open $tab table"); return undef; } - my @rs = $ptab->getAllAttribs('name','repository'); + my @rs = $ptab->getAllAttribs('name','repository', 'pubinterface'); foreach my $r ( @rs ) { my $cloud = $r->{'name'}; my $repos = $r->{'repository'}; + my $pubinterface = $r->{'pubinterface'}; $info{ $cloud }{repository} = $repos; + $info{ $cloud }{pubinterface} = $pubinterface; } $tab = "cloud"; @@ -122,11 +124,18 @@ sub getcloudinfo sub getcloudres { my $cloudinfo_hash = shift; + my $node = shift; my $clients = shift; my $cloudres; my $cloudlist; - my $repos; + my $repos;use Data::Dumper; print Dumper($cloudinfo_hash); if( @$clients == 0 ) { + #This should not be a chef-server, and it's a chef-client + if( defined($cloudinfo_hash) && defined($cloudinfo_hash->{$node}) ) { + my $cloud=$cloudinfo_hash->{$node}->{cloud}; + my $pubinterface=$cloudinfo_hash->{$cloud}->{pubinterface}; + $cloudres="PUBINTERFACE='$pubinterface'\nexport PUBINTERFACE\n"; + } return $cloudres; } foreach my $client (@$clients) { diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index 2e12c6409..2e0d4ac67 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -485,7 +485,7 @@ sub makescript { my $cloudres; $cfgres = getcfgres($cfginfo_hash, $node, \@clients); if ( $cloud_exists == 1 ) { - $cloudres = getcloudres($cloud_module_name, $cloud_exists, $cloudinfo_hash, \@clients); + $cloudres = getcloudres($cloud_module_name, $cloud_exists, $cloudinfo_hash, $node, \@clients); } #ok, now do everything else.. @@ -1815,6 +1815,7 @@ sub getcloudres my $module_name = shift; my $cloud_exists = shift; my $cloudinfo_hash = shift; + my $node = shift; my $clients = shift; my $result; @@ -1822,7 +1823,7 @@ sub getcloudres if ( $cloud_exists ) { no strict "refs"; if (defined(${$module_name."::"}{getcloudres})) { - $result=${$module_name."::"}{getcloudres}($cloudinfo_hash, $clients); + $result=${$module_name."::"}{getcloudres}($cloudinfo_hash, $node, $clients); } } return $result; diff --git a/xCAT/postscripts/confignics b/xCAT/postscripts/confignics index 4fc91aae6..f523d9b1c 100755 --- a/xCAT/postscripts/confignics +++ b/xCAT/postscripts/confignics @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash str_dir_name=`dirname $0` . $str_dir_name/xcatlib.sh @@ -59,6 +59,22 @@ do fi done +boot_myscript=0 +if [ $# -eq 2 ] +then + if [ "$1" = "--script" ] + then + if [ $bool_cfg_inst_nic -eq 1 -o $bool_remove -eq 1 -o ! -z "$num_iba_ports" ] + then + logger -t xcat -p local4.info "confignics --script could Not be used with other options" + echo "confignics --script could Not be used with other options" + exit -1 + fi + boot_myscript=1 + myscript=$2; + fi +fi + logger -t xcat -p local4.info "confignics is called: config install nic:$bool_cfg_inst_nic, remove: $bool_remove, iba ports: $num_iba_ports" echo "confignics on $NODE: config install nic:$bool_cfg_inst_nic, remove: $bool_remove, iba ports: $num_iba_ports" @@ -132,6 +148,14 @@ splitconfig $NICTYPES splitconfig $NICNETWORKS splitconfig $NICCUSTOMSCRIPTS +if [ $boot_myscript -eq 1 ];then + . $str_dir_name/$myscript + if [ $? -ne 0 ];then + exit -1 + fi + exit 0 +fi + #get state of nic in "UP" status #If bonded redhat then "SLAVE" or "MASTER" will be in the first line of stanza #do not configure the loopback nic