summaryrefslogtreecommitdiffstats
path: root/compass-tasks-base/deployment
diff options
context:
space:
mode:
Diffstat (limited to 'compass-tasks-base/deployment')
-rw-r--r--compass-tasks-base/deployment/deploy_manager.py29
-rw-r--r--compass-tasks-base/deployment/installers/config_manager.py22
-rw-r--r--compass-tasks-base/deployment/installers/os_installers/cobbler/cobbler.py28
-rw-r--r--compass-tasks-base/deployment/utils/constants.py4
4 files changed, 56 insertions, 27 deletions
diff --git a/compass-tasks-base/deployment/deploy_manager.py b/compass-tasks-base/deployment/deploy_manager.py
index baf7cd6..225c31e 100644
--- a/compass-tasks-base/deployment/deploy_manager.py
+++ b/compass-tasks-base/deployment/deploy_manager.py
@@ -111,7 +111,34 @@ class DeployManager(object):
self.os_installer.set_package_installer_config(pk_installer_config)
# start to deploy OS
- return self.os_installer.deploy()
+ result = self.os_installer.deploy()
+ self.reset_server()
+
+ return result
+
+ def poweron_server(self):
+ if not self.os_installer:
+ return
+
+ host_id_list = self.os_installer.config_manager.get_host_id_list()
+ for host_id in host_id_list:
+ self.os_installer.poweron(host_id)
+
+ def poweroff_server(self):
+ if not self.os_installer:
+ return
+
+ host_id_list = self.os_installer.config_manager.get_host_id_list()
+ for host_id in host_id_list:
+ self.os_installer.poweroff(host_id)
+
+ def reset_server(self):
+ if not self.os_installer:
+ return
+
+ host_id_list = self.os_installer.config_manager.get_host_id_list()
+ for host_id in host_id_list:
+ self.os_installer.reset(host_id)
def deploy_target_system(self):
"""Deploy target system to all hosts in the cluster.
diff --git a/compass-tasks-base/deployment/installers/config_manager.py b/compass-tasks-base/deployment/installers/config_manager.py
index d3b28e0..ebee727 100644
--- a/compass-tasks-base/deployment/installers/config_manager.py
+++ b/compass-tasks-base/deployment/installers/config_manager.py
@@ -169,8 +169,8 @@ class HostInfo(object):
self.package_config = self.host_info.setdefault(const.PK_CONFIG, {})
self.roles = self.host_info.setdefault(const.ROLES, [])
self.patched_roles = self.host_info.setdefault(const.PATCHED_ROLES, [])
- self.ipmi = deepcopy(self.host_info.setdefault(const.IPMI, {}))
- self.ipmi_credentials = deepcopy(self.host_info.setdefault(const.IPMI_CREDS, {}))
+ self.power_type = deepcopy(self.host_info.setdefault(const.POWER_TYPE, {}))
+ self.power_manage = deepcopy(self.host_info.setdefault(const.POWER_MANAGE, {}))
self.reinstall_os_flag = self.host_info.get(const.REINSTALL_OS_FLAG)
self.deployed_os_config = self.host_info.setdefault(
const.DEPLOYED_OS_CONFIG, {}
@@ -276,7 +276,8 @@ class HostInfo(object):
def baseinfo(self):
return {
const.REINSTALL_OS_FLAG: self.reinstall_os_flag,
- const.IPMI_CREDS: self.ipmi_credentials,
+ const.POWER_TYPE: self.power_type,
+ const.POWER_MANAGE: self.power_manage,
const.MAC_ADDR: self.mac,
const.NAME: self.name,
const.HOSTNAME: self.hostname,
@@ -516,14 +517,15 @@ class BaseConfigManager(object):
self.validate_host(host_id)
return self.hosts_info[host_id].roles_mapping
- def get_host_ipmi_info(self, host_id):
+ def get_host_power_info(self, host_id):
self.validate_host(host_id)
- if self.hosts_info[host_id].ipmi:
+ if self.hosts_info[host_id].power_manage:
return (
- self.hosts_info[host_id].ipmi[const.IP_ADDR],
- self.hosts_info[host_id].ipmi
- [const.IPMI_CREDS][const.USERNAME],
- self.hosts_info[host_id].ipmi
- [const.IPMI_CREDS][const.USERNAME])
+ self.hosts_info[host_id].power_manage
+ [const.IP_ADDR],
+ self.hosts_info[host_id].power_manage
+ [const.USERNAME],
+ self.hosts_info[host_id].power_manage
+ [const.PASSWORD])
else:
return (None, None, None)
diff --git a/compass-tasks-base/deployment/installers/os_installers/cobbler/cobbler.py b/compass-tasks-base/deployment/installers/os_installers/cobbler/cobbler.py
index 9c2a935..aa74f68 100644
--- a/compass-tasks-base/deployment/installers/os_installers/cobbler/cobbler.py
+++ b/compass-tasks-base/deployment/installers/os_installers/cobbler/cobbler.py
@@ -397,25 +397,25 @@ class CobblerInstaller(OSInstaller):
return cluster_vas_dict
- def _check_and_set_system_impi(self, host_id, sys_id):
+ def _check_and_set_system_power(self, host_id, sys_id):
if not sys_id:
logging.info("System is None!")
return False
system = self.dump_system_info(host_id)
- if system[self.POWER_TYPE] != 'ipmilan' or not system[self.POWER_USER]:
+ if not system.get(self.POWER_TYPE):
# Set sytem power type to ipmilan if needs and set IPMI info
- ipmi_info = self.config_manager.get_host_ipmi_info(host_id)
- if not ipmi_info:
+ power_info = self.config_manager.get_host_power_info(host_id)
+ if not power_info:
logging.info('No IPMI information found! Failed power on.')
return False
- ipmi_ip, ipmi_user, ipmi_pass = ipmi_info
+ ip, username, password = power_info
power_opts = {}
power_opts[self.POWER_TYPE] = 'ipmilan'
- power_opts[self.POWER_ADDR] = ipmi_ip
- power_opts[self.POWER_USER] = ipmi_user
- power_opts[self.POWER_PASS] = ipmi_pass
+ power_opts[self.POWER_ADDR] = ip
+ power_opts[self.POWER_USER] = username
+ power_opts[self.POWER_PASS] = password
self._update_system_config(sys_id, power_opts)
@@ -424,26 +424,26 @@ class CobblerInstaller(OSInstaller):
def poweron(self, host_id):
hostname = self.config_manager.get_hostname(host_id)
sys_id = self._get_create_system(hostname)
- if not self._check_and_set_system_impi(sys_id):
+ if not self._check_and_set_system_power(host_id, sys_id):
return
- self.remote.power_system(sys_id, self.token, power='on')
+ self.remote.power_system(sys_id, 'on', self.token)
logging.info("Host with ID=%d starts to power on!" % host_id)
def poweroff(self, host_id):
hostname = self.config_manager.get_hostname(host_id)
sys_id = self._get_create_system(hostname)
- if not self._check_and_set_system_impi(sys_id):
+ if not self._check_and_set_system_power(host_id, sys_id):
return
- self.remote.power_system(sys_id, self.token, power='off')
+ self.remote.power_system(sys_id, 'off', self.token)
logging.info("Host with ID=%d starts to power off!" % host_id)
def reset(self, host_id):
hostname = self.config_manager.get_hostname(host_id)
sys_id = self._get_create_system(hostname)
- if not self._check_and_set_system_impi(sys_id):
+ if not self._check_and_set_system_power(host_id, sys_id):
return
- self.remote.power_system(sys_id, self.token, power='reboot')
+ self.remote.power_system(sys_id, 'reboot', self.token)
logging.info("Host with ID=%d starts to reboot!" % host_id)
diff --git a/compass-tasks-base/deployment/utils/constants.py b/compass-tasks-base/deployment/utils/constants.py
index e90b1b2..18ee56a 100644
--- a/compass-tasks-base/deployment/utils/constants.py
+++ b/compass-tasks-base/deployment/utils/constants.py
@@ -54,8 +54,8 @@ DOMAIN = 'domain'
HOST_ID = 'host_id'
HOSTNAME = 'hostname'
IP_ADDR = 'ip'
-IPMI = 'ipmi'
-IPMI_CREDS = 'ipmi_credentials'
+POWER_TYPE = 'power_type'
+POWER_MANAGE = 'power_manage'
MAC_ADDR = 'mac'
MGMT_NIC_FLAG = 'is_mgmt'
NETMASK = 'netmask'