upgrade ironic baremetal driver for ironic update a abstract class

This commit is contained in:
chenglch 2014-08-17 22:21:25 -04:00
parent 4903509b05
commit 7e90a37681
4 changed files with 49 additions and 61 deletions

View File

@ -67,6 +67,13 @@ CONF.register_opts(pxe_opts, group='pxe')
CONF.register_opts(xcat_opts, group='xcat')
CONF.import_opt('use_ipv6', 'ironic.netconf')
REQUIRED_PROPERTIES = {
'pxe_deploy_kernel': _("UUID (from Glance) of the deployment kernel. "
"Required."),
'pxe_deploy_ramdisk': _("UUID (from Glance) of the ramdisk that is "
"mounted at boot time. Required."),
}
COMMON_PROPERTIES = REQUIRED_PROPERTIES
EM_SEMAPHORE = 'xcat_pxe'
def _check_for_missing_params(info_dict, param_prefix=''):
@ -173,6 +180,8 @@ def _validate_glance_image(ctx, deploy_info):
class PXEDeploy(base.DeployInterface):
"""PXE Deploy Interface: just a stub until the real driver is ported."""
def get_properties(self):
return COMMON_PROPERTIES
def validate(self, task):
"""Validate the deployment information for the task's node.
@ -219,7 +228,7 @@ class PXEDeploy(base.DeployInterface):
self._config_host_file(d_info,task.node.instance_info.get('fixed_ip_address'))
self._make_dhcp()
self._nodeset_osimage(d_info,task.node.instance_info.get('image_name'))
manager_utils.node_set_boot_device(task, 'net', persistent=True)
manager_utils.node_set_boot_device(task, 'pxe', persistent=True)
manager_utils.node_power_action(task, states.REBOOT)
try:
self._wait_for_node_deploy(task)

View File

@ -34,8 +34,22 @@ CONF.import_opt('min_command_interval',
LOG = logging.getLogger(__name__)
VALID_BOOT_DEVICES = ['net', 'hd', 'cd', 'floppy', 'def', 'stat']
VALID_PRIV_LEVELS = ['ADMINISTRATOR', 'CALLBACK', 'OPERATOR', 'USER']
REQUIRED_PROPERTIES = {
'ipmi_address': _("IP address or hostname of the node. Required.")
}
OPTIONAL_PROPERTIES = {
'ipmi_password': _("password. Optional."),
'ipmi_priv_level': _("privilege level; default is ADMINISTRATOR. One of "
"%s. Optional.") % ', '.join(VALID_PRIV_LEVELS),
'ipmi_username': _("username; default is NULL user. Optional.")
}
COMMON_PROPERTIES = REQUIRED_PROPERTIES.copy()
COMMON_PROPERTIES.update(OPTIONAL_PROPERTIES)
CONSOLE_PROPERTIES = {
'ipmi_terminal_port': _("node's UDP port to connect to. Only required for "
"console access.")
}
TIMING_SUPPORT = None
@ -298,6 +312,8 @@ class XcatPower(base.PowerInterface):
driver=self.__class__.__name__,
reason="Unable to locate usable xcat command in "
"the system path when checking xcat version")
def get_properties(self):
return COMMON_PROPERTIES
def validate(self, task):
"""Validate driver_info for xcat driver.
@ -365,59 +381,6 @@ class XcatPower(base.PowerInterface):
if state != states.POWER_ON:
raise exception.PowerStateFailure(pstate=states.POWER_ON)
class VendorPassthru(base.VendorInterface):
@task_manager.require_exclusive_lock
def _set_boot_device(self, task, device, persistent=False):
"""Set the boot device for a node.
:param task: a TaskManager instance.
:param device: Boot device. One of [net, hd, cd, floppy, def, stat].
:param persistent: Whether to set next-boot, or make the change
permanent. Default: False.
:raises: InvalidParameterValue if an invalid boot device is specified
or if required ipmi parameters are missing.
:raises: IPMIFailure on an error from ipmitool.
"""
if device not in VALID_BOOT_DEVICES:
raise exception.InvalidParameterValue(_(
"Invalid boot device %s specified.") % device)
cmd = "rsetboot"
if persistent:
cmd = cmd + " options=persistent"
driver_info = _parse_driver_info(task.node)
try:
xcat_util.exec_xcatcmd(driver_info, cmd, device)
# TODO(deva): validate (out, err) and add unit test for failure
except xcat_exception.xCATCmdFailure:
LOG.error(_("rsetboot %(node)s %(device)s"),{'node':driver_info['xcat_node]'],
'device':device})
def validate(self, task, **kwargs):
""" run chdef command to config xcat node infomation """
method = kwargs['method']
if method == 'set_boot_device':
device = kwargs.get('device')
if device not in VALID_BOOT_DEVICES:
raise exception.InvalidParameterValue(_(
"Invalid boot device %s specified.") % device)
else:
raise exception.InvalidParameterValue(_(
"Unsupported method (%s) passed to xcat driver.")
% method)
driver_info = _parse_driver_info(task.node)
chdef_node(driver_info)
def vendor_passthru(self, task, **kwargs):
method = kwargs['method']
if method == 'set_boot_device':
return self._set_boot_device(
task,
kwargs.get('device'),
kwargs.get('persistent', False))
class IPMIShellinaboxConsole(base.ConsoleInterface):
"""A ConsoleInterface that uses ipmitool and shellinabox."""
@ -429,6 +392,8 @@ class IPMIShellinaboxConsole(base.ConsoleInterface):
driver=self.__class__.__name__,
reason="Unable to locate usable xcat command in "
"the system path when checking xcat version")
def get_properties(self):
return COMMON_PROPERTIES
def validate(self, task):
"""Validate the Node console info.

View File

@ -23,8 +23,5 @@ class XCATBaremetalDriver(base.BaseDriver):
self.power = xcat_rpower.XcatPower()
self.console = ipmitool.IPMIShellinaboxConsole()
self.deploy = xcat_pxe.PXEDeploy()
self.pxe_vendor = pxe.VendorPassthru()
self.ipmi_vendor = ipmitool.VendorPassthru()
self.mapping = {'pass_deploy_info': self.pxe_vendor,
'set_boot_device': self.ipmi_vendor}
self.vendor = utils.MixinVendorInterface(self.mapping)
self.management = ipmitool.IPMIManagement()
self.vendor = pxe.VendorPassthru()

View File

@ -24,7 +24,24 @@ packages =
[entry_points]
ironic.drivers =
pxe_xcat = ironic.drivers.xcat:XCATBaremetalDriver
agent_ipmitool = ironic.drivers.agent:AgentAndIPMIToolDriver
agent_pyghmi = ironic.drivers.agent:AgentAndIPMINativeDriver
agent_ssh = ironic.drivers.agent:AgentAndSSHDriver
fake = ironic.drivers.fake:FakeDriver
fake_agent = ironic.drivers.fake:FakeAgentDriver
fake_iboot = ironic.drivers.fake:FakeIBootDriver
fake_ipminative = ironic.drivers.fake:FakeIPMINativeDriver
fake_ipmitool = ironic.drivers.fake:FakeIPMIToolDriver
fake_pxe = ironic.drivers.fake:FakePXEDriver
fake_seamicro = ironic.drivers.fake:FakeSeaMicroDriver
fake_ssh = ironic.drivers.fake:FakeSSHDriver
ilo = ironic.drivers.ilo:IloDriver
pxe_iboot = ironic.drivers.pxe:PXEAndIBootDriver
pxe_ipminative = ironic.drivers.pxe:PXEAndIPMINativeDriver
pxe_ipmitool = ironic.drivers.pxe:PXEAndIPMIToolDriver
pxe_seamicro = ironic.drivers.pxe:PXEAndSeaMicroDriver
pxe_ssh = ironic.drivers.pxe:PXEAndSSHDriver
pxe_xcat = ironic.drivers.xcat:XCATBaremetalDriver
[pbr]
autodoc_index_modules = True