當前位置: 首頁>>代碼示例>>Python>>正文


Python ProfitBricksService.remove_snapshot方法代碼示例

本文整理匯總了Python中profitbricks.client.ProfitBricksService.remove_snapshot方法的典型用法代碼示例。如果您正苦於以下問題:Python ProfitBricksService.remove_snapshot方法的具體用法?Python ProfitBricksService.remove_snapshot怎麽用?Python ProfitBricksService.remove_snapshot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在profitbricks.client.ProfitBricksService的用法示例。


在下文中一共展示了ProfitBricksService.remove_snapshot方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestVolume

# 需要導入模塊: from profitbricks.client import ProfitBricksService [as 別名]
# 或者: from profitbricks.client.ProfitBricksService import remove_snapshot [as 別名]
class TestVolume(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.resource = resource()
        self.client = ProfitBricksService(
            username=configuration.USERNAME,
            password=configuration.PASSWORD,
            headers=configuration.HEADERS)

        # Create test datacenter
        self.datacenter = self.client.create_datacenter(
            datacenter=Datacenter(**self.resource['datacenter']))
        wait_for_completion(self.client, self.datacenter, 'create_datacenter')

        # Create test volume
        self.volume = self.client.create_volume(
            datacenter_id=self.datacenter['id'],
            volume=Volume(**self.resource['volume']))
        wait_for_completion(self.client, self.volume, 'create_volume')

        # Create snapshot1
        self.snapshot1 = self.client.create_snapshot(
            datacenter_id=self.datacenter['id'],
            volume_id=self.volume['id'],
            name=self.resource['snapshot']['name'],
            description=self.resource['snapshot']['description'])
        wait_for_completion(self.client, self.snapshot1, 'create_snapshot1',
                            wait_timeout=600)

        # Create snapshot2 (used in delete test)
        self.snapshot2 = self.client.create_snapshot(
            datacenter_id=self.datacenter['id'],
            volume_id=self.volume['id'],
            name=self.resource['snapshot']['name'],
            description=self.resource['snapshot']['description'])
        wait_for_completion(self.client, self.snapshot2, 'create_snapshop2',
                            wait_timeout=600)

        self.image = find_image(self.client, configuration.IMAGE_NAME)

    @classmethod
    def tearDownClass(self):
        self.client.remove_snapshot(snapshot_id=self.snapshot1['id'])
        self.client.delete_datacenter(datacenter_id=self.datacenter['id'])

    def test_list_volumes(self):
        volumes = self.client.list_volumes(
            datacenter_id=self.datacenter['id'])

        self.assertGreater(len(volumes), 0)
        assertRegex(self, volumes['items'][0]['id'], self.resource['uuid_match'])
        self.assertEqual(volumes['items'][0]['type'], 'volume')
        self.assertEqual(volumes['items'][0]['properties']['name'], self.resource['volume']['name'])
        self.assertEqual(volumes['items'][0]['properties']['size'], self.resource['volume']['size'])
        self.assertEqual(volumes['items'][0]['properties']['licenceType'], self.resource['volume']['licence_type'])
        self.assertEqual(volumes['items'][0]['properties']['type'], self.resource['volume']['type'])
        self.assertFalse(volumes['items'][0]['properties']['cpuHotPlug'])
        self.assertFalse(volumes['items'][0]['properties']['cpuHotUnplug'])
        self.assertFalse(volumes['items'][0]['properties']['ramHotPlug'])
        self.assertFalse(volumes['items'][0]['properties']['ramHotUnplug'])
        self.assertFalse(volumes['items'][0]['properties']['nicHotPlug'])
        self.assertFalse(volumes['items'][0]['properties']['nicHotUnplug'])
        self.assertFalse(volumes['items'][0]['properties']['discVirtioHotPlug'])
        self.assertFalse(volumes['items'][0]['properties']['discVirtioHotUnplug'])
        self.assertFalse(volumes['items'][0]['properties']['discScsiHotPlug'])
        self.assertFalse(volumes['items'][0]['properties']['discScsiHotUnplug'])
        self.assertIsNone(volumes['items'][0]['properties']['bus'])

    def test_get_volume(self):
        volume = self.client.get_volume(
            datacenter_id=self.datacenter['id'],
            volume_id=self.volume['id'])

        self.assertEqual(volume['id'], self.volume['id'])
        self.assertEqual(volume['type'], 'volume')
        self.assertEqual(volume['properties']['name'], self.resource['volume']['name'])
        self.assertEqual(volume['properties']['size'], self.resource['volume']['size'])
        self.assertEqual(volume['properties']['licenceType'], self.resource['volume']['licence_type'])
        self.assertEqual(volume['properties']['type'], self.resource['volume']['type'])
        self.assertFalse(volume['properties']['cpuHotPlug'])
        self.assertFalse(volume['properties']['cpuHotUnplug'])
        self.assertFalse(volume['properties']['ramHotPlug'])
        self.assertFalse(volume['properties']['ramHotUnplug'])
        self.assertFalse(volume['properties']['nicHotPlug'])
        self.assertFalse(volume['properties']['nicHotUnplug'])
        self.assertFalse(volume['properties']['discVirtioHotPlug'])
        self.assertFalse(volume['properties']['discVirtioHotUnplug'])
        self.assertFalse(volume['properties']['discScsiHotPlug'])
        self.assertFalse(volume['properties']['discScsiHotUnplug'])
        self.assertIsNone(volume['properties']['bus'])

    def test_delete_volume(self):
        volume = self.client.create_volume(
            datacenter_id=self.datacenter['id'],
            volume=Volume(**self.resource['volume']))
        wait_for_completion(self.client, volume, 'create_volume')

        volume = self.client.delete_volume(
            datacenter_id=self.datacenter['id'],
            volume_id=volume['id'])
#.........這裏部分代碼省略.........
開發者ID:jbuchhammer,項目名稱:profitbricks-sdk-python,代碼行數:103,代碼來源:test_volume_live.py

示例2: TestVolume

# 需要導入模塊: from profitbricks.client import ProfitBricksService [as 別名]
# 或者: from profitbricks.client.ProfitBricksService import remove_snapshot [as 別名]

#.........這裏部分代碼省略.........

        self.assertEqual(
            volume['properties']['name'], 'Resized storage to 100 GB')
        self.assertEqual(volume['properties']['size'], 100)

    def test_create_volume(self):
        i = Volume(
            name='Explicitly created volume',
            size=56,
            image='<IMAGE/SNAPSHOT-ID>',
            bus='VIRTIO')

        response = self.volume.create_volume(
            datacenter_id=datacenter_id, volume=i)

        self.assertEqual(
            response['properties']['name'], 'my boot volume for server 1')
        self.assertEqual(response['properties']['size'], 80)
        self.assertEqual(response['properties']['licenceType'], 'WINDOWS')
        self.assertFalse(response['properties']['cpuHotPlug'])
        self.assertFalse(response['properties']['cpuHotUnplug'])
        self.assertFalse(response['properties']['ramHotPlug'])
        self.assertFalse(response['properties']['ramHotUnplug'])
        self.assertFalse(response['properties']['nicHotPlug'])
        self.assertFalse(response['properties']['nicHotUnplug'])
        self.assertFalse(response['properties']['discVirtioHotPlug'])
        self.assertFalse(response['properties']['discVirtioHotUnplug'])
        self.assertFalse(response['properties']['discScsiHotPlug'])
        self.assertFalse(response['properties']['discScsiHotUnplug'])
        self.assertEqual(response['properties']['bus'], 'VIRTIO')
        self.assertEqual(response['properties']['type'], 'HDD')

    def test_create_optional_value(self):
        i = Volume(
            name='Explicitly created volume',
            size=56,
            image='<IMAGE/SNAPSHOT-ID>',
            bus='VIRTIO',
            ram_hot_plug=True,
            cpu_hot_unplug=True)

        response = self.volume.create_volume(
            datacenter_id=datacenter_id, volume=i)

        self.assertEqual(
            response['properties']['name'], 'my boot volume for server 1')
        self.assertEqual(response['properties']['size'], 80)
        self.assertEqual(response['properties']['licenceType'], 'WINDOWS')
        self.assertFalse(response['properties']['cpuHotPlug'])
        self.assertFalse(response['properties']['cpuHotUnplug'])
        self.assertFalse(response['properties']['ramHotPlug'])
        self.assertFalse(response['properties']['ramHotUnplug'])
        self.assertFalse(response['properties']['nicHotPlug'])
        self.assertFalse(response['properties']['nicHotUnplug'])
        self.assertFalse(response['properties']['discVirtioHotPlug'])
        self.assertFalse(response['properties']['discVirtioHotUnplug'])
        self.assertFalse(response['properties']['discScsiHotPlug'])
        self.assertFalse(response['properties']['discScsiHotUnplug'])
        self.assertEqual(response['properties']['bus'], 'VIRTIO')
        self.assertEqual(response['properties']['type'], 'HDD')

    def test_create_snapshot(self):
        volume = self.volume.create_snapshot(
            datacenter_id=datacenter_id,
            volume_id=volume_id,
            name='<URLENCODED_SNAPSHOT_NAME>',
            description='<URLENCODED_SNAPSHOT_DESCRIPTION>')

        self.assertEqual(volume['id'], snapshot_id)
        self.assertEqual(
            volume['properties']['name'],
            'Snapshot of storage X on 12.12.12 12:12:12 - updated')
        self.assertEqual(volume['properties']['description'],
                         'description of a snapshot - updated')
        self.assertEqual(volume['properties']['location'], 'de/fkb')
        self.assertEqual(volume['properties']['size'], 28)
        self.assertEqual(volume['properties']['licenceType'], 'WINDOWS')
        self.assertFalse(volume['properties']['cpuHotPlug'])
        self.assertFalse(volume['properties']['cpuHotUnplug'])
        self.assertFalse(volume['properties']['ramHotPlug'])
        self.assertFalse(volume['properties']['ramHotUnplug'])
        self.assertFalse(volume['properties']['nicHotPlug'])
        self.assertFalse(volume['properties']['nicHotUnplug'])
        self.assertFalse(volume['properties']['discVirtioHotPlug'])
        self.assertFalse(volume['properties']['discVirtioHotUnplug'])
        self.assertFalse(volume['properties']['discScsiHotPlug'])
        self.assertFalse(volume['properties']['discScsiHotUnplug'])

    def test_restore_snapshot(self):
        response = self.volume.restore_snapshot(
            datacenter_id=datacenter_id,
            volume_id=volume_id,
            snapshot_id=snapshot_id)

        self.assertTrue(response)

    def test_remove_snapshot(self):
        volume = self.volume.remove_snapshot(snapshot_id=snapshot_id)

        self.assertTrue(volume)
開發者ID:grandvizier,項目名稱:profitbricks-sdk-python,代碼行數:104,代碼來源:test_volume.py


注:本文中的profitbricks.client.ProfitBricksService.remove_snapshot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。