Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ComputeTask(task.Task):
- """This task creates a Compute instance
- so far it's not loading the driver properly
- """
- def __init__(self, **kwargs):
- super(ComputeTask, self).__init__(**kwargs)
- self.compute = nova_driver.VirtualMachineManager()
- class ComputeCreate(ComputeTask):
- def revert(self, amphora, *args, **kwargs):
- """This method will revert the creation
- of the
- amphora. So it will just delete it in this
- flow
- """
- LOG.info(i18n._LI("Reverting Nova for amphora with id %s "),
- amphora.id)
- try:
- self.compute.delete(amphora.compute_id)
- amphora.compute_id = None
- except Exception as e:
- LOG.error(i18n._LI("Reverting Nova failed with exception %s"),
- e)
- return
- def execute(self, amphora):
- """Create an amphora
- :returns an amphora
- """
- LOG.debug("Nova Create execute for amphora with id %s" % amphora.id)
- # #Hack to create nova vm
- try:
- nics = []
- for net_id in CONF.api_manager.amp_network_list:
- nics.append({"net-id": net_id})
- compute_id = self.compute.build(name="octavia-test" + uuid.uuid1().hex,
- amphora_flavor=CONF.api_manager.amp_flavor_id,
- image_id=CONF.api_manager.amp_image_id,
- key_name=CONF.api_manager.amp_key_list,
- sec_groups=None,
- network_ids=nics)
- LOG.debug("Server created")
- amphora.compute_id = compute_id
- return amphora
- except Exception as e:
- LOG.error(i18n._LE("Nova create failed: "))
- LOG.debug(e)
- raise e
- class ComputeWait(ComputeTask):
- def execute(self, amphora):
- time.sleep(10)
- if self.compute.status(amphora.compute_id) == constants.AMPHORA_UP:
- return
- raise Exception()
- class Finalize_Amphora_Create(task.Task):
- """This task will finalize the amphora
- with some driver call - this will
- likely move into the driver
- """
- def revert(self, history, *args, **kwargs):
- # Todo(german) call driver revert code
- return
- def execute(self, amphora):
- LOG.debug("Finalize Amphora")
- return None
- class ComputeTask(task.Task):
- """This task creates a Compute instance
- so far it's not loading the driver properly
- """
- def __init__(self, **kwargs):
- super(ComputeTask, self).__init__(**kwargs)
- self.compute = nova_driver.VirtualMachineManager()
- class ComputeCreate(ComputeTask):
- def revert(self, amphora, *args, **kwargs):
- """This method will revert the creation
- of the
- amphora. So it will just delete it in this
- flow
- """
- LOG.info(i18n._LI("Reverting Nova for amphora with id %s "),
- amphora.id)
- try:
- self.compute.delete(amphora.compute_id)
- amphora.compute_id = None
- except Exception as e:
- LOG.error(i18n._LI("Reverting Nova failed with exception %s"),
- e)
- return
- def execute(self, amphora):
- """Create an amphora
- :returns an amphora
- """
- LOG.debug("Nova Create execute for amphora with id %s" % amphora.id)
- # #Hack to create nova vm
- try:
- nics = []
- for net_id in CONF.api_manager.amp_network_list:
- nics.append({"net-id": net_id})
- compute_id = self.compute.build(name="octavia-test" + uuid.uuid1().hex,
- amphora_flavor=CONF.api_manager.amp_flavor_id,
- image_id=CONF.api_manager.amp_image_id,
- key_name=CONF.api_manager.amp_key_list,
- sec_groups=None,
- network_ids=nics)
- LOG.debug("Server created")
- amphora.compute_id = compute_id
- return amphora
- except Exception as e:
- LOG.error(i18n._LE("Nova create failed: "))
- LOG.debug(e)
- raise e
- class ComputeWait(ComputeTask):
- def execute(self, amphora):
- time.sleep(10)
- if self.compute.status(amphora.compute_id) == constants.AMPHORA_UP:
- return
- raise Exception()
- class Finalize_Amphora_Create(task.Task):
- """This task will finalize the amphora
- with some driver call - this will
- likely move into the driver
- """
- def revert(self, history, *args, **kwargs):
- # Todo(german) call driver revert code
- return
- def execute(self, amphora):
- LOG.debug("Finalize Amphora")
- return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement