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


Python JavaGateway.getVolumeIdFromName方法代码示例

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


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

示例1: EC2VolumeDriver

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import getVolumeIdFromName [as 别名]
class EC2VolumeDriver(driver.ISCSIDriver):
    ec2 = None
    VERSION = "1.0"

    def __init__(self, *args, **kwargs):
        super(EC2VolumeDriver, self).__init__(*args, **kwargs)
        self.ec2 = JavaGateway(GatewayClient(port=25535)).entry_point

    def do_setup(self, context):
        """Instantiate common class and log in storage system."""
        pass

    def check_for_setup_error(self):
        """Check configuration file."""
        pass

    def create_volume(self, volume):
        ec2_volume_id = self.ec2.createVolume(volume['id'],
                                              volume['size'])
        LOG.info("create volume: %s; arn: %s " % (volume['id'],
                                                  ec2_volume_id))
        model_update = {'provider_location': ec2_volume_id}
        return model_update

    def create_cloned_volume(self, volume, src_vref):
        """Create a clone of the specified volume."""
        pass

    def extend_volume(self, volume, new_size):
        """Extend a volume."""
        pass

    def delete_volume(self, volume):
        """Delete a volume."""
        if hasattr(volume, 'id') and volume['id']:
            ec2_volume_id = self.ec2.getVolumeIdFromName(volume['id'])
            if ec2_volume_id != 'None':
                self.ec2.deleteVolume(ec2_volume_id)
                LOG.info("deleted volume %s" % volume['id'])

    def create_snapshot(self, snapshot):
        """Create a snapshot."""
        pass

    def delete_snapshot(self, snapshot):
        """Delete a snapshot."""
        pass

    def get_volume_stats(self, refresh=False):
        """Get volume stats."""
        data = {'volume_backend_name': "EC2",
                'storage_protocol': 'LSI Logic SCSI',
                'driver_version': self.VERSION,
                'vendor_name': 'Huawei',
                'total_capacity_gb': 1000,
                'free_capacity_gb': 1000,
                'reserved_percentage': 0}
        # TODO: get from ec2
        return data

    def initialize_connection(self, volume, connector):
        """Map a volume to a host."""
        LOG.info("attach volume: %s; arn: %s " % (volume['id'],
                                                  volume['provider_location']))
        properties = {'volume_id': volume['id'],
                      'remote_id': volume['provider_location']}
        LOG.info("initialize_connection success. Return data: %s."
                 % properties)
        return {'driver_volume_type': 'ec2volume', 'data': properties}

    def terminate_connection(self, volume, connector, **kwargs):
        pass

    def create_export(self, context, volume):
        """Export the volume."""
        pass

    def ensure_export(self, context, volume):
        """Synchronously recreate an export for a volume."""
        pass

    def remove_export(self, context, volume):
        """Remove an export for a volume."""
        pass

    def create_volume_from_snapshot(self, volume, snapshot):
        """Create a volume from a snapshot."""
        snapshot_id = snapshot.get('id')
        volume_id = volume.get('id')
        ec2_volume_id = self.ec2.createVolumeFromSnapshot(snapshot_id, volume_id)
        model_update = {'provider_location': ec2_volume_id}
        return model_update

    def validate_connector(self, connector):
        """Fail if connector doesn't contain all the data needed by driver."""
        LOG.debug('ec2volume Driver: validate_connector')
        pass
开发者ID:Hybrid-Cloud,项目名称:jacket,代码行数:99,代码来源:ec2volume.py

示例2: AwsEc2Driver

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import getVolumeIdFromName [as 别名]
class AwsEc2Driver(driver.ComputeDriver):
    """The EC2 java server"""

    aws_ec2_java_server = None
    VERSION = "1.0"

    def __init__(self, virtapi, scheme="https"):
        super(AwsEc2Driver, self).__init__(virtapi)
        self.aws_ec2_java_server = JavaGateway(GatewayClient(port=25535)).entry_point
        self.network_api = network.API()
        self.volume_api = volume.API()
        self.compute_api = compute.API(network_api=self.network_api,
                                       volume_api=self.volume_api)
        # record openstack instance-uuid to EC2 instance-id
        self.instances = {}
        # TODO: configure aws backend in openstack
        '''if (
            CONF.ec2.access_key is None or
            CONF.ec2.access_secret_key is None):
            raise Exception(_("Must specify access_key, access_secret_key"
                              "to use ec2.AwsEc2Driver"))'''
    def init_host(self, host):
        pass

    def list_instances(self):
        """List VM instances from all nodes."""
        # TODO: list instances from aws
        instances = []
        return instances

    def snapshot(self, context, instance, image_id, update_task_state):
        pass

    def set_bootable(self, instance, is_bootable):
        pass

    def set_admin_password(self, instance, new_pass):
        pass

    def spawn(self, context, instance, image_meta, injected_files,
              admin_password, network_info=None, block_device_info=None):
        """Create VM instance."""
        LOG.debug(_("image meta is:%s") % image_meta)
        ec2_image_id = self.aws_ec2_java_server.getImageIdFromName(
            image_meta['id'])
        LOG.debug(_("ec2 image id is:%s") % ec2_image_id)

        LOG.debug(_("instance is:%s") % instance)
        ec2_vm_name = instance['uuid']
        launch_result = self.aws_ec2_java_server.launchInstanceFromAMI(
            ec2_image_id, ec2_vm_name)

        LOG.debug("Instance is running %s" % instance)
        LOG.debug("launch result:%s, %s" % (launch_result['public-ip'],
                                            launch_result['instance-id']))
        # save ec2 instance id into cache
        self.instances[ec2_vm_name] = launch_result['instance-id']

    def attach_volume(self, context, connection_info, instance, mountpoint,
                      disk_bus=None, device_type=None, encryption=None):
        """Attach volume storage to VM instance."""
        openstack_volume_id = connection_info['data']['volume_id']
        LOG.info("attach ec2 volume")
        ec2_instance_id = self._get_ec2_instance_id(instance['uuid'])
        ec2_volume_id = self.aws_ec2_java_server.getVolumeIdFromName(
            openstack_volume_id)
        # TODO need to change device name
        ec2_rule = "/dev/sd"
        ec2_mountpoint = ec2_rule + mountpoint[-1]
        self.aws_ec2_java_server.attachVolumeToInstance(ec2_volume_id,
                                                        ec2_instance_id,
                                                        ec2_mountpoint)

    def get_available_resource(self, nodename):
        """Retrieve resource info.

        This method is called when nova-compute launches, and
        as part of a periodic task.

        :returns: dictionary describing resources

        """
        return {'vcpus': 32,
                'memory_mb': 164403,
                'local_gb': 5585,
                'vcpus_used': 0,
                'memory_mb_used': 69005,
                'local_gb_used': 3479,
                'hypervisor_type': 'vcloud',
                'hypervisor_version': 5005000,
                'hypervisor_hostname': nodename,
                'cpu_info': '{"model": ["Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz"], \
                "vendor": ["Huawei Technologies Co., Ltd."], \
                "topology": {"cores": 16, "threads": 32}}',
                'supported_instances': jsonutils.dumps(
                    [["i686", "ec2", "hvm"], ["x86_64", "vmware", "hvm"]]),
                'numa_topology': None,
                }
        
    def get_available_nodes(self, refresh=False):
#.........这里部分代码省略.........
开发者ID:arthur-wangfeng,项目名称:basket,代码行数:103,代码来源:driver.py


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