当前位置: 首页>>代码示例>>Python>>正文


Python healthnmonResourceModel.Vm类代码示例

本文整理汇总了Python中healthnmon.resourcemodel.healthnmonResourceModel.Vm的典型用法代码示例。如果您正苦于以下问题:Python Vm类的具体用法?Python Vm怎么用?Python Vm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Vm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_vm_deleted_event

    def test_vm_deleted_event(self):
        self.mox.StubOutWithMock(api, 'vm_delete_by_ids')

        api.vm_delete_by_ids(mox.IgnoreArg(),
                             mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        deleted_vm_id = '25f04dd3-e924-02b2-9eac-876e3c943123'
        deleted_vm = Vm()
        deleted_vm.id = deleted_vm_id
        self.mox.StubOutWithMock(
            InventoryCacheManager, 'get_object_from_cache')

        InventoryCacheManager.get_object_from_cache(
            deleted_vm_id,
            Constants.Vm).AndReturn(deleted_vm)
        self.mox.ReplayAll()
        cachedList = ['25f04dd3-e924-02b2-9eac-876e3c943262',
                      deleted_vm_id]
        updatedList = ['25f04dd3-e924-02b2-9eac-876e3c943262']
        self.libvirtVM.processVmDeletes(cachedList, updatedList)
        self.assertTrue(len(test_notifier.NOTIFICATIONS) == 1)
        msg = test_notifier.NOTIFICATIONS[0]
        self.assertTrue(msg is not None)
        self.assertEquals(msg['priority'], notifier_api.INFO)
        event_type = \
            event_metadata.get_EventMetaData(
                event_metadata.EVENT_TYPE_VM_DELETED)
        self.assertEquals(msg['event_type'],
                          event_type.get_event_fully_qal_name())
        payload = msg['payload']
        self.assertEquals(payload['entity_type'], 'Vm')
        self.assertEquals(payload['entity_id'], deleted_vm_id)
开发者ID:rakrup,项目名称:healthnmon,代码行数:31,代码来源:test_vm_events.py

示例2: test_vm_host_get_all_for_vm

 def test_vm_host_get_all_for_vm(self):
     host_id = 'VH1'
     vmhost = VmHost()
     vmhost.id = host_id
     healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
     vm = Vm()
     vm.id = 'VM11'
     vm.set_vmHostId(host_id)
     healthnmon_db_api.vm_save(get_admin_context(), vm)
     vmhosts = \
         healthnmon_db_api.vm_host_get_all(get_admin_context())
     self.assertFalse(vmhosts is None,
                      'Host get by id returned a none list')
     self.assertTrue(len(vmhosts) > 0,
                     'Host get by id returned invalid number of list'
                     )
     self.assertTrue(vmhosts[0].id == host_id)
     vmids = vmhosts[0].get_virtualMachineIds()
     self.assert_(vmids is not None)
     self.assert_(len(vmids) == 1)
     self.assert_(vm.id in vmids)
     healthnmon_db_api.vm_delete_by_ids(get_admin_context(), [vm.id])
     vmhosts = \
         healthnmon_db_api.vm_host_get_all(get_admin_context())
     self.assertTrue(vmhosts[0].id == host_id)
     vmids = vmhosts[0].get_virtualMachineIds()
     self.assert_((vmids is None) or (len(vmids) == 0))
开发者ID:rakrup,项目名称:healthnmon,代码行数:27,代码来源:test_vm_host_db_api.py

示例3: test_vm_netadpater_save

    def test_vm_netadpater_save(self):
        vm = Vm()
        vm.id = 'VM1'
        vmNetAdapter = VmNetAdapter()
        vmNetAdapter.set_id('netAdapter-01')
        vmNetAdapter.set_name('netAdapter-01')
        vmNetAdapter.set_addressType('assigned')
        vmNetAdapter.set_adapterType('E1000')
        vmNetAdapter.set_switchType('vSwitch')
        vmNetAdapter.set_macAddress('00:50:56:81:1c:d0')
        vmNetAdapter.add_ipAddresses('1.1.1.1')
        vmNetAdapter.set_networkName('br100')
        vmNetAdapter.set_vlanId(0)

        vm.add_vmNetAdapters(vmNetAdapter)
        healthnmon_db_api.vm_save(get_admin_context(), vm)
        virual_machines = \
            healthnmon_db_api.vm_get_by_ids(get_admin_context(), ['VM1'
                                                                  ])
        vm_from_db = virual_machines[0]
        netAdapters = vm_from_db.get_vmNetAdapters()
        netAdapter = netAdapters[0]
        self.assertTrue(vmNetAdapter.get_id() == netAdapter.get_id())
        healthnmon_db_api.vm_delete_by_ids(get_admin_context(), [vm.id])

        vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(),
                                              [vm.id])
        self.assertTrue(vms is None or len(vms) == 0, 'VM not deleted')
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:28,代码来源:test_vm_db_api.py

示例4: test_processVmDeletes

    def test_processVmDeletes(self):
        self.mock.StubOutWithMock(api, 'vm_delete_by_ids')

        api.vm_delete_by_ids(mox.IgnoreArg(),
                             mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(nova_db, 'service_get_all_by_topic')

        nova_db.service_get_all_by_topic(
            mox.IgnoreArg(),
            mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mock.StubOutWithMock(InventoryCacheManager,
                                  'get_object_from_cache')
        deleted_vm_id = '25f04dd3-e924-02b2-9eac-876e3c943123'
        deleted_vm = Vm()
        deleted_vm.id = deleted_vm_id

        InventoryCacheManager.get_object_from_cache(
            deleted_vm_id,
            Constants.Vm).AndReturn(deleted_vm)
        self.mock.ReplayAll()
        cachedList = ['25f04dd3-e924-02b2-9eac-876e3c943262',
                      deleted_vm_id]
        updatedList = ['25f04dd3-e924-02b2-9eac-876e3c943262']
        self.assertEquals(self.libvirtVM.processVmDeletes(cachedList,
                          updatedList), None)
        self.assertTrue(deleted_vm_id not in
                        InventoryCacheManager.get_inventory_cache().keys())
        self.mock.stubs.UnsetAll()
开发者ID:rakrup,项目名称:healthnmon,代码行数:28,代码来源:test_Inventory.py

示例5: test_vm_save

    def test_vm_save(self):
        '''
        Insert a vm object into db and check
        whether we are getting proper values after retrieval
        '''
        vm = Vm()
        vm.id = 'VM1-id'
        vm.name = 'VM1-Name'
        vmScsiController = VmScsiController()
        vmScsiController.set_id('VM_CTRL_1')
        vmScsiController.set_id('some_type')
        vm.add_vmScsiControllers(vmScsiController)
        healthnmon_db_api.vm_save(get_admin_context(), vm)

        vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(), [vm.id])
        self.assertTrue(vms is not None)
        self.assertTrue(len(vms) == 1)
        self.assertEqual(vms[0].get_id(), 'VM1-id', "VM id is not same")
        self.assertEqual(vms[0].get_name(), 'VM1-Name', "VM name is not same")
        self.assert_(len(vms[0].get_vmScsiControllers(
        )) == 1, "vmScsiController len mismatch")
        self.assert_(vms[0].get_vmScsiControllers()[0].get_id(
        ) == vmScsiController.get_id(), "vmScsiController id mismatch")
        self.assert_(vms[0].get_vmScsiControllers()[0].get_type() ==
                     vmScsiController.get_type(),
                     "vmScsiController type mismatch")
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:26,代码来源:test_vm_db_api.py

示例6: test_vm_host_get_by_id

    def test_vm_host_get_by_id(self):
        host_id = 'VH1'
        vmhost = VmHost()
        vmhost.id = host_id
        healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
        vm = Vm()
        vm.id = 'VM11'
        vm.set_vmHostId(host_id)
        healthnmon_db_api.vm_save(get_admin_context(), vm)
        mntPnt = HostMountPoint()
        mntPnt.set_vmHostId(host_id)
        mntPnt.set_path('/path')
        volume = StorageVolume()
        volume.set_id('SV11')
        volume.add_mountPoints(mntPnt)
        healthnmon_db_api.storage_volume_save(get_admin_context(),
                                              volume)

        vmhosts = \
            healthnmon_db_api.vm_host_get_by_ids(get_admin_context(),
                                                 [host_id])
        self.assertFalse(vmhosts is None,
                         'Host get by id returned a none list')
        self.assertTrue(len(vmhosts) > 0,
                        'Host get by id returned invalid number of list'
                        )
        self.assertTrue(vmhosts[0].id == host_id)
开发者ID:rakrup,项目名称:healthnmon,代码行数:27,代码来源:test_vm_host_db_api.py

示例7: testGet_long_desc

 def testGet_long_desc(self):
     testVm = Vm()
     testVm.name = 'TestVm'
     test_arg = 'TestArg'
     long_desc = self.metadata.get_long_desc(testVm,
                                             test_arg=test_arg)
     self.assertEquals(long_desc, self.long_desc_tmpl
                       % {'name': testVm.name, 'test_arg': test_arg})
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:8,代码来源:test_event_metadata.py

示例8: test_vm_get_by_id

    def test_vm_get_by_id(self):
        vm_id = 'VM1'
        vm = Vm()
        vm.id = vm_id
        healthnmon_db_api.vm_save(get_admin_context(), vm)

        vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(),
                                              [vm_id])
        self.assertFalse(vms is None,
                         'VM get by id returned a none list')
        self.assertTrue(len(vms) > 0,
                        'VM get by id returned invalid number of list')
        self.assertTrue(vms[0].id == 'VM1')
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:13,代码来源:test_vm_db_api.py

示例9: test_vm_save_none

    def test_vm_save_none(self):
        # Initially insert a vm into db and check the length
        vm = Vm()
        vm.id = 'VM1-id'
        healthnmon_db_api.vm_save(get_admin_context(), vm)
        vms = healthnmon_db_api.vm_get_all(get_admin_context())
        self.assertTrue(vms is not None)
        self.assertTrue(len(vms) == 1)

        # Now try to save the none and check the length is same as previous
        healthnmon_db_api.vm_save(get_admin_context(), None)
        vmsaved = healthnmon_db_api.vm_get_all(get_admin_context())
        self.assertTrue(vmsaved is not None)
        self.assertTrue(len(vmsaved) == 1)
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:14,代码来源:test_vm_db_api.py

示例10: test_vm_delete_none

    def test_vm_delete_none(self):
        # Initially insert a vm into db and check the length
        vm = Vm()
        vm.id = 'VM1-id'
        healthnmon_db_api.vm_save(get_admin_context(), vm)
        vms = healthnmon_db_api.vm_get_all(get_admin_context())
        self.assertTrue(vms is not None)
        self.assertTrue(len(vms) == 1)

        # Now delete the None from db
        healthnmon_db_api.vm_delete_by_ids(get_admin_context(), None)
        vms = healthnmon_db_api.vm_get_all(get_admin_context())
        self.assertTrue(vms is not None)
        self.assertTrue(len(vms) == 1)
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:14,代码来源:test_vm_db_api.py

示例11: testVmPayloadGenerator

 def testVmPayloadGenerator(self):
     metadata = \
         event_metadata.get_EventMetaData(
             event_metadata.EVENT_TYPE_VM_CREATED)
     obj = Vm()
     obj.name = 'TestVm'
     ipProfile = IpProfile()
     ipProfile.ipAddress = '10.10.10.1'
     obj.add_ipAddresses(ipProfile)
     payload = payload_generator.generate_payload(metadata, obj)
     self.assertEquals(payload['entity_type'],
                       obj.__class__.__name__)
     self.assertEquals(payload['name'], obj.name)
     self.assertEquals(payload['ipAddresses'],
                       ipProfile.ipAddress)
开发者ID:rakrup,项目名称:healthnmon,代码行数:15,代码来源:test_payload_generator.py

示例12: _createCache

 def _createCache(self):
     self.mox.StubOutWithMock(api, 'vm_host_get_all')
     vmhost = VmHost()
     vmhost.set_id('vmhost1')
     vm = Vm()
     vm.set_id('vm1')
     stPool = StorageVolume()
     stPool.set_id('stpool1')
     subnet = Subnet()
     subnet.set_id('bridge0')
     api.vm_host_get_all(mox.IgnoreArg()).AndReturn([vmhost])
     self.mox.StubOutWithMock(api, 'vm_get_all')
     api.vm_get_all(mox.IgnoreArg()).AndReturn([vm])
     self.mox.StubOutWithMock(api, 'storage_volume_get_all')
     api.storage_volume_get_all(mox.IgnoreArg()).AndReturn([stPool])
     self.mox.StubOutWithMock(api, 'subnet_get_all')
     api.subnet_get_all(mox.IgnoreArg()).AndReturn([subnet])
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:17,代码来源:test_manager.py

示例13: setUp

 def setUp(self):
     super(APiTest, self).setUp()
     self.mox.StubOutWithMock(nova_db, 'service_get_all_by_topic')
     self.vm = Vm()
     self.vm.set_id('12345')
     self.vm.set_name('TestVm')
     self.flags(healthnmon_notification_drivers=[
         'nova.openstack.common.notifier.test_notifier'])
     test_notifier.NOTIFICATIONS = []
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:9,代码来源:test_api.py

示例14: get_single_vm

 def get_single_vm(self):
     vm_list = []
     vm = Vm()
     vm.set_id('vm-01')
     vm.set_name('vm-01')
     disk1 = VmDisk()
     disk1.set_id('disk-01')
     disk1.set_storageVolumeId('datastore-939')
     disk2 = VmDisk()
     disk2.set_id('disk-02')
     disk2.set_storageVolumeId('datastore-439')
     vm.add_vmDisks(disk1)
     vm.add_vmDisks(disk2)
     vm.set_vmHostId('host-329')
     vm_list.append(vm)
     return vm_list
开发者ID:emonty,项目名称:healthnmon,代码行数:16,代码来源:test_vm.py

示例15: test_vm_delete

    def test_vm_delete(self):
        vm = Vm()
        vm_id = 'VM1'
        vm.id = vm_id
        vmGlobalSettings = VmGlobalSettings()
        vmGlobalSettings.set_id(vm_id)
        vm.set_vmGlobalSettings(vmGlobalSettings)
        healthnmon_db_api.vm_save(get_admin_context(), vm)

        vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(),
                                              [vm_id])
        self.assertFalse(vms is None,
                         'VM get by id returned a none list')
        self.assertTrue(len(vms) > 0,
                        'VM get by id returned invalid number of list')

        healthnmon_db_api.vm_delete_by_ids(get_admin_context(), [vm_id])

        vms = healthnmon_db_api.vm_get_by_ids(get_admin_context(),
                                              [vm_id])
        self.assertTrue(vms is None or len(vms) == 0, 'VM not deleted')
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:21,代码来源:test_vm_db_api.py


注:本文中的healthnmon.resourcemodel.healthnmonResourceModel.Vm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。