add virtual choice of install intreface to avoid ipmi and deploy virtual os

Change-Id: I899508b874e27908821adde5f025868bc200f7b0
Signed-off-by: Yao Lu <lu.yao135@zte.com.cn>
This commit is contained in:
Yao Lu
2016-11-24 21:05:14 +08:00
committed by zhouya
parent 1ca8307de2
commit 4bc3be5ad8
7 changed files with 86 additions and 51 deletions

View File

@@ -1,5 +1,5 @@
#! /bin/bash #! /bin/bash
echo "nameserver 8.8.8.8" > /etc/resolv.conf
daisy_management_ip=$1 daisy_management_ip=$1
yum -y install epel-release yum -y install epel-release
curl -sSL https://get.docker.io | bash curl -sSL https://get.docker.io | bash

View File

@@ -489,9 +489,10 @@ class OSInstall():
""" """
""" Definition for install states.""" """ Definition for install states."""
def __init__(self, req, cluster_id): def __init__(self, req, cluster_id, skip_pxe_ipmi):
self.req = req self.req = req
self.cluster_id = cluster_id self.cluster_id = cluster_id
self.skip_pxe_ipmi = skip_pxe_ipmi
# 5s # 5s
self.time_step = 5 self.time_step = 5
# 30 min # 30 min
@@ -582,6 +583,11 @@ class OSInstall():
return ipmi_result_flag return ipmi_result_flag
def _pxe_os_server_build(self, req):
all_hosts_need_os = get_cluster_hosts_config(req, self.cluster_id)
for host_detail in all_hosts_need_os:
self._install_os_for_baremetal(host_detail)
def _install_os_for_baremetal(self, host_detail): def _install_os_for_baremetal(self, host_detail):
# os_version_file and os_version_id only exist one at # os_version_file and os_version_id only exist one at
# same time # same time
@@ -662,29 +668,6 @@ class OSInstall():
hugepagesize = '1G' hugepagesize = '1G'
# tfg_patch_pkg_file = check_tfg_exist() # tfg_patch_pkg_file = check_tfg_exist()
host_manufacturer = host_detail['system'].get('manufacturer')
if host_detail.get('hwm_id'):
host_hwm_meta = {
"hwm_ip": host_detail.get('hwm_ip'),
"hwm_id": host_detail.get('hwm_id'),
"boot_type": "pxe"
}
self.providerclient(host_hwm_meta['hwm_ip']).node.set_boot(
**host_hwm_meta)
elif host_manufacturer == 'Cisco Systems Inc':
set_pxe_start_of_cisco(host_detail)
else:
if (not host_detail['ipmi_user'] or
not host_detail['ipmi_passwd'] or
not host_detail['ipmi_addr']):
self.message = \
"Invalid ipmi information configed for host %s" \
% host_detail['id']
raise exception.NotFound(message=self.message)
ipmi_result_flag = self._set_boot_or_power_state(host_detail,
'pxe')
host_interfaces = _get_host_interfaces(host_detail) host_interfaces = _get_host_interfaces(host_detail)
kwargs = {'hostname': host_detail['name'], kwargs = {'hostname': host_detail['name'],
'iso_path': os_version_file, 'iso_path': os_version_file,
@@ -736,21 +719,47 @@ class OSInstall():
kwargs['nova_lv_size'] = host_detail['nova_lv_size'] kwargs['nova_lv_size'] = host_detail['nova_lv_size']
else: else:
kwargs['nova_lv_size'] = 0 kwargs['nova_lv_size'] = 0
if host_detail.get('hwm_id') or ipmi_result_flag: rc, error = install_os(**kwargs)
rc, error = install_os(**kwargs) if rc != 0:
if rc != 0: install_os_description = error
install_os_description = error LOG.info(
LOG.info( _("install os config failed because of '%s'" % error))
_("install os config failed because of '%s'" % error)) host_status = {'os_status': host_os_status['INSTALL_FAILED'],
host_status = {'os_status': host_os_status['INSTALL_FAILED'], 'os_progress': 0,
'os_progress': 0, 'messages': error}
'messages': error} daisy_cmn.update_db_host_status(self.req, host_detail['id'],
daisy_cmn.update_db_host_status(self.req, host_detail['id'], host_status)
host_status) msg = "ironic install os return failed for host %s" % \
msg = "ironic install os return failed for host %s" % \ host_detail['id']
host_detail['id'] raise exception.OSInstallFailed(message=msg)
raise exception.OSInstallFailed(message=msg)
def _set_boot_pxe(self, host_detail):
ipmi_result_flag = True
host_manufacturer = host_detail['system'].get('manufacturer')
if host_detail.get('hwm_id'):
host_hwm_meta = {
"hwm_ip": host_detail.get('hwm_ip'),
"hwm_id": host_detail.get('hwm_id'),
"boot_type": "pxe"
}
self.providerclient(host_hwm_meta['hwm_ip']).node.set_boot(
**host_hwm_meta)
elif host_manufacturer == 'Cisco Systems Inc':
set_pxe_start_of_cisco(host_detail)
else:
if (not host_detail['ipmi_user'] or
not host_detail['ipmi_passwd'] or
not host_detail['ipmi_addr']):
self.message = \
"Invalid ipmi information configed for host %s" \
% host_detail['id']
raise exception.NotFound(message=self.message)
ipmi_result_flag = self._set_boot_or_power_state(host_detail,
'pxe')
return ipmi_result_flag
def _set_power_reset(self, host_detail):
if host_detail.get('hwm_id'): if host_detail.get('hwm_id'):
host_hwm_meta = { host_hwm_meta = {
"hwm_ip": host_detail.get('hwm_ip'), "hwm_ip": host_detail.get('hwm_ip'),
@@ -772,9 +781,14 @@ class OSInstall():
'messages': 'Preparing for OS installation'} 'messages': 'Preparing for OS installation'}
daisy_cmn.update_db_host_status(self.req, host_detail['id'], daisy_cmn.update_db_host_status(self.req, host_detail['id'],
host_status) host_status)
if self.skip_pxe_ipmi and self.skip_pxe_ipmi == 'true':
for host_detail in hosts_detail: return
self._install_os_for_baremetal(host_detail) else:
for host_detail in hosts_detail:
ipmi_result_flag = self._set_boot_pxe(host_detail)
if host_detail.get('hwm_id') or ipmi_result_flag:
self._install_os_for_baremetal(host_detail)
self._set_power_reset(host_detail)
def _set_disk_start_mode(self, host_detail): def _set_disk_start_mode(self, host_detail):
host_manufacturer = host_detail['system'].get('manufacturer') host_manufacturer = host_detail['system'].get('manufacturer')
@@ -832,7 +846,10 @@ class OSInstall():
host_status['messages'] = "OS installed successfully" host_status['messages'] = "OS installed successfully"
# wait for nicfix script complete # wait for nicfix script complete
time.sleep(10) time.sleep(10)
self._set_disk_start_mode(host_detail) if self.skip_pxe_ipmi and self.skip_pxe_ipmi == 'true':
return
else:
self._set_disk_start_mode(host_detail)
else: else:
if host_status['os_progress'] ==\ if host_status['os_progress'] ==\
host_last_status['os_progress']: host_last_status['os_progress']:

View File

@@ -103,9 +103,10 @@ class InstallTask(object):
""" """
""" Definition for install states.""" """ Definition for install states."""
def __init__(self, req, cluster_id): def __init__(self, req, cluster_id, skip_pxe_ipmi):
self.req = req self.req = req
self.cluster_id = cluster_id self.cluster_id = cluster_id
self.skip_pxe_ipmi = skip_pxe_ipmi
def _backends_install(self): def _backends_install(self):
backends = get_deployment_backends( backends = get_deployment_backends(
@@ -176,7 +177,8 @@ class InstallTask(object):
max_parallel_os_num - 1) / max_parallel_os_num max_parallel_os_num - 1) / max_parallel_os_num
recycle_number = 0 recycle_number = 0
while order_hosts_need_os: while order_hosts_need_os:
os_install = os_handle.OSInstall(self.req, self.cluster_id) os_install = os_handle.OSInstall(
self.req, self.cluster_id, self.skip_pxe_ipmi)
# all os will be installed batch by batch with # all os will be installed batch by batch with
# max_parallel_os_number which was set in daisy-api.conf # max_parallel_os_number which was set in daisy-api.conf
(order_hosts_need_os, role_hosts_need_os) = os_install.install_os( (order_hosts_need_os, role_hosts_need_os) = os_install.install_os(
@@ -328,8 +330,15 @@ class Controller(controller.BaseController):
os_handle = get_os_handle() os_handle = get_os_handle()
os_handle.pxe_server_build(req, install_meta) os_handle.pxe_server_build(req, install_meta)
return {"status": "pxe is installed"} return {"status": "pxe is installed"}
cluster_id = install_meta['cluster_id'] cluster_id = install_meta['cluster_id']
skip_pxe_ipmi = None
if install_meta.get('skip_pxe_ipmi'):
skip_pxe_ipmi = install_meta['skip_pxe_ipmi']
if 'pxe_only' in install_meta:
os_handle = get_os_handle()
pxe_build = os_handle.OSInstall(req, cluster_id, skip_pxe_ipmi)
pxe_build._pxe_os_server_build(req)
return {"status": "pxe is installed"}
self._enforce(req, 'install_cluster') self._enforce(req, 'install_cluster')
self._raise_404_if_cluster_deleted(req, cluster_id) self._raise_404_if_cluster_deleted(req, cluster_id)
self.valid_used_networks(req, cluster_id) self.valid_used_networks(req, cluster_id)
@@ -346,7 +355,7 @@ class Controller(controller.BaseController):
daisy_cmn.cluster_list_add(cluster_id) daisy_cmn.cluster_list_add(cluster_id)
# if have hosts need to install os, # if have hosts need to install os,
# TECS installataion executed in InstallTask # TECS installataion executed in InstallTask
os_install_obj = InstallTask(req, cluster_id) os_install_obj = InstallTask(req, cluster_id, skip_pxe_ipmi)
os_install_thread = Thread(target=os_install_obj.run) os_install_thread = Thread(target=os_install_obj.run)
os_install_thread.start() os_install_thread.start()
return {"status": "begin install"} return {"status": "begin install"}

View File

@@ -22,7 +22,8 @@ from daisyclient.openstack.common.apiclient import base
# import daisy.queue_process as queue # import daisy.queue_process as queue
# from daisy.queue_process import exec_cmd # from daisy.queue_process import exec_cmd
CREATE_PARAMS = ('cluster_id', 'version_id', 'deployment_interface') CREATE_PARAMS = ('cluster_id', 'version_id',
'deployment_interface', 'skip_pxe_ipmi', 'pxe_only')
OS_REQ_ID_HDR = 'x-openstack-request-id' OS_REQ_ID_HDR = 'x-openstack-request-id'

View File

@@ -1589,6 +1589,10 @@ def do_network_detail(gc, args):
help='Version of TECS.') help='Version of TECS.')
@utils.arg('--deployment-interface', metavar='<DEPLOYMNET>', @utils.arg('--deployment-interface', metavar='<DEPLOYMNET>',
help='Network interface construction of PXE server(eg:eth0).') help='Network interface construction of PXE server(eg:eth0).')
@utils.arg('--skip-pxe-ipmi', metavar='<SKIP>',
help='skip pxe and ipmi(eg:true).')
@utils.arg('--pxe-only', metavar='<PXE>',
help='build pxe of os(eg:true).')
def do_install(dc, args): def do_install(dc, args):
"""Install TECS.""" """Install TECS."""
fields = dict(filter(lambda x: x[1] is not None, vars(args).items())) fields = dict(filter(lambda x: x[1] is not None, vars(args).items()))

View File

@@ -77,8 +77,6 @@ function kolla_install
check_and_install_rpm python-docker-py check_and_install_rpm python-docker-py
check_and_install_rpm ntp check_and_install_rpm ntp
systemctl enable ntpd.service systemctl enable ntpd.service
systemctl stop libvirtd.service
systemctl disable libvirtd.service
systemctl start ntpd.service systemctl start ntpd.service
check_and_install_rpm ansible check_and_install_rpm ansible
check_and_install_rpm python2-crypto check_and_install_rpm python2-crypto

View File

@@ -68,14 +68,20 @@ function all_install
install_rpm_by_yum "daisy" install_rpm_by_yum "daisy"
write_install_log "install daisy dashboard rpm" write_install_log "install daisy dashboard rpm"
install_rpm_by_yum "python-django"
install_rpm_by_daisy_yum "python-django-horizon" install_rpm_by_daisy_yum "python-django-horizon"
install_rpm_by_yum "daisy-dashboard" install_rpm_by_yum "daisy-dashboard"
write_install_log "install clustershell rpm" write_install_log "install clustershell rpm"
install_rpm_by_yum "clustershell" install_rpm_by_yum "clustershell"
write_install_log "install ipmitool rpm" write_install_log "install discover relate rpm"
install_rpm_by_yum "ipmitool" install_rpm_by_yum "ipmitool"
install_rpm_by_yum "syslinux"
write_install_log "install wget rpm"
install_rpm_by_yum "wget"
if [ -f "/etc/zte-docker" ];then if [ -f "/etc/zte-docker" ];then
write_install_log "install pxe_docker_install rpm" write_install_log "install pxe_docker_install rpm"