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


Python ProfitBricksService.restore_snapshot方法代码示例

本文整理汇总了Python中profitbricks.client.ProfitBricksService.restore_snapshot方法的典型用法代码示例。如果您正苦于以下问题:Python ProfitBricksService.restore_snapshot方法的具体用法?Python ProfitBricksService.restore_snapshot怎么用?Python ProfitBricksService.restore_snapshot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在profitbricks.client.ProfitBricksService的用法示例。


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

示例1: ProfitBricksService

# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import restore_snapshot [as 别名]
    snapshot_description='<URLENCODED_SNAPSHOT_DESCRIPTION>')

"""Restore Snapshot
"""
from profitbricks.client import ProfitBricksService

datacenter_id = '700e1cab-99b2-4c30-ba8c-1d273ddba022'
volume_id = '700e1cab-99b2-4c30-ba8c-1d273ddba025'
snapshot_id = '7df81087-5835-41c6-a10b-3e098593bba4'


client = ProfitBricksService(
    username='username', password='password')

response = client.restore_snapshot(
    datacenter_id=datacenter_id,
    volume_id=volume_id,
    snapshot_id=snapshot_id)

"""Update Volume
"""

from profitbricks.client import ProfitBricksService

datacenter_id = '700e1cab-99b2-4c30-ba8c-1d273ddba022'
volume_id = '700e1cab-99b2-4c30-ba8c-1d273ddba025'

client = ProfitBricksService(
    username='username', password='password')

volume = client.update_volume(
    datacenter_id=datacenter_id,
开发者ID:grandvizier,项目名称:profitbricks-sdk-python,代码行数:34,代码来源:volume_example.py

示例2: TestVolume

# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import restore_snapshot [as 别名]

#.........这里部分代码省略.........
        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'])

        self.assertTrue(volume)

    def test_update_volume(self):
        volume = self.client.update_volume(
            datacenter_id=self.datacenter['id'],
            volume_id=self.volume['id'],
            size=6,
            name=self.resource['volume']['name'] + ' RENAME')
        wait_for_completion(self.client, volume, 'update_volume')

        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['properties']['name'], self.resource['volume']['name'] + ' RENAME')
        self.assertEqual(volume['properties']['size'], 6)

    def test_create_volume(self):
        # Use volume created during volume test setup.
        self.assertEqual(self.volume['properties']['name'], self.resource['volume']['name'])
        self.assertEqual(self.volume['properties']['bus'], self.resource['volume']['bus'])
        self.assertEqual(self.volume['properties']['type'], self.resource['volume']['type'])
        self.assertEqual(self.volume['properties']['size'], self.resource['volume']['size'])
        self.assertEqual(self.volume['properties']['licenceType'], self.resource['volume']['licence_type'])
        self.assertFalse(self.volume['properties']['cpuHotPlug'])
        self.assertFalse(self.volume['properties']['cpuHotUnplug'])
        self.assertFalse(self.volume['properties']['ramHotPlug'])
        self.assertFalse(self.volume['properties']['ramHotUnplug'])
        self.assertFalse(self.volume['properties']['nicHotPlug'])
        self.assertFalse(self.volume['properties']['nicHotUnplug'])
        self.assertFalse(self.volume['properties']['discVirtioHotPlug'])
        self.assertFalse(self.volume['properties']['discVirtioHotUnplug'])
        self.assertFalse(self.volume['properties']['discScsiHotPlug'])
        self.assertFalse(self.volume['properties']['discScsiHotUnplug'])

    def test_create_snapshot(self):
        # Use snapshot created during volume test setup.
        assertRegex(self, self.snapshot1['id'], self.resource['uuid_match'])
        self.assertEqual(self.snapshot1['type'], 'snapshot')
        self.assertEqual(self.snapshot1['properties']['name'], self.resource['snapshot']['name'])
        self.assertEqual(self.snapshot1['properties']['description'], self.resource['snapshot']['description'])
        self.assertEqual(self.snapshot1['properties']['location'], configuration.LOCATION)
        self.assertFalse(self.snapshot1['properties']['cpuHotPlug'])
        self.assertFalse(self.snapshot1['properties']['cpuHotUnplug'])
        self.assertFalse(self.snapshot1['properties']['ramHotPlug'])
        self.assertFalse(self.snapshot1['properties']['ramHotUnplug'])
        self.assertFalse(self.snapshot1['properties']['nicHotPlug'])
        self.assertFalse(self.snapshot1['properties']['nicHotUnplug'])
        self.assertFalse(self.snapshot1['properties']['discVirtioHotPlug'])
        self.assertFalse(self.snapshot1['properties']['discVirtioHotUnplug'])
        self.assertFalse(self.snapshot1['properties']['discScsiHotPlug'])
        self.assertFalse(self.snapshot1['properties']['discScsiHotUnplug'])
        self.assertIsNone(self.snapshot1['properties']['size'])
        self.assertIsNone(self.snapshot1['properties']['licenceType'])

    def test_restore_snapshot(self):
        response = self.client.restore_snapshot(
            datacenter_id=self.datacenter['id'],
            volume_id=self.volume['id'],
            snapshot_id=self.snapshot1['id'])

        self.assertTrue(response)

    def test_remove_snapshot(self):
        volume = self.client.remove_snapshot(snapshot_id=self.snapshot2['id'])

        self.assertTrue(volume)

    def test_create_volume_failure(self):
        with self.assertRaises(Exception) as context:
            self.client.create_volume(
                datacenter_id=self.datacenter['id'],
                volume=Volume(image=self.image['id'],
                              **self.resource['volume_failure']))
        exception = ('(422, u\'[(root).properties.image] Passwords/SSH Keys '
                     'are mandatory for public ProfitBricks Images.\')')

        self.assertIn(exception, str(context.exception))
开发者ID:jbuchhammer,项目名称:profitbricks-sdk-python,代码行数:104,代码来源:test_volume_live.py

示例3: TestVolume

# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import restore_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.restore_snapshot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。