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


Python healthnmonResourceModel.StorageVolume类代码示例

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


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

示例1: test_timestamp_columns

 def test_timestamp_columns(self):
     """
         Test the time stamp columns createEpoch,
         modifiedEpoch and deletedEpoch
     """
     vol = StorageVolume()
     vol.set_id('vol-01')
     # Check for createEpoch
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.storage_volume_save(self.admin_context, vol)
     epoch_after = utils.get_current_epoch_ms()
     vol_queried = healthnmon_db_api.storage_volume_get_by_ids(
         self.admin_context, [vol.get_id()])[0]
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, vol_queried.get_createEpoch()))
     # Check for lastModifiedEpoch
     vol_modified = vol_queried
     test_utils.unset_timestamp_fields(vol_modified)
     vol_modified.set_name('changed_name')
     epoch_before = utils.get_current_epoch_ms()
     healthnmon_db_api.storage_volume_save(self.admin_context, vol_modified)
     epoch_after = utils.get_current_epoch_ms()
     vol_queried = healthnmon_db_api.storage_volume_get_by_ids(
         self.admin_context, [vol.get_id()])[0]
     self.assert_(
         vol_modified.get_createEpoch() == vol_queried.get_createEpoch())
     self.assert_(test_utils.is_timestamp_between(
         epoch_before, epoch_after, vol_queried.get_lastModifiedEpoch()))
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:28,代码来源:test_storage_volume_db_api.py

示例2: test_storagevolume_save

 def test_storagevolume_save(self):
     storagevolume = StorageVolume()
     storagevolume.id = 'SV1'
     healthnmon_db_api.storage_volume_save(self.admin_context,
                                           storagevolume)
     healthnmon_db_api.storage_volume_save(self.admin_context,
                                           storagevolume)
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:7,代码来源:test_storage_volume_db_api.py

示例3: test_storage_deleted_event

    def test_storage_deleted_event(self):
        self.mox.StubOutWithMock(api, 'storage_volume_delete_by_ids')

        api.storage_volume_delete_by_ids(
            mox.IgnoreArg(),
            mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        self.mox.StubOutWithMock(
            InventoryCacheManager, 'get_object_from_cache')
        deleted_storage_id = '3fbfbefb-17dd-07aa-2dac-13afbedf3be3'
        deleted_storage = StorageVolume()
        deleted_storage.id = deleted_storage_id

        InventoryCacheManager.get_object_from_cache(
            deleted_storage_id,
            Constants.StorageVolume).AndReturn(deleted_storage)
        self.mox.ReplayAll()
        cachedList = [deleted_storage_id,
                      '3fbfbefb-17dd-07aa-2dac-13afbedf1234']
        updatedList = ['3fbfbefb-17dd-07aa-2dac-13afbedf1234']
        self.mox.ReplayAll()
        self.LibvirtStorageVolume.processStorageDeletes(cachedList,
                                                        updatedList)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
        msg = test_notifier.NOTIFICATIONS[0]
        self.assertEquals(msg['priority'], notifier_api.INFO)
        eventMetaData = \
            event_metadata.get_EventMetaData(
                event_metadata.EVENT_TYPE_STORAGE_DELETED)
        event_type = eventMetaData.get_event_fully_qal_name()
        self.assertEquals(msg['event_type'], event_type)
        payload = msg['payload']
        self.assertEquals(payload['entity_type'], 'StorageVolume')
        self.assertEquals(payload['entity_id'], deleted_storage_id)
开发者ID:rakrup,项目名称:healthnmon,代码行数:33,代码来源:test_storage_events.py

示例4: 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

示例5: test_storage_enabled_event

    def test_storage_enabled_event(self):
        storagePool = libvirt.virStoragePool()
        self.mox.StubOutWithMock(api, 'storage_volume_save')

        api.storage_volume_save(
            mox.IgnoreArg(),
            mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        cachedStorageVolume = StorageVolume()
        cachedStorageVolume.id = storagePool.UUIDString()
        cachedStorageVolume.size = 0
        cachedStorageVolume.free = 0
        cachedStorageVolume.connectionState = \
            Constants.STORAGE_STATE_INACTIVE
        self.mox.StubOutWithMock(
            InventoryCacheManager, 'get_object_from_cache')

        InventoryCacheManager.get_object_from_cache(
            storagePool.UUIDString(),
            Constants.StorageVolume).AndReturn(cachedStorageVolume)
        self.mox.ReplayAll()
        self.LibvirtStorageVolume._processStorage(storagePool)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
        msg = test_notifier.NOTIFICATIONS[0]
        self.assertEquals(msg['priority'], notifier_api.INFO)
        event_type = \
            event_metadata.get_EventMetaData(
                event_metadata.EVENT_TYPE_STORAGE_ENABLED)
        self.assertEquals(msg['event_type'],
                          event_type.get_event_fully_qal_name())
        payload = msg['payload']
        self.assertEquals(payload['entity_type'], 'StorageVolume')
        self.assertEquals(payload['entity_id'],
                          storagePool.UUIDString())
        self.assertEquals(payload['state'],
                          Constants.STORAGE_STATE_ACTIVE)
开发者ID:rakrup,项目名称:healthnmon,代码行数:35,代码来源:test_storage_events.py

示例6: test_storage_no_state_change

    def test_storage_no_state_change(self):
        storagePool = libvirt.virStoragePool()
        self.mox.StubOutWithMock(api, 'storage_volume_save')

        api.storage_volume_save(mox.IgnoreArg(),
                                mox.IgnoreArg()).MultipleTimes().AndReturn(None)
        cachedStorageVolume = StorageVolume()
        cachedStorageVolume.id = storagePool.UUIDString()
        cachedStorageVolume.size = 0
        cachedStorageVolume.free = 0
        cachedStorageVolume.connectionState = \
            Constants.STORAGE_STATE_ACTIVE
        self.mox.StubOutWithMock(
            InventoryCacheManager, 'get_object_from_cache')

        InventoryCacheManager.get_object_from_cache(storagePool.UUIDString(),
                                                    Constants.StorageVolume).AndReturn(cachedStorageVolume)
#        self.mox.StubOutWithMock(InventoryCacheManager, 'get_compute_conn_driver')
#
#        InventoryCacheManager.get_compute_conn_driver(self.LibvirtStorageVolume.compute_id,
#                Constants.VmHost).AndReturn(fake.get_connection())
        self.mox.ReplayAll()
        nova_db.service_get_all_by_topic(None, None)
        self.LibvirtStorageVolume._processStorage(storagePool)
        self.assertEquals(len(test_notifier.NOTIFICATIONS), 0)
开发者ID:emonty,项目名称:healthnmon,代码行数:25,代码来源:test_storage_events.py

示例7: _createCache

 def _createCache(self):
     self.mox.StubOutWithMock(api, "vm_host_get_all")
     vmhost = VmHost()
     vmhost.set_id("vmhost1")
     vmhost1 = VmHost()
     vmhost1.set_id("vmhost2")
     vm = Vm()
     vm.set_id("vm1")
     vm.set_powerState(Constants.VM_POWER_STATES[1])
     vm.set_vmHostId("vmhost1")
     vm1 = Vm()
     vm1.set_id("vm2")
     vm1.set_powerState(Constants.VM_POWER_STATES[1])
     vm1.set_vmHostId("vmhost2")
     vmhost.set_virtualMachineIds(["vm1", "vm2"])
     stPool = StorageVolume()
     stPool.set_id("stpool1")
     subNet = Subnet()
     subNet.set_id("net1")
     api.vm_host_get_all(mox.IgnoreArg()).AndReturn([vmhost, vmhost1])
     self.mox.StubOutWithMock(api, "vm_get_all")
     api.vm_get_all(mox.IgnoreArg()).AndReturn([vm, vm1])
     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,代码行数:26,代码来源:test_inventory_manager.py

示例8: test_storagevolume_get_by_id

    def test_storagevolume_get_by_id(self):
        storagevolume_id = 'SV1'
        storagevolume = StorageVolume()
        storagevolume.id = storagevolume_id
        healthnmon_db_api.storage_volume_save(self.admin_context,
                                              storagevolume)

        storagevolumes = \
            healthnmon_db_api.storage_volume_get_by_ids(self.admin_context,
                                                        [storagevolume_id])
        self.assertFalse(storagevolumes is None,
                         'storage volume get by id returned a none list'
                         )
        self.assertTrue(
            len(storagevolumes) > 0,
            'storage volume get by id returned invalid number of list')
        self.assertTrue(storagevolumes[0].id == 'SV1')
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:17,代码来源:test_storage_volume_db_api.py

示例9: _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

示例10: test_vm_host_get_all_for_sv

    def test_vm_host_get_all_for_sv(self):
        host_id = 'VH1'
        vmhost = VmHost()
        vmhost.id = host_id
        healthnmon_db_api.vm_host_save(get_admin_context(), vmhost)
        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_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)
        svlist = vmhosts[0].get_storageVolumeIds()
        self.assert_(svlist is not None)
        self.assert_(len(svlist) == 1)
        self.assert_(volume.get_id() in svlist)

        healthnmon_db_api.storage_volume_delete_by_ids(
            get_admin_context(), [volume.get_id()])
        vmhosts = \
            healthnmon_db_api.vm_host_get_all(get_admin_context())
        self.assertTrue(vmhosts[0].id == host_id)
        svids = vmhosts[0].get_storageVolumeIds()
        self.assert_((svids is None) or (len(svids) == 0))
开发者ID:rakrup,项目名称:healthnmon,代码行数:34,代码来源:test_vm_host_db_api.py

示例11: test_storagevolume_get_all

 def test_storagevolume_get_all(self):
     storagevolume = StorageVolume()
     storagevolume.id = 'SV1'
     healthnmon_db_api.storage_volume_save(self.admin_context,
                                           storagevolume)
     storagevolume = StorageVolume()
     storagevolume.id = 'SV2'
     healthnmon_db_api.storage_volume_save(self.admin_context,
                                           storagevolume)
     storagevolumes = \
         healthnmon_db_api.storage_volume_get_all(self.admin_context)
     self.assertFalse(storagevolumes is None,
                      'storage volume all returned a none list')
     self.assertTrue(len(storagevolumes) == 2,
                     'storage volume all returned invalid number of list'
                     )
     self.assertTrue(
         storagevolumes[0].id == 'SV1', 'Storage volume id mismatch')
     self.assertTrue(
         storagevolumes[1].id == 'SV2', 'Storage volume id mismatch')
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:20,代码来源:test_storage_volume_db_api.py

示例12: test_storagevolume_delete

    def test_storagevolume_delete(self):
        storagevolume = StorageVolume()
        storagevolume_id = 'SV1'
        storagevolume.id = storagevolume_id
        vm = Vm()
        vm.set_id('vm-01')
        vmGlobalSettings = VmGlobalSettings()
        vmGlobalSettings.set_id('vm_01')
        vm.set_vmGlobalSettings(vmGlobalSettings)
        vmDisk = VmDisk()
        vmDisk.set_id('disk-01')
        vmDisk.set_storageVolumeId(storagevolume_id)
        vm.add_vmDisks(vmDisk)
        vmDisk = VmDisk()
        vmDisk.set_id('disk-02')
        vmDisk.set_storageVolumeId('SV2')
        vm.add_vmDisks(vmDisk)
        healthnmon_db_api.vm_save(self.admin_context, vm)

        healthnmon_db_api.storage_volume_save(self.admin_context,
                                              storagevolume)

        storagevolumes = \
            healthnmon_db_api.storage_volume_get_by_ids(self.admin_context,
                                                        [storagevolume_id])
        self.assertFalse(storagevolumes is None,
                         'storage volume get by id returned a none list'
                         )
        self.assertTrue(
            len(storagevolumes) > 0,
            'storage volume get by id returned invalid number of list')

        healthnmon_db_api.storage_volume_delete_by_ids(self.admin_context,
                                                       [storagevolume_id])

        storagevolumes = \
            healthnmon_db_api.storage_volume_get_by_ids(self.admin_context,
                                                        [storagevolume_id])
        self.assertTrue(storagevolumes is None or len(storagevolumes)
                        == 0, 'Storage volume not deleted')
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:40,代码来源:test_storage_volume_db_api.py

示例13: test_processUpdates_hostupdate_event

    def test_processUpdates_hostupdate_event(self):
        defaultInstancesPath = cfg.CONF.instances_path
        cfg.CONF.set_override('instances_path', '/var/lib/libvirt/images')
        storagePool = libvirt.virStoragePool()
        self.mock.StubOutWithMock(api, 'storage_volume_save')

        api.storage_volume_save(mox.IgnoreArg(),
                                mox.IgnoreArg()).MultipleTimes().\
            AndReturn(None)
        cachedStorageVolume = StorageVolume()
        cachedStorageVolume.id = storagePool.UUIDString()
        cachedStorageVolume.size = 0
        cachedStorageVolume.free = 0
        cachedStorageVolume.connectionState = \
            Constants.STORAGE_STATE_INACTIVE
        InventoryCacheManager.update_object_in_cache(
            '95f7101b-892c-c388-867a-8340e5fea27x', cachedStorageVolume)

        self.mock.StubOutWithMock(api, 'storage_volume_delete_by_ids')

        api.storage_volume_delete_by_ids(mox.IgnoreArg(),
                                         mox.IgnoreArg()).MultipleTimes().\
            AndReturn(None)

        self.mock.StubOutWithMock(
            InventoryCacheManager, 'get_compute_conn_driver')

        InventoryCacheManager.get_compute_conn_driver(None,
                                                      Constants.VmHost).\
            AndReturn(fake.
                      get_connection())

        self.mock.ReplayAll()
        self.assertEquals(self.LibvirtStorageVolume.processUpdates(),
                          None)
        self.assertEquals(self.LibvirtStorageVolume._createNovaPool(),
                          None)
        cfg.CONF.set_override('instances_path', defaultInstancesPath)
        self.mock.stubs.UnsetAll()
开发者ID:jessegonzalez,项目名称:healthnmon,代码行数:39,代码来源:test_Inventory.py

示例14: test_diff_dict_emptyDict

 def test_diff_dict_emptyDict(self):
     storagevolume = StorageVolume()
     hostMountPoint = HostMountPoint({})
     storagevolume.add_mountPoints(hostMountPoint)
     storagevolume1 = StorageVolume()
     hostMountPoint1 = HostMountPoint({})
     storagevolume1.add_mountPoints(hostMountPoint1)
     diff = ResourceModelDiff(storagevolume, storagevolume1)
     diff_res = diff.diff_resourcemodel()
     self.assertTrue(len(diff_res) == 0)
开发者ID:rakrup,项目名称:healthnmon,代码行数:10,代码来源:test_resourcemodel_diff.py

示例15: test_diff_getAllMembers_emptyDict

 def test_diff_getAllMembers_emptyDict(self):
     storagevolume = StorageVolume()
     storagevolume1 = StorageVolume()
     self.mox.StubOutWithMock(StorageVolume, 'get_all_members')
     storagevolume.get_all_members().AndReturn({})
     storagevolume1.get_all_members().AndReturn({})
     self.mox.ReplayAll()
     diff = ResourceModelDiff(storagevolume, storagevolume1)
     diff_res = diff.diff_resourcemodel()
     self.assertTrue(len(diff_res) == 0)
开发者ID:rakrup,项目名称:healthnmon,代码行数:10,代码来源:test_resourcemodel_diff.py


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