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


Python volume.Volume类代码示例

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


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

示例1: test_delete_orphaned_volumes

    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,代码行数:28,代码来源:test_encrypt_ami.py

示例2: test_startElement_with_name_tagSet_calls_ResultSet

 def test_startElement_with_name_tagSet_calls_ResultSet(self, ResultSet, startElement):
     startElement.return_value = None
     result_set = mock.Mock(ResultSet([("item", Tag)]))
     volume = Volume()
     volume.tags = result_set
     retval = volume.startElement("tagSet", None, None)
     self.assertEqual(retval, volume.tags)
开发者ID:Timus1712,项目名称:boto,代码行数:7,代码来源:test_volume.py

示例3: run_instance

    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,代码行数:28,代码来源:test.py

示例4: test_startElement_with_name_attachmentSet_returns_AttachmentSet

 def test_startElement_with_name_attachmentSet_returns_AttachmentSet(self, startElement):
     startElement.return_value = None
     attach_data = AttachmentSet()
     volume = Volume()
     volume.attach_data = attach_data
     retval = volume.startElement("attachmentSet", None, None)
     self.assertEqual(retval, volume.attach_data)
开发者ID:Timus1712,项目名称:boto,代码行数:7,代码来源:test_volume.py

示例5: setUp

    def setUp(self):
        self.attach_data = AttachmentSet()
        self.attach_data.id = 1
        self.attach_data.instance_id = 2
        self.attach_data.status = "some status"
        self.attach_data.attach_time = 5
        self.attach_data.device = "/dev/null"

        self.volume_one = Volume()
        self.volume_one.id = 1
        self.volume_one.create_time = 5
        self.volume_one.status = "one_status"
        self.volume_one.size = "one_size"
        self.volume_one.snapshot_id = 1
        self.volume_one.attach_data = self.attach_data
        self.volume_one.zone = "one_zone"

        self.volume_two = Volume()
        self.volume_two.connection = mock.Mock()
        self.volume_two.id = 1
        self.volume_two.create_time = 6
        self.volume_two.status = "two_status"
        self.volume_two.size = "two_size"
        self.volume_two.snapshot_id = 2
        self.volume_two.attach_data = None
        self.volume_two.zone = "two_zone"
开发者ID:Timus1712,项目名称:boto,代码行数:26,代码来源:test_volume.py

示例6: test_startElement_calls_TaggedEC2Object_startElement_with_correct_args

 def test_startElement_calls_TaggedEC2Object_startElement_with_correct_args(self, startElement):
     volume = Volume()
     volume.startElement("some name", "some attrs", None)
     startElement.assert_called_with(
         "some name",
         "some attrs",
         None
     )
开发者ID:B-Rich,项目名称:boto,代码行数:8,代码来源:test_volume.py

示例7: create_volume

 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,代码行数:8,代码来源:test_aws_service.py

示例8: detach_volume

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,代码行数:14,代码来源:ebstool.py

示例9: _create_template_ebs_volume

    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,代码行数:28,代码来源:test_ebs.py

示例10: run_instance

    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,代码行数:45,代码来源:test_aws_service.py

示例11: attach_volume

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,代码行数:18,代码来源:ebstool.py

示例12: test_wait_for_volume

    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,代码行数:21,代码来源:test_aws_service.py

示例13: allocate_base_volume

    def allocate_base_volume(self, tag=True):
        cloud_config = self._config.plugins[self.full_name]
        context = self._config.context

        self._volume = Volume(connection=self._connection)

        rootdev = context.base_ami.block_device_mapping[context.base_ami.root_device_name]
        volume_type = context.cloud.get('provisioner_ebs_type', cloud_config.get('provisioner_ebs_type', 'standard'))
        volume_size = context.ami.get('root_volume_size', None)
        if volume_size is None:
            volume_size = cloud_config.get('root_volume_size', None)
            if volume_size is None:
                volume_size = rootdev.size
        volume_size = int(volume_size)
        if volume_size < 1:
            raise VolumeException('root_volume_size must be a positive integer, received {}'.format(volume_size))
        if volume_size < rootdev.size:
            raise VolumeException(
                'root_volume_size ({}) must be at least as large as the root '
                'volume of the base AMI ({})'.format(volume_size, rootdev.size))
        self._volume.id = self._connection.create_volume(
            size=volume_size, zone=self._instance.placement,
            volume_type=volume_type, snapshot=rootdev.snapshot_id).id
        if not self._volume_available():
            log.critical('{0}: unavailable.')
            return False

        if tag:
            tags = {
                'purpose': cloud_config.get('tag_ami_purpose', 'amination'),
                'status': 'busy',
                'ami': context.base_ami.id,
                'ami-name': context.base_ami.name,
                'arch': context.base_ami.architecture,
            }
            self._connection.create_tags([self._volume.id], tags)
        self._volume.update()
        log.debug('Volume {0} created'.format(self._volume.id))
开发者ID:Netflix,项目名称:aminator,代码行数:38,代码来源:ec2.py

示例14: allocate_base_volume

    def allocate_base_volume(self, tag=True):
        cloud_config = self._config.plugins[self.full_name]
        context = self._config.context

        self._volume = Volume(connection=self._connection)

        rootdev = context.base_ami.block_device_mapping[context.base_ami.root_device_name]
        self._volume.id = self._connection.create_volume(size=rootdev.size, zone=self._instance.placement,
                                                         snapshot=rootdev.snapshot_id).id
        if not self._volume_available():
            log.critical('{0}: unavailable.')
            return False

        if tag:
            tags = {
                'purpose': cloud_config.get('tag_ami_purpose', 'amination'),
                'status': 'busy',
                'ami': context.base_ami.id,
                'ami-name': context.base_ami.name,
                'arch': context.base_ami.architecture,
            }
            self._connection.create_tags([self._volume.id], tags)
        self._volume.update()
        log.debug('Volume {0} created'.format(self._volume.id))
开发者ID:aminator-plugins,项目名称:eucalyptus-cloud,代码行数:24,代码来源:euca.py

示例15: test_endElement_with_name_status_and_empty_string_value_doesnt_set_status

 def test_endElement_with_name_status_and_empty_string_value_doesnt_set_status(self):
     volume = Volume()
     volume.endElement("status", "", None)
     self.assertNotEqual(volume.status, "")
开发者ID:Timus1712,项目名称:boto,代码行数:4,代码来源:test_volume.py


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