コード例 #1
0
    def _check_vm_record(self):
        """
        Check if the spawned VM's properties correspond to the instance in
        the db.
        """
        instances = self.conn.list_instances()
        self.assertEquals(len(instances), 1)

        # Get Nova record for VM
        vm_info = self.conn.get_info({'name': 1})

        # Get record for VM
        vms = vmwareapi_fake._get_objects("VirtualMachine")
        vm = vms[0]

        # Check that m1.large above turned into the right thing.
        mem_kib = long(self.type_data['memory_mb']) << 10
        vcpus = self.type_data['vcpus']
        self.assertEquals(vm_info['max_mem'], mem_kib)
        self.assertEquals(vm_info['mem'], mem_kib)
        self.assertEquals(vm.get("summary.config.numCpu"), vcpus)
        self.assertEquals(vm.get("summary.config.memorySizeMB"),
                          self.type_data['memory_mb'])

        # Check that the VM is running according to Nova
        self.assertEquals(vm_info['state'], power_state.RUNNING)

        # Check that the VM is running according to vSphere API.
        self.assertEquals(vm.get("runtime.powerState"), 'poweredOn')
コード例 #2
0
ファイル: test_vmwareapi.py プロジェクト: dnguyenutsa/nova
 def test_find_st(self):
     data = {'target_portal': 'fake_target_host:port',
             'target_iqn': 'fake_target_iqn'}
     host = vmwareapi_fake._get_objects('HostSystem').objects[0]
     host._add_iscsi_target(data)
     result = volume_util.find_st(self.conn._session, data)
     self.assertEquals(('fake-device', 'fake-uuid'), result)
コード例 #3
0
ファイル: test_vmwareapi.py プロジェクト: slagle/nova
 def test_get_vnc_console(self):
     self._create_vm()
     fake_vm = vmwareapi_fake._get_objects("VirtualMachine").objects[0]
     fake_vm_id = int(fake_vm.obj.value.replace("vm-", ""))
     vnc_dict = self.conn.get_vnc_console(self.instance)
     self.assertEquals(vnc_dict["host"], "test_url")
     self.assertEquals(vnc_dict["port"], cfg.CONF.vmware.vnc_port + fake_vm_id % cfg.CONF.vmware.vnc_port_total)
コード例 #4
0
ファイル: test_vmwareapi.py プロジェクト: dnguyenutsa/nova
 def _test_get_vnc_console(self):
     self._create_vm()
     fake_vm = vmwareapi_fake._get_objects("VirtualMachine").objects[0]
     fake_vm_id = int(fake_vm.obj.value.replace('vm-', ''))
     vnc_dict = self.conn.get_vnc_console(self.instance)
     self.assertEqual(vnc_dict['host'], self.vnc_host)
     self.assertEqual(vnc_dict['port'], cfg.CONF.vmware.vnc_port +
                      fake_vm_id % cfg.CONF.vmware.vnc_port_total)
コード例 #5
0
ファイル: test_vmwareapi.py プロジェクト: aneeshpu/nova
 def _test_get_vnc_console(self):
     self._create_vm()
     fake_vm = vmwareapi_fake._get_objects("VirtualMachine").objects[0]
     fake_vm_id = int(fake_vm.obj.value.replace('vm-', ''))
     vnc_dict = self.conn.get_vnc_console(self.instance)
     self.assertEquals(vnc_dict['host'], self.vnc_host)
     self.assertEquals(vnc_dict['port'], cfg.CONF.vmware.vnc_port +
                       fake_vm_id % cfg.CONF.vmware.vnc_port_total)
コード例 #6
0
ファイル: test_vmwareapi.py プロジェクト: qingw/nova
 def test_get_volume_connector(self):
     self._create_vm()
     connector_dict = self.conn.get_volume_connector(self.instance)
     fake_vm = vmwareapi_fake._get_objects("VirtualMachine").objects[0]
     fake_vm_id = fake_vm.obj.value
     self.assertEquals(connector_dict['ip'], 'test_url')
     self.assertEquals(connector_dict['initiator'], 'iscsi-name')
     self.assertEquals(connector_dict['host'], 'test_url')
     self.assertEquals(connector_dict['instance'], fake_vm_id)
コード例 #7
0
ファイル: test_vmwareapi.py プロジェクト: aneeshpu/nova
 def test_get_volume_connector(self):
     self._create_vm()
     connector_dict = self.conn.get_volume_connector(self.instance)
     fake_vm = vmwareapi_fake._get_objects("VirtualMachine").objects[0]
     fake_vm_id = fake_vm.obj.value
     self.assertEquals(connector_dict['ip'], 'test_url')
     self.assertEquals(connector_dict['initiator'], 'iscsi-name')
     self.assertEquals(connector_dict['host'], 'test_url')
     self.assertEquals(connector_dict['instance'], fake_vm_id)
コード例 #8
0
ファイル: test_vmwareapi.py プロジェクト: slagle/nova
 def test_get_volume_connector(self):
     self._create_vm()
     connector_dict = self.conn.get_volume_connector(self.instance)
     fake_vm = vmwareapi_fake._get_objects("VirtualMachine").objects[0]
     fake_vm_id = fake_vm.obj.value
     self.assertEquals(connector_dict["ip"], "test_url")
     self.assertEquals(connector_dict["initiator"], "iscsi-name")
     self.assertEquals(connector_dict["host"], "test_url")
     self.assertEquals(connector_dict["instance"], fake_vm_id)
コード例 #9
0
ファイル: test_vmwareapi.py プロジェクト: dnguyenutsa/nova
    def _check_vm_record(self, num_instances=1):
        """
        Check if the spawned VM's properties correspond to the instance in
        the db.
        """
        instances = self.conn.list_instances()
        self.assertEqual(len(instances), num_instances)

        # Get Nova record for VM
        vm_info = self.conn.get_info({'uuid': 'fake-uuid',
                                      'name': 1,
                                      'node': self.instance_node})

        # Get record for VM
        vms = vmwareapi_fake._get_objects("VirtualMachine")
        vm = vms.objects[0]

        # Check that m1.large above turned into the right thing.
        mem_kib = long(self.type_data['memory_mb']) << 10
        vcpus = self.type_data['vcpus']
        self.assertEqual(vm_info['max_mem'], mem_kib)
        self.assertEqual(vm_info['mem'], mem_kib)
        self.assertEqual(vm.get("summary.config.numCpu"), vcpus)
        self.assertEqual(vm.get("summary.config.memorySizeMB"),
                         self.type_data['memory_mb'])

        self.assertEqual(
            vm.get("config.hardware.device")[2].device.obj_name,
            "ns0:VirtualE1000")
        # Check that the VM is running according to Nova
        self.assertEqual(vm_info['state'], power_state.RUNNING)

        # Check that the VM is running according to vSphere API.
        self.assertEqual(vm.get("runtime.powerState"), 'poweredOn')

        found_vm_uuid = False
        found_iface_id = False
        for c in vm.get("config.extraConfig"):
            if (c.key == "nvp.vm-uuid" and c.value == self.instance['uuid']):
                found_vm_uuid = True
            if (c.key == "nvp.iface-id.0" and c.value == "vif-xxx-yyy-zzz"):
                found_iface_id = True

        self.assertTrue(found_vm_uuid)
        self.assertTrue(found_iface_id)
コード例 #10
0
ファイル: test_vmwareapi.py プロジェクト: aneeshpu/nova
    def _check_vm_record(self, num_instances=1):
        """
        Check if the spawned VM's properties correspond to the instance in
        the db.
        """
        instances = self.conn.list_instances()
        self.assertEquals(len(instances), num_instances)

        # Get Nova record for VM
        vm_info = self.conn.get_info({'uuid': 'fake-uuid',
                                      'name': 1,
                                      'node': self.instance_node})

        # Get record for VM
        vms = vmwareapi_fake._get_objects("VirtualMachine")
        vm = vms.objects[0]

        # Check that m1.large above turned into the right thing.
        mem_kib = long(self.type_data['memory_mb']) << 10
        vcpus = self.type_data['vcpus']
        self.assertEquals(vm_info['max_mem'], mem_kib)
        self.assertEquals(vm_info['mem'], mem_kib)
        self.assertEquals(vm.get("summary.config.numCpu"), vcpus)
        self.assertEquals(vm.get("summary.config.memorySizeMB"),
                          self.type_data['memory_mb'])

        self.assertEqual(
            vm.get("config.hardware.device")[2].device.obj_name,
            "ns0:VirtualE1000")
        # Check that the VM is running according to Nova
        self.assertEquals(vm_info['state'], power_state.RUNNING)

        # Check that the VM is running according to vSphere API.
        self.assertEquals(vm.get("runtime.powerState"), 'poweredOn')

        found_vm_uuid = False
        found_iface_id = False
        for c in vm.get("config.extraConfig"):
            if (c.key == "nvp.vm-uuid" and c.value == self.instance['uuid']):
                found_vm_uuid = True
            if (c.key == "nvp.iface-id.0" and c.value == "vif-xxx-yyy-zzz"):
                found_iface_id = True

        self.assertTrue(found_vm_uuid)
        self.assertTrue(found_iface_id)
コード例 #11
0
ファイル: test_vmwareapi.py プロジェクト: qingw/nova
 def fake_get_vm_ref_from_uuid(session, vm_uuid):
     return vmwareapi_fake._get_objects("VirtualMachine").objects[0]
コード例 #12
0
ファイル: test_vmwareapi.py プロジェクト: qingw/nova
 def fake_get_vm_ref_from_name(session, vm_name):
     self.assertEquals(self.vm_name, vm_name)
     return vmwareapi_fake._get_objects("VirtualMachine").objects[0]
コード例 #13
0
ファイル: test_vmwareapi.py プロジェクト: aneeshpu/nova
 def fake_get_vm_ref_from_uuid(session, vm_uuid):
     return vmwareapi_fake._get_objects("VirtualMachine").objects[0]
コード例 #14
0
ファイル: test_vmwareapi.py プロジェクト: aneeshpu/nova
 def fake_get_vm_ref_from_name(session, vm_name):
     self.assertEquals(self.vm_name, vm_name)
     return vmwareapi_fake._get_objects("VirtualMachine").objects[0]