def __init__(self, virtapi, read_only=False):
super(EC2Driver, self).__init__(virtapi)
self.host_status_base = {
'vcpus': CONF.AWS.max_vcpus,
'memory_mb': CONF.AWS.max_memory_mb,
'local_gb': CONF.AWS.max_disk_gb,
'vcpus_used': 0,
'memory_mb_used': 0,
'local_gb_used': 0,
'hypervisor_type': 'EC2',
'hypervisor_version': '1.0',
'hypervisor_hostname': CONF.host,
'cpu_info': {},
'disk_available_least': CONF.AWS.max_disk_gb,
}
global _EC2_NODES
self._mounts = {}
self._interfaces = {}
self._uuid_to_ec2_instance = {}
self.ec2_flavor_info = EC2_FLAVOR_MAP
aws_region = CONF.AWS.region_name
aws_endpoint = "ec2." + aws_region + ".amazonaws.com"
region = RegionInfo(name=aws_region, endpoint=aws_endpoint)
self.ec2_conn = ec2.EC2Connection(
aws_access_key_id=CONF.AWS.access_key,
aws_secret_access_key=CONF.AWS.secret_key,
region=region)
self.cloudwatch_conn = cloudwatch.connect_to_region(
aws_region, aws_access_key_id=CONF.AWS.access_key,
aws_secret_access_key=CONF.AWS.secret_key)
# Allow keypair deletion to be controlled by conf
if CONF.AWS.enable_keypair_notifications:
eventlet.spawn(KeyPairNotifications(self.ec2_conn).run)
LOG.info("EC2 driver init with %s region" % aws_region)
if _EC2_NODES is None:
set_nodes([CONF.host])
评论列表
文章目录