From f89ef9a9ee968c778af3444c7f9d2a39489fcf2b Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Thu, 11 Oct 2018 11:05:02 +0800 Subject: Manage host power from cobbler JIRA: COMPASS-616 1. Use fence_ipmilan to control power of baremetal servers. Add fence_libvirt to control power of virtual servers. 2. Use power_manage field instead of ipmi field 3. Add power_type to specify machine's power manage tool 4. Store power manage information in db and update to cobbler 5. Manage power from cobbler for both virtual and baremetal machines Change-Id: Ic36ae640dc0aa1703566b5b0b549880a71be36e4 Signed-off-by: Harry Huang --- compass-tasks-base/db/api/utils.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'compass-tasks-base/db/api/utils.py') diff --git a/compass-tasks-base/db/api/utils.py b/compass-tasks-base/db/api/utils.py index a44f26e..ef975ef 100644 --- a/compass-tasks-base/db/api/utils.py +++ b/compass-tasks-base/db/api/utils.py @@ -1208,42 +1208,41 @@ def check_name(name): ) -def _check_ipmi_credentials_ip(ip): +def _check_power_manage_ip(ip): check_ip(ip) -def check_ipmi_credentials(ipmi_credentials): - """Check ipmi credentials format is correct.""" - if not ipmi_credentials: +def check_power_manage(power_manage): + """Check power manage format is correct.""" + if not power_manage: return - if not isinstance(ipmi_credentials, dict): + if not isinstance(power_manage, dict): raise exception.InvalidParameter( - 'invalid ipmi credentials %s' % ipmi_credentials - + 'invalid power manage %s' % power_manage ) - for key in ipmi_credentials: + for key in power_manage: if key not in ['ip', 'username', 'password']: raise exception.InvalidParameter( - 'unrecognized field %s in ipmi credentials %s' % ( - key, ipmi_credentials + 'unrecognized field %s in power manage %s' % ( + key, power_manage ) ) for key in ['ip', 'username', 'password']: - if key not in ipmi_credentials: + if key not in power_manage: raise exception.InvalidParameter( - 'no field %s in ipmi credentials %s' % ( - key, ipmi_credentials + 'no field %s in power manage %s' % ( + key, power_manage ) ) - check_ipmi_credential_field = '_check_ipmi_credentials_%s' % key + check_power_manage_field = '_check_power_manage_%s' % key this_module = globals() - if check_ipmi_credential_field in this_module: - this_module[check_ipmi_credential_field]( - ipmi_credentials[key] + if check_power_manage_field in this_module: + this_module[check_power_manage_field]( + power_manage[key] ) else: logging.debug( - 'function %s is not defined', check_ipmi_credential_field + 'function %s is not defined', check_power_manage_field ) -- cgit 1.2.3-korg