示例#1
0
def destroy(name, call=None):
    """
    This function irreversibly destroys a virtual machine on the cloud provider.
    Before doing so, it should fire an event on the Salt event bus.

    The tag for this event is `salt/cloud/<vm name>/destroying`.
    Once the virtual machine has been destroyed, another event is fired.
    The tag for that event is `salt/cloud/<vm name>/destroyed`.

    Dependencies:
        list_nodes

    @param name:
    @type name: str
    @param call:
    @type call:
    @return: True if all went well, otherwise an error message
    @rtype: bool|str
    """
    log.info("Attempting to delete instance %s", name)
    if not vb_machine_exists(name):
        return "{0} doesn't exist and can't be deleted".format(name)

    cloud.fire_event('event',
                     'destroying instance',
                     'salt/cloud/{0}/destroying'.format(name), {'name': name},
                     transport=__opts__['transport'])

    vb_destroy_machine(name)

    cloud.fire_event('event',
                     'destroyed instance',
                     'salt/cloud/{0}/destroyed'.format(name), {'name': name},
                     transport=__opts__['transport'])
示例#2
0
文件: virtualbox.py 项目: bryson/salt
    def test_vm_creation_and_destruction(self):
        vm_name = BASE_BOX_NAME
        vb_create_machine(vm_name)
        self.assertMachineExists(vm_name)

        vb_destroy_machine(vm_name)
        self.assertMachineDoesNotExist(vm_name)
示例#3
0
    def test_vm_creation_and_destruction(self):
        vm_name = BASE_BOX_NAME
        vb_create_machine(vm_name)
        self.assertMachineExists(vm_name)

        vb_destroy_machine(vm_name)
        self.assertMachineDoesNotExist(vm_name)
示例#4
0
    def test_create_machine(self):
        vb_name = "NewTestMachine"
        machine = vb_clone_vm(name=vb_name, clone_from=self.name)
        self.assertEqual(machine.get("name"), vb_name)
        self.assertMachineExists(vb_name)

        vb_destroy_machine(vb_name)
        self.assertMachineDoesNotExist(vb_name)
示例#5
0
文件: virtualbox.py 项目: bryson/salt
    def test_create_machine(self):
        vb_name = "NewTestMachine"
        machine = vb_clone_vm(
            name=vb_name,
            clone_from=self.name
        )
        self.assertEqual(machine.get("name"), vb_name)
        self.assertMachineExists(vb_name)

        vb_destroy_machine(vb_name)
        self.assertMachineDoesNotExist(vb_name)
示例#6
0
    def tearDown(self):
        try:
            vb_stop_vm(BOOTABLE_BASE_BOX_NAME)
        except Exception:
            pass

        if vb_machine_exists(INSTANCE_NAME):
            try:
                vb_stop_vm(INSTANCE_NAME)
                vb_destroy_machine(INSTANCE_NAME)
            except Exception as e:
                log.warning("Possibly dirty state after exception", exc_info=True)
示例#7
0
文件: virtualbox.py 项目: bryson/salt
    def tearDown(self):
        try:
            vb_stop_vm(BOOTABLE_BASE_BOX_NAME)
        except Exception:
            pass

        if vb_machine_exists(INSTANCE_NAME):
            try:
                vb_stop_vm(INSTANCE_NAME)
                vb_destroy_machine(INSTANCE_NAME)
            except Exception as e:
                log.warning("Possibly dirty state after exception", exc_info=True)
示例#8
0
文件: virtualbox.py 项目: bryson/salt
def destroy(name, call=None):
    """
    This function irreversibly destroys a virtual machine on the cloud provider.
    Before doing so, it should fire an event on the Salt event bus.

    The tag for this event is `salt/cloud/<vm name>/destroying`.
    Once the virtual machine has been destroyed, another event is fired.
    The tag for that event is `salt/cloud/<vm name>/destroyed`.

    Dependencies:
        list_nodes

    @param name:
    @type name: str
    @param call:
    @type call:
    @return: True if all went well, otherwise an error message
    @rtype: bool|str
    """
    log.info("Attempting to delete instance %s", name)
    if not vb_machine_exists(name):
        return "{0} doesn't exist and can't be deleted".format(name)

    cloud.fire_event(
        'event',
        'destroying instance',
        'salt/cloud/{0}/destroying'.format(name),
        args={'name': name},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    vb_destroy_machine(name)

    cloud.fire_event(
        'event',
        'destroyed instance',
        'salt/cloud/{0}/destroyed'.format(name),
        args={'name': name},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )
示例#9
0
 def tearDown(self):
     vb_destroy_machine(self.name)
     self.assertMachineDoesNotExist(self.name)
示例#10
0
 def tearDown(self):
     """
     Clean up after tests
     """
     if vb_machine_exists(INSTANCE_NAME):
         vb_destroy_machine(INSTANCE_NAME)
示例#11
0
 def tearDownClass(cls):
     vb_destroy_machine(BASE_BOX_NAME)
示例#12
0
文件: virtualbox.py 项目: bryson/salt
 def tearDown(self):
     vb_destroy_machine(self.name)
     self.assertMachineDoesNotExist(self.name)
示例#13
0
文件: virtualbox.py 项目: bryson/salt
 def tearDown(self):
     """
     Clean up after tests
     """
     if vb_machine_exists(INSTANCE_NAME):
         vb_destroy_machine(INSTANCE_NAME)
示例#14
0
文件: virtualbox.py 项目: bryson/salt
 def tearDownClass(cls):
     vb_destroy_machine(BASE_BOX_NAME)