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


Python Volume.id方法代码示例

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


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

示例1: test_delete_orphaned_volumes

# 需要导入模块: from boto.ec2.volume import Volume [as 别名]
# 或者: from boto.ec2.volume.Volume import id [as 别名]
    def test_delete_orphaned_volumes(self):
        """ Test that we clean up instance volumes that are orphaned by AWS.
        """
        aws_svc, encryptor_image, guest_image = build_aws_service()

        # Simulate a tagged orphaned volume.
        volume = Volume()
        volume.id = test_aws_service.new_id()
        aws_svc.volumes[volume.id] = volume
        aws_svc.tagged_volumes.append(volume)

        # Verify that lookup succeeds before encrypt().
        self.assertEqual(volume, aws_svc.get_volume(volume.id))
        self.assertEqual(
            [volume],
            aws_svc.get_volumes(
                tag_key=encrypt_ami.TAG_ENCRYPTOR_SESSION_ID, tag_value='123')
        )

        encrypt_ami.encrypt(
            aws_svc=aws_svc,
            enc_svc_cls=DummyEncryptorService,
            image_id=guest_image.id,
            encryptor_ami=encryptor_image.id
        )

        # Verify that the volume was deleted.
        self.assertIsNone(aws_svc.volumes.get(volume.id, None))
开发者ID:robertabbott,项目名称:brkt-cli,代码行数:30,代码来源:test_encrypt_ami.py

示例2: run_instance

# 需要导入模块: from boto.ec2.volume import Volume [as 别名]
# 或者: from boto.ec2.volume.Volume import id [as 别名]
    def run_instance(self,
                     image_id,
                     security_group_ids=None,
                     instance_type='m3.medium',
                     block_device_map=None):
        instance = Instance()
        instance.id = _new_id()
        instance.root_device_name = '/dev/sda1'
        instance._state.code = 0
        instance._state.name = 'pending'

        # Create volumes based on block device data from the image.
        image = self.get_image(image_id)
        instance_bdm = BlockDeviceMapping()
        for device_name, bdm in image.block_device_mapping.iteritems():
            # Create a new volume and attach it to the instance.
            volume = Volume()
            volume.size = 8
            volume.id = _new_id()
            self.volumes[volume.id] = volume

            bdt = BlockDeviceType(volume_id=volume.id, size=8)
            instance_bdm[device_name] = bdt

        instance.block_device_mapping = instance_bdm
        self.instances[instance.id] = instance

        return instance
开发者ID:jimvoll,项目名称:brkt-cli,代码行数:30,代码来源:test.py

示例3: _create_template_ebs_volume

# 需要导入模块: from boto.ec2.volume import Volume [as 别名]
# 或者: from boto.ec2.volume.Volume import id [as 别名]
    def _create_template_ebs_volume(self, operation):
        """
        Helper function to create template EBS volume to work on.

        :param NamedConstant operation: Intended use of created template.
            A value from ``VolumeOperations``.

        :returns: Suitable volume in the right start state for input operation.
        :rtype: boto.ec2.volume.Volume
        """
        volume = EbsVolume()

        # Irrelevant volume attributes.
        volume.id = u'vol-9c48a689'
        volume.create_time = u'2015-07-14T22:46:00.447Z'
        volume.size = 1
        volume.snapshot_id = ''
        volume.zone = u'us-west-2b'
        volume.type = u'standard'

        volume_state_table = VolumeStateTable()
        state_flow = volume_state_table.table[operation]
        start_state = state_flow.start_state.value

        # Interesting volume attribute.
        volume.status = start_state

        return volume
开发者ID:hackday-profilers,项目名称:flocker,代码行数:30,代码来源:test_ebs.py

示例4: create_volume

# 需要导入模块: from boto.ec2.volume import Volume [as 别名]
# 或者: from boto.ec2.volume.Volume import id [as 别名]
 def create_volume(self, size, zone, **kwargs):
     volume = Volume()
     volume.id = 'vol-' + new_id()
     volume.size = size
     volume.zone = zone
     volume.status = 'available'
     self.volumes[volume.id] = volume
     return volume
开发者ID:patlachance,项目名称:brkt-cli,代码行数:10,代码来源:test_aws_service.py

示例5: detach_volume

# 需要导入模块: from boto.ec2.volume import Volume [as 别名]
# 或者: from boto.ec2.volume.Volume import id [as 别名]
def detach_volume(ec2_conn, volume_id, force=False, logger=None, timeout=DEFAULT_TIMEOUT):
    logger = logger or logging.getLogger(__name__)
    if isinstance(volume_id, basestring):
        vol = Volume(ec2_conn)
        vol.id = volume_id
    else:
        vol = volume_id

    logger.debug('Detaching volume %s', vol.id)
    try:
        vol.detach(force)
    except BotoServerError, e:
        if e.code != 'IncorrectState':
            raise
开发者ID:AnyBucket,项目名称:scalarizr,代码行数:16,代码来源:ebstool.py

示例6: run_instance

# 需要导入模块: from boto.ec2.volume import Volume [as 别名]
# 或者: from boto.ec2.volume.Volume import id [as 别名]
    def run_instance(self,
                     image_id,
                     security_group_ids=None,
                     instance_type='c3.xlarge',
                     placement=None,
                     block_device_map=None,
                     subnet_id=None,
                     user_data=None,
                     ebs_optimized=True,
                     instance_profile_name=None):
        instance = Instance()
        instance.id = new_id()
        instance.image_id = image_id
        instance.root_device_name = '/dev/sda1'
        instance._state.code = 0
        instance._state.name = 'pending'

        # Create volumes based on block device data from the image.
        image = self.get_image(image_id)
        instance_bdm = BlockDeviceMapping()
        for device_name, bdm in image.block_device_mapping.iteritems():
            # Create a new volume and attach it to the instance.
            volume = Volume()
            volume.size = 8
            volume.id = new_id()
            self.volumes[volume.id] = volume

            bdt = BlockDeviceType(volume_id=volume.id, size=8)
            instance_bdm[device_name] = bdt

        instance.block_device_mapping = instance_bdm
        self.instances[instance.id] = instance

        if self.run_instance_callback:
            args = RunInstanceArgs()
            args.image_id = image_id
            args.instance_type = instance_type
            args.ebs_optimized = ebs_optimized
            args.security_group_ids = security_group_ids
            args.subnet_id = subnet_id
            args.user_data = user_data
            args.instance = instance
            self.run_instance_callback(args)

        return instance
开发者ID:patlachance,项目名称:brkt-cli,代码行数:47,代码来源:test_aws_service.py

示例7: attach_volume

# 需要导入模块: from boto.ec2.volume import Volume [as 别名]
# 或者: from boto.ec2.volume.Volume import id [as 别名]
def attach_volume(ec2_conn, volume_id, instance_id, devname, to_me=False, logger=None, timeout=DEFAULT_TIMEOUT):
    logger = logger or logging.getLogger(__name__)
    if isinstance(volume_id, basestring):
        vol = Volume(ec2_conn)
        vol.id = volume_id
    else:
        vol = volume_id

    def attach():
        try:
            vol.attach(instance_id, devname)
        except BotoServerError, e:
            if e.status == 400 and not e.code:
                # RHEL here can raise Null body error
                return
            else:
                raise
        return 1
开发者ID:AnyBucket,项目名称:scalarizr,代码行数:20,代码来源:ebstool.py

示例8: test_wait_for_volume

# 需要导入模块: from boto.ec2.volume import Volume [as 别名]
# 或者: from boto.ec2.volume.Volume import id [as 别名]
    def test_wait_for_volume(self):
        aws_svc, encryptor_image, guest_image = build_aws_service()

        # Create a dummy volume.
        volume = Volume()
        volume.size = 8
        volume.id = new_id()
        volume.status = 'detaching'
        aws_svc.volumes[volume.id] = volume

        def transition_to_available(callback_volume):
            self.num_calls += 1
            self.assertEqual(volume, callback_volume)
            self.assertFalse(self.num_calls > 5)

            if self.num_calls == 5:
                volume.status = 'available'

        aws_svc.get_volume_callback = transition_to_available
        result = aws_service.wait_for_volume(aws_svc, volume.id)
        self.assertEqual(volume, result)
开发者ID:patlachance,项目名称:brkt-cli,代码行数:23,代码来源:test_aws_service.py


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