mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Updating create server behaviour and defaults
This commit is contained in:
parent
070de176a7
commit
bca4826bfe
3 changed files with 10 additions and 17 deletions
|
@ -74,10 +74,6 @@ module Fog
|
||||||
@api_url = base_url + api_version + '/projects/'
|
@api_url = base_url + api_version + '/projects/'
|
||||||
@client = ::Google::APIClient.new
|
@client = ::Google::APIClient.new
|
||||||
@compute = @client.discovered_api('compute', api_version)
|
@compute = @client.discovered_api('compute', api_version)
|
||||||
|
|
||||||
@default_image = 'ubuntu-12-04-v20120912'
|
|
||||||
@default_zone = 'us-east1-a'
|
|
||||||
@default_machine = 'n1-standard-1'
|
|
||||||
@default_network = 'default'
|
@default_network = 'default'
|
||||||
|
|
||||||
auth_util = CommandLineOAuthHelper.new(api_scope_url)
|
auth_util = CommandLineOAuthHelper.new(api_scope_url)
|
||||||
|
|
|
@ -6,8 +6,7 @@ module Fog
|
||||||
|
|
||||||
class Server < Fog::Model
|
class Server < Fog::Model
|
||||||
|
|
||||||
identity :name
|
attribute :name
|
||||||
|
|
||||||
attribute :image_name, :aliases => 'image'
|
attribute :image_name, :aliases => 'image'
|
||||||
attribute :network_interfaces, :aliases => 'networkInterfaces'
|
attribute :network_interfaces, :aliases => 'networkInterfaces'
|
||||||
attribute :state, :aliases => 'status'
|
attribute :state, :aliases => 'status'
|
||||||
|
@ -15,8 +14,8 @@ module Fog
|
||||||
attribute :machine_type, :aliases => 'machineType'
|
attribute :machine_type, :aliases => 'machineType'
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :identity
|
requires :name
|
||||||
connection.delete_server(identity)
|
connection.delete_server(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def image
|
def image
|
||||||
|
@ -36,14 +35,13 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def save
|
def save
|
||||||
requires :identity
|
requires :name
|
||||||
requires :image_name
|
requires :image_name
|
||||||
requires :zone_name
|
|
||||||
requires :machine_type
|
requires :machine_type
|
||||||
|
requires :zone_name
|
||||||
|
|
||||||
data = connection.insert_server(identity, image_name=image_name,
|
data = connection.insert_server(name, image_name, zone_name,
|
||||||
zone_name=zone_name,
|
machine_type)
|
||||||
machine_type=machine_type)
|
|
||||||
connection.servers.merge_attributes()
|
connection.servers.merge_attributes()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,10 @@ module Fog
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
def insert_server(server_name,
|
def insert_server(server_name, image_name,
|
||||||
image_name=@default_image,
|
zone_name, machine_name,
|
||||||
zone_name=@default_zone,
|
|
||||||
machine_name=@default_machine,
|
|
||||||
network_name=@default_network)
|
network_name=@default_network)
|
||||||
|
|
||||||
api_method = @compute.instances.insert
|
api_method = @compute.instances.insert
|
||||||
parameters = {
|
parameters = {
|
||||||
'project' => @project,
|
'project' => @project,
|
||||||
|
|
Loading…
Add table
Reference in a new issue