allomov
5/1/2014 - 3:53 PM

gce.rb

require 'yaml'
$LOAD_PATH.unshift('/home/lomov/bosh/bosh_google_cpi/lib')
require 'fog'
require 'fog/google/compute'

bosh_options = YAML.load_file('/home/lomov/bosh-workspace/deployments/microbosh-google/micro_bosh.yml')

@options = bosh_options['cloud']['properties']['google']
@compute_options = @options['compute']

compute_params = {
  :provider => 'google',
  :google_client_email => @compute_options['client_email'],
  :google_project      => @compute_options['project'],
  :google_key_location => @compute_options['client_key_path']
}


@compute = Fog::Compute.new(compute_params)


server_name  = "gce-fog-test-vm"
machine_type = 'g1-small'
zone_name    = 'us-central1-a'


server = @compute.servers.bootstrap( name: server_name,
                                     # source_image: image.name,
                                     zone_name: zone_name,
                                     machine_type: machine_type,
                                     username: 'ubuntu', 
                                     # metadata: { 'bosh-metadata' => metadata_json }, 
                                     private_key_path: @compute_options['private_key_path'],
                                     public_key_path:  @compute_options['public_key_path'])