more for xCAT baremetal driver for OpenStack

This commit is contained in:
linggao 2014-02-27 11:01:15 -05:00
parent e6dc6f8a22
commit 3389774e1b
6 changed files with 86 additions and 11 deletions

View File

@ -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'])

View File

@ -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()

View File

@ -12,23 +12,38 @@ B<opsaddbmnode> [B<-v>|B<--version>]
=head1 DESCRIPTION
The B<opsaddbmnode> command registers xCAT nodes to an OpenStack cloud.
The B<opsaddbmnode> 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<noderage> is a comma separated node or node group names.
@ -56,7 +71,7 @@ I<noderage> 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.

View File

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

View File

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

View File

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