Last active
August 29, 2015 14:04
-
-
Save rameshg87/9764b2f70571402cd356 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _parse_driver_info(node): | |
"""Gets the driver specific Node deployment info. | |
This method validates whether the 'driver_info' property of the | |
supplied node contains the required information for this driver to | |
deploy images to the node. | |
:param node: a single Node. | |
:returns: A dict with the driver_info values. | |
""" | |
info = node.driver_info | |
d_info = {} | |
d_info['deploy_iso'] = info.get('deploy_iso') | |
deploy_utils.check_for_missing_params(d_info) | |
return d_info | |
def _parse_deploy_info(node): | |
"""Gets the instance and driver specific Node deployment info. | |
This method validates whether the 'instance_info' and 'driver_info' | |
property of the supplied node contains the required information for | |
this driver to deploy images to the node. | |
:param node: a single Node. | |
:returns: A dict with the instance_info and driver_info values. | |
""" | |
info = {} | |
info.update(iscsi_deploy.parse_instance_info(node)) | |
info.update(_parse_driver_info(node)) | |
return 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. | |
:param task: a TaskManager instance containing the node to act on. | |
:raises: InvalidParameterValue. | |
""" | |
iscsi_deploy.validate(task) | |
props = ['deploy_iso'] | |
d_info = _parse_deploy_info(task.node) | |
iscsi_deploy.validate_glance_image_properties(task.context, d_info, | |
props) | |
@task_manager.require_exclusive_lock | |
def deploy(self, task): | |
"""Start deployment of the task's node'. | |
Fetches instance image, creates a temporary keystone token file, | |
updates the Neutron DHCP port options for next boot, and issues a | |
reboot request to the power driver. | |
This causes the node to boot into the deployment ramdisk and triggers | |
the next phase of PXE-based deployment via | |
VendorPassthru._continue_deploy(). | |
:param task: a TaskManager instance containing the node to act on. | |
:returns: deploy state DEPLOYING. | |
""" | |
iscsi_deploy.cache_instance_image(task.context, task.node) | |
iscsi_deploy.check_image_size(task) | |
# <attach boot iso> | |
# <set ilo to boot from cdrom> | |
manager_utils.node_power_action(task, states.REBOOT) | |
return states.DEPLOYWAIT | |
@task_manager.require_exclusive_lock | |
def tear_down(self, task): | |
"""Tear down a previous deployment on the task's node. | |
Power off the node. All actual clean-up is done in the clean_up() | |
method which should be called separately. | |
:param task: a TaskManager instance containing the node to act on. | |
:returns: deploy state DELETED. | |
""" | |
manager_utils.node_power_action(task, states.POWER_OFF) | |
return states.DELETED | |
def prepare(self, task): | |
"""Prepare the deployment environment for this task's node. | |
Generates the TFTP configuration for PXE-booting both the deployment | |
and user images, fetches the TFTP image from Glance and add it to the | |
local cache. | |
:param task: a TaskManager instance containing the node to act on. | |
""" | |
# <call iscsi_deploy.build_deploy_ramdisk_options() and prepare floppy image> | |
def clean_up(self, task): | |
"""Clean up the deployment environment for the task's node. | |
Unlinks TFTP and instance images and triggers image cache cleanup. | |
Removes the TFTP configuration files for this node. As a precaution, | |
this method also ensures the keystone auth token file was removed. | |
:param task: a TaskManager instance containing the node to act on. | |
""" | |
# <eject virtual media, cleanup swift images> | |
iscsi_deploy.destroy_images(node.uuid) | |
def take_over(self, task): | |
pass | |
class VendorPassthru(base.VendorInterface): | |
"""Interface to mix IPMI and PXE vendor-specific interfaces.""" | |
def get_properties(self): | |
return COMMON_PROPERTIES | |
def validate(self, task, **kwargs): | |
method = kwargs['method'] | |
if method == 'pass_deploy_info': | |
iscsi_deploy.get_deploy_info(task.node, **kwargs) | |
else: | |
raise exception.InvalidParameterValue(_( | |
"Unsupported method (%s) passed to PXE driver.") | |
% method) | |
@task_manager.require_exclusive_lock | |
def _continue_deploy(self, task, **kwargs): | |
node = task.node | |
if node.provision_state != states.DEPLOYWAIT: | |
LOG.error(_LE('Node %s is not waiting to be deployed.'), node.uuid) | |
return | |
# <eject virtual media, cleanup swift images> | |
root_uuid = iscsi_deploy.continue_deploy(task, **kwargs) | |
# <attach boot_iso to virtual media> | |
def vendor_passthru(self, task, **kwargs): | |
method = kwargs['method'] | |
if method == 'pass_deploy_info': | |
self._continue_deploy(task, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment