本文整理汇总了Python中py4j.java_gateway.JavaGateway.getInstanceIdFromName方法的典型用法代码示例。如果您正苦于以下问题:Python JavaGateway.getInstanceIdFromName方法的具体用法?Python JavaGateway.getInstanceIdFromName怎么用?Python JavaGateway.getInstanceIdFromName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类py4j.java_gateway.JavaGateway
的用法示例。
在下文中一共展示了JavaGateway.getInstanceIdFromName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AwsEc2Driver
# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import getInstanceIdFromName [as 别名]
#.........这里部分代码省略.........
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):
"""Returns nodenames of all nodes managed by the compute service.
This method is for multi compute-nodes support. If a driver supports
multi compute-nodes, this method returns a list of nodenames managed
by the service. Otherwise, this method should return
[hypervisor_hostname].
"""
return "aws-ec2-hypervisor"
def get_info(self, instance):
ec2_instance_id = self._get_ec2_instance_id(instance['uuid'])
if ec2_instance_id == 'None':
return {'state': power_state.NOSTATE,
'max_mem': 0,
'mem': 0,
'num_cpu': 1,
'cpu_time': 0}
ec2_instance_state = self.aws_ec2_java_server.\
getInstanceStatus(ec2_instance_id)
if ec2_instance_state == 'None':
return {'state': power_state.NOSTATE,
'max_mem': 0,
'mem': 0,
'num_cpu': 1,
'cpu_time': 0}
elif ec2_instance_state == 'running':
return {'state': power_state.RUNNING,
'max_mem': 0,
'mem': 0,
'num_cpu': 1,
'cpu_time': 0}
# TODO: mapping ec2 state to openstack state
else:
return {'state': power_state.RUNNING,
'max_mem': 0,
'mem': 0,
'num_cpu': 1,
'cpu_time': 0}
def destroy(self, context, instance, network_info, block_device_info=None,
destroy_disks=True, migrate_data=None):
"""Destroy VM instance."""
# TODO: handle destroy_disks flag later
ec2_instance_id = self._get_ec2_instance_id(instance['uuid'])
self.aws_ec2_java_server.deleteInstance(ec2_instance_id)
def _get_ec2_instance_id(self, instance_uuid):
"""map openstack instance_uuid to ec2 instance id"""
if instance_uuid not in self.instances.keys():
ec2_instance_id = self.aws_ec2_java_server.getInstanceIdFromName(
instance_uuid)
self.instances[instance_uuid] = ec2_instance_id
else:
ec2_instance_id = self.instances[instance_uuid]
return ec2_instance_id
def get_volume_connector(self, instance):
pass