diff --git a/xCAT-OpenStack-baremetal/lib/python/xcat/openstack/baremetal/driver.py b/xCAT-OpenStack-baremetal/lib/python/xcat/openstack/baremetal/driver.py index 059ed0168..dc3308f61 100644 --- a/xCAT-OpenStack-baremetal/lib/python/xcat/openstack/baremetal/driver.py +++ b/xCAT-OpenStack-baremetal/lib/python/xcat/openstack/baremetal/driver.py @@ -150,8 +150,8 @@ class xCATBareMetalDriver(bm_driver.BareMetalDriver): 'error':str(e)}) bm_driver._update_state(context, node, instance, baremetal_states.ERROR) - def destroy(self, context, instance, network_info, block_device_info=None, - destroy_disks=True): + def destroy(self, instance, network_info, block_device_info=None, + context=None): """Destroy (shutdown and delete) the specified instance. If the instance is not found (for example if networking failed), this @@ -168,6 +168,7 @@ class xCATBareMetalDriver(bm_driver.BareMetalDriver): """ #import pdb #pdb.set_trace() + context = nova_context.get_admin_context() try: node = bm_driver._get_baremetal_node_by_instance_uuid(instance['uuid']) diff --git a/xCAT-OpenStack-baremetal/lib/python/xcat/openstack/baremetal/xcat_driver.py b/xCAT-OpenStack-baremetal/lib/python/xcat/openstack/baremetal/xcat_driver.py index b8b3ac56a..b4068d92e 100644 --- a/xCAT-OpenStack-baremetal/lib/python/xcat/openstack/baremetal/xcat_driver.py +++ b/xCAT-OpenStack-baremetal/lib/python/xcat/openstack/baremetal/xcat_driver.py @@ -137,6 +137,7 @@ class xCAT(object): LOG.warning(errstr) raise exception.xCATCommandError(errstr) else: + self._wait_for_node_reboot(nodename) return power_states.ON def power_off_node(self, nodename): @@ -199,6 +200,7 @@ class xCAT(object): if out: node,status = out.split(": ") + status = status.strip() if status == "booted": LOG.info(_("Deployment for node %s completed.") % nodename) @@ -226,7 +228,7 @@ class xCAT(object): locals = {'errstr':''} def _wait_for_reboot(): - out,err = self._exec_xcat_command("nodels %s nodelist.status" % nodename) + out,err = self._exec_xcat_command("nodestat %s" % nodename) if err: locals['errstr'] = _("Error returned when quering node status" " for node %s:%s") % (nodename, err) @@ -235,7 +237,8 @@ class xCAT(object): if out: node,status = out.split(": ") - if status == "booted": + status = status.strip() + if status == "sshd": LOG.info(_("Rebooting node %s completed.") % nodename) raise loopingcall.LoopingCallDone() diff --git a/xCAT-OpenStack-baremetal/pods/man1/opsaddbmnode.1.pod b/xCAT-OpenStack-baremetal/pods/man1/opsaddbmnode.1.pod index 9fc8ec90e..3f9015380 100644 --- a/xCAT-OpenStack-baremetal/pods/man1/opsaddbmnode.1.pod +++ b/xCAT-OpenStack-baremetal/pods/man1/opsaddbmnode.1.pod @@ -12,23 +12,38 @@ B [B<-v>|B<--version>] =head1 DESCRIPTION -The B command registers xCAT nodes to an OpenStack cloud. +The B command registers xCAT nodes to an OpenStack cloud. An OpenStack nova baremetal node registration command takes several node attributes: + +=over -An OpenStack nova baremetal node registration command takes several node attributes: =item BMC ip addresss, user id and password + =item Name of nova compute host which will control this baremetal node + =item Number of CPUs in the node + =item Memory in the node (MB) + =item Local hard disk in the node (GB) + =item MAC address to provision the node +=back + The opsaddbmnode command pulls the above baremetal node information from xCAT tables and calls "nova baremetal-node-create" to register the baremetal node with the OpenStack cloud. Please make sure the following xCAT tables are filled with correct information for the given nodes before calling this command. + +=over + =item ipmi (for BMC ip addresss, user id and password) + =item mac (for MAC address) + =item hwinv (for CPU, memory and disk info.) +=back + =head1 Parameters I is a comma separated node or node group names. @@ -56,7 +71,7 @@ I is a comma separated node or node group names. =over 3 -=item 1. +=item 1 To register node1, node2 and node3 to OpenStack, sv1 is the compute host. diff --git a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node index b9be1257d..e516a138a 100755 --- a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node +++ b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/config_ops_bm_node @@ -90,6 +90,34 @@ setup_ip() fi } +#change hostname permanently +change_host_name() +{ + str_os_type=$1 + str_hostname=$2 + + hostname $str_hostname + + if [ "$str_os_type" = "sles" ];then + echo "Persistently changing the hostname not implemented yet." + #debian ubuntu + elif [ "$str_os_type" = "debian" ];then + conf_file="/etc/hostname" + echo "$str_hostname" > $conf_file + else + conf_file="/etc/sysconfig/network" + if [ ! -f $conf_file ]; then + touch $conf_file + fi + grep 'HOSTNAME' $conf_file 2>&1 > /dev/null + if [ $? -eq 0 ]; then + sed -i "s/HOSTNAME=.*/HOSTNAME=$str_hostname/" $conf_file + else + echo "HOSTNAME=$str_hostname" >> $conf_file + fi + fi + +} str_os_type=$(get_os_type) echo "os_type=$str_os_type" @@ -101,7 +129,7 @@ fi #change the hostname if [[ -n "$1" ]]; then - hostname $1 + change_host_name $str_os_type $1 fi #Add the openstack ip to the node diff --git a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node index 7a69fed1a..da148f47e 100755 --- a/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node +++ b/xCAT-OpenStack-baremetal/share/xcat/openstack/postscripts/deconfig_ops_bm_node @@ -26,6 +26,34 @@ get_os_type() echo "$str_os_type" } +#change hostname permanently +change_host_name() +{ + str_os_type=$1 + str_hostname=$2 + + hostname $str_hostname + + if [ "$str_os_type" = "sles" ];then + echo "Persistently changing the hostname not implemented yet." + #debian ubuntu + elif [ "$str_os_type" = "debian" ];then + conf_file="/etc/hostname" + echo "$str_hostname" > $conf_file + else + conf_file="/etc/sysconfig/network" + if [ ! -f $conf_file ]; then + touch $conf_file + fi + grep 'HOSTNAME' $conf_file 2>&1 > /dev/null + if [ $? -eq 0 ]; then + sed -i "s/HOSTNAME=.*/HOSTNAME=$str_hostname/" $conf_file + else + echo "HOSTNAME=$str_hostname" >> $conf_file + fi + fi +} + str_os_type=$(get_os_type) echo "os_type=$str_os_type" @@ -37,7 +65,8 @@ if [ $str_os_type == "aix" ]; then fi #change the hostname -hostname $NODE +#hostname $NODE +change_host_name $str_os_type $NODE #remove the openstack ip from the node if [[ -n $1 ]]; then diff --git a/xCAT-OpenStack-baremetal/xCAT-OpenStack-baremetal.spec b/xCAT-OpenStack-baremetal/xCAT-OpenStack-baremetal.spec index afda4c26f..8546e6ad1 100644 --- a/xCAT-OpenStack-baremetal/xCAT-OpenStack-baremetal.spec +++ b/xCAT-OpenStack-baremetal/xCAT-OpenStack-baremetal.spec @@ -85,9 +85,8 @@ rm -rf $RPM_BUILD_ROOT %post #copy the postscripts under /installl/postscripts directory on MN only if [ -f "/etc/xCATMN" ]; then - cp $RPM_INSTALL_PREFIX0/share/xcat/openstack/postscripts/* /install/postscripts + cp $RPM_INSTALL_PREFIX0/share/xcat/openstack/postscripts/* /install/postscripts/ fi -exit 0 %preun #remove postscripts under /installl/postscripts directory on MN only