src/bosh_aws_cpi/lib/cloud/aws/cloud_v2.rb
##
# Create an EC2 instance and wait until it's in running state
# @param [String] agent_id agent id associated with new VM
# @param [String] stemcell_id AMI id of the stemcell used to
#  create the new instance
# @param [Hash] vm_type resource pool specification
# @param [Hash] network_spec network specification, if it contains
#  security groups they must already exist
# @param [optional, Array] disk_locality list of disks that
#   might be attached to this instance in the future, can be
#   used as a placement hint (i.e. instance will only be created
#   if resource pool availability zone is the same as disk
#   availability zone)
# @param [optional, Hash] environment data to be merged into
#   agent settings
# @return [Array] Contains VM ID, and Network info
Create an EC2 instance and wait until it's in running state
Create an EC2 instance and wait until it ' s in running state
def create_vm(agent_id, stemcell_id, vm_type, network_spec, disk_locality = [], environment = nil)
      raise Bosh::Clouds::CloudError, "Cannot create VM without registry with CPI v2 and stemcell api version #{@stemcell_api_version}. Registry not configured." if !@config.registry_configured? && @stemcell_api_version < 2
      with_thread_name("create_vm(#{agent_id}, ...):v2") do
        network_props = @props_factory.network_props(network_spec)
        registry, dns = nil
        registry = {endpoint: @config.registry.endpoint} if @config.registry_configured?
        network_with_dns = network_props.dns_networks.first
        dns = {nameserver: network_with_dns.dns} unless network_with_dns.nil?
        agent_settings = AgentSettings.new(registry, network_props, dns)
        agent_settings.environment = environment
        agent_settings.agent_id = agent_id
        instance_id, networks = @cloud_core.create_vm(agent_id, stemcell_id, vm_type, network_props, agent_settings, disk_locality, environment) do
        |instance_id, settings|
          @registry.update_settings(instance_id, settings.agent_settings) if @stemcell_api_version < 2
        end
        [instance_id, network_spec]
      end
    end
def create_vm ( agent_id , stemcell_id , vm_type , network_spec , disk_locality = [ ] , environment = nil ) raise Bosh :: Clouds :: CloudError , "Cannot create VM without registry with CPI v2 and stemcell api version #{@stemcell_api_version}. Registry not configured." if ! @config . registry_configured? && @stemcell_api_version < 2 with_thread_name ( "create_vm(#{agent_id}, ...):v2" ) do network_props = @props_factory . network_props ( network_spec ) registry , dns = nil registry = { endpoint : @config . registry . endpoint } if @config . registry_configured? network_with_dns = network_props . dns_networks . first dns = { nameserver : network_with_dns . dns } unless network_with_dns . nil? agent_settings = AgentSettings . new ( registry , network_props , dns ) agent_settings . environment = environment agent_settings . agent_id = agent_id instance_id , networks = @cloud_core . create_vm ( agent_id , stemcell_id , vm_type , network_props , agent_settings , disk_locality , environment ) do | instance_id , settings | @registry . update_settings ( instance_id , settings . agent_settings ) if @stemcell_api_version < 2 end [ instance_id , network_spec ] end end
Create an EC2 instance and wait until it's in running state
Create an EC2 instance and wait until it ' s in running state
#TODO : should use networks from core create_vm in future
Contains VM ID, and Network info
Contains VM ID and Network info
Array
agent_id
<not_specific>
stemcell_id
<not_specific>
vm_type
<not_specific>
network_spec
<not_specific>
disk_locality
<not_specific>
environment
<not_specific>
<not_specific>
environment data to be merged into agent settings
environment data to be merged into agent settings