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

@@ -489,9 +489,10 @@ class OSInstall():
"""
""" Definition for install states."""
def __init__(self, req, cluster_id):
def __init__(self, req, cluster_id, skip_pxe_ipmi):
self.req = req
self.cluster_id = cluster_id
self.skip_pxe_ipmi = skip_pxe_ipmi
# 5s
self.time_step = 5
# 30 min
@@ -582,6 +583,11 @@ class OSInstall():
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):
# os_version_file and os_version_id only exist one at
# same time
@@ -662,29 +668,6 @@ class OSInstall():
hugepagesize = '1G'
# 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)
kwargs = {'hostname': host_detail['name'],
'iso_path': os_version_file,
@@ -736,21 +719,47 @@ class OSInstall():
kwargs['nova_lv_size'] = host_detail['nova_lv_size']
else:
kwargs['nova_lv_size'] = 0
if host_detail.get('hwm_id') or ipmi_result_flag:
rc, error = install_os(**kwargs)
if rc != 0:
install_os_description = error
LOG.info(
_("install os config failed because of '%s'" % error))
host_status = {'os_status': host_os_status['INSTALL_FAILED'],
'os_progress': 0,
'messages': error}
daisy_cmn.update_db_host_status(self.req, host_detail['id'],
host_status)
msg = "ironic install os return failed for host %s" % \
host_detail['id']
raise exception.OSInstallFailed(message=msg)
rc, error = install_os(**kwargs)
if rc != 0:
install_os_description = error
LOG.info(
_("install os config failed because of '%s'" % error))
host_status = {'os_status': host_os_status['INSTALL_FAILED'],
'os_progress': 0,
'messages': error}
daisy_cmn.update_db_host_status(self.req, host_detail['id'],
host_status)
msg = "ironic install os return failed for host %s" % \
host_detail['id']
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'):
host_hwm_meta = {
"hwm_ip": host_detail.get('hwm_ip'),
@@ -772,9 +781,14 @@ class OSInstall():
'messages': 'Preparing for OS installation'}
daisy_cmn.update_db_host_status(self.req, host_detail['id'],
host_status)
for host_detail in hosts_detail:
self._install_os_for_baremetal(host_detail)
if self.skip_pxe_ipmi and self.skip_pxe_ipmi == 'true':
return
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):
host_manufacturer = host_detail['system'].get('manufacturer')
@@ -832,7 +846,10 @@ class OSInstall():
host_status['messages'] = "OS installed successfully"
# wait for nicfix script complete
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:
if host_status['os_progress'] ==\
host_last_status['os_progress']:

View File

@@ -103,9 +103,10 @@ class InstallTask(object):
"""
""" Definition for install states."""
def __init__(self, req, cluster_id):
def __init__(self, req, cluster_id, skip_pxe_ipmi):
self.req = req
self.cluster_id = cluster_id
self.skip_pxe_ipmi = skip_pxe_ipmi
def _backends_install(self):
backends = get_deployment_backends(
@@ -176,7 +177,8 @@ class InstallTask(object):
max_parallel_os_num - 1) / max_parallel_os_num
recycle_number = 0
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
# max_parallel_os_number which was set in daisy-api.conf
(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.pxe_server_build(req, install_meta)
return {"status": "pxe is installed"}
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._raise_404_if_cluster_deleted(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)
# if have hosts need to install os,
# 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.start()
return {"status": "begin install"}