def test_vm_is_removed(self):
        vm_id = "VM-1"
        tenant_id = "test"
        network_id = "123"
        port_id = 456
        host_id = "ubuntu1"

        db.remember_vm(vm_id, host_id, port_id, network_id, tenant_id)
        db.forget_vm(vm_id, host_id, port_id, network_id, tenant_id)
        vm_provisioned = db.is_vm_provisioned(vm_id, host_id, port_id, network_id, tenant_id)
        self.assertFalse(vm_provisioned, "The vm should be deleted")
    def test_vm_is_removed(self):
        vm_id = 'VM-1'
        tenant_id = 'test'
        network_id = '123'
        port_id = 456
        host_id = 'ubuntu1'

        db.remember_vm(vm_id, host_id, port_id, network_id, tenant_id)
        db.forget_vm(vm_id, host_id, port_id, network_id, tenant_id)
        vm_provisioned = db.is_vm_provisioned(vm_id, host_id, port_id,
                                              network_id, tenant_id)
        self.assertFalse(vm_provisioned, 'The vm should be deleted')
    def test_vm_is_removed(self):
        vm_id = 'VM-1'
        tenant_id = 'test'
        network_id = '123'
        port_id = 456
        host_id = 'ubuntu1'

        db.remember_vm(vm_id, host_id, port_id, network_id, tenant_id)
        db.forget_vm(vm_id, host_id, port_id, network_id, tenant_id)
        vm_provisioned = db.is_vm_provisioned(vm_id, host_id, port_id,
                                              network_id, tenant_id)
        self.assertFalse(vm_provisioned, 'The vm should be deleted')
Exemple #4
0
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        host_id = port[portbindings.HOST_ID]
        device_id = port['device_id']
        tenant_id = port['tenant_id']
        network_id = port['network_id']
        port_id = port['id']
        with self.eos_sync_lock:
            if db.is_vm_provisioned(device_id, host_id, port_id, network_id,
                                    tenant_id):
                db.forget_vm(device_id, host_id, port_id, network_id,
                             tenant_id)
            # if necessary, delete tenant as well.
            self.delete_tenant(tenant_id)
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        host_id = port[portbindings.HOST_ID]
        device_id = port['device_id']
        tenant_id = port['tenant_id']
        network_id = port['network_id']
        port_id = port['id']
        with self.eos_sync_lock:
            if db.is_vm_provisioned(device_id, host_id, port_id,
                                    network_id, tenant_id):
                db.forget_vm(device_id, host_id, port_id,
                             network_id, tenant_id)
            # if necessary, delete tenant as well.
            self.delete_tenant(tenant_id)
Exemple #6
0
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        # TODO(sukhdev) revisit this once port biniding support is implemented
        host_id = port['binding:host_id']
        device_id = port['device_id']
        tenant_id = port['tenant_id']
        network_id = port['network_id']
        port_id = port['id']
        with self.eos_sync_lock:
            if db.is_vm_provisioned(device_id, host_id, port_id,
                                    network_id, tenant_id):
                db.forget_vm(device_id, host_id, port_id,
                             network_id, tenant_id)
            # if necessary, delete tenant as well.
            self.delete_tenant(tenant_id)
Exemple #7
0
    def delete_port_precommit(self, context):
        """Delete information about a VM and host from the DB."""
        port = context.current

        # TODO(sukhdev) revisit this once port biniding support is implemented
        host_id = port['binding:host_id']
        device_id = port['device_id']
        tenant_id = port['tenant_id']
        network_id = port['network_id']
        port_id = port['id']
        with self.eos_sync_lock:
            if db.is_vm_provisioned(device_id, host_id, port_id,
                                    network_id, tenant_id):
                db.forget_vm(device_id, host_id, port_id,
                             network_id, tenant_id)
            # if necessary, delete tenant as well.
            self.delete_tenant(tenant_id)
    def test_num_vm_is_valid(self):
        tenant_id = "test"
        network_id = "123"
        port_id = 456
        host_id = "ubuntu1"

        vm_to_remember = ["vm1", "vm2", "vm3"]
        vm_to_forget = ["vm2", "vm1"]

        for vm in vm_to_remember:
            db.remember_vm(vm, host_id, port_id, network_id, tenant_id)
        for vm in vm_to_forget:
            db.forget_vm(vm, host_id, port_id, network_id, tenant_id)

        num_vms = len(db.get_vms(tenant_id))
        expected = len(vm_to_remember) - len(vm_to_forget)

        self.assertEqual(expected, num_vms, "There should be %d records, " "got %d records" % (expected, num_vms))
        # clean up afterwards
        db.forget_vm("vm3", host_id, port_id, network_id, tenant_id)
    def test_num_vm_is_valid(self):
        tenant_id = 'test'
        network_id = '123'
        port_id = 456
        host_id = 'ubuntu1'

        vm_to_remember = ['vm1', 'vm2', 'vm3']
        vm_to_forget = ['vm2', 'vm1']

        for vm in vm_to_remember:
            db.remember_vm(vm, host_id, port_id, network_id, tenant_id)
        for vm in vm_to_forget:
            db.forget_vm(vm, host_id, port_id, network_id, tenant_id)

        num_vms = len(db.get_vms(tenant_id))
        expected = len(vm_to_remember) - len(vm_to_forget)

        self.assertEqual(expected, num_vms,
                         'There should be %d records, '
                         'got %d records' % (expected, num_vms))
        # clean up afterwards
        db.forget_vm('vm3', host_id, port_id, network_id, tenant_id)
    def test_num_vm_is_valid(self):
        tenant_id = 'test'
        network_id = '123'
        port_id = 456
        host_id = 'ubuntu1'

        vm_to_remember = ['vm1', 'vm2', 'vm3']
        vm_to_forget = ['vm2', 'vm1']

        for vm in vm_to_remember:
            db.remember_vm(vm, host_id, port_id, network_id, tenant_id)
        for vm in vm_to_forget:
            db.forget_vm(vm, host_id, port_id, network_id, tenant_id)

        num_vms = len(db.get_vms(tenant_id))
        expected = len(vm_to_remember) - len(vm_to_forget)

        self.assertEqual(expected, num_vms,
                         'There should be %d records, '
                         'got %d records' % (expected, num_vms))
        # clean up afterwards
        db.forget_vm('vm3', host_id, port_id, network_id, tenant_id)