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/'
|
||||
@client = ::Google::APIClient.new
|
||||
@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'
|
||||
|
||||
auth_util = CommandLineOAuthHelper.new(api_scope_url)
|
||||
|
|
|
@ -6,8 +6,7 @@ module Fog
|
|||
|
||||
class Server < Fog::Model
|
||||
|
||||
identity :name
|
||||
|
||||
attribute :name
|
||||
attribute :image_name, :aliases => 'image'
|
||||
attribute :network_interfaces, :aliases => 'networkInterfaces'
|
||||
attribute :state, :aliases => 'status'
|
||||
|
@ -15,8 +14,8 @@ module Fog
|
|||
attribute :machine_type, :aliases => 'machineType'
|
||||
|
||||
def destroy
|
||||
requires :identity
|
||||
connection.delete_server(identity)
|
||||
requires :name
|
||||
connection.delete_server(name)
|
||||
end
|
||||
|
||||
def image
|
||||
|
@ -36,14 +35,13 @@ module Fog
|
|||
end
|
||||
|
||||
def save
|
||||
requires :identity
|
||||
requires :name
|
||||
requires :image_name
|
||||
requires :zone_name
|
||||
requires :machine_type
|
||||
requires :zone_name
|
||||
|
||||
data = connection.insert_server(identity, image_name=image_name,
|
||||
zone_name=zone_name,
|
||||
machine_type=machine_type)
|
||||
data = connection.insert_server(name, image_name, zone_name,
|
||||
machine_type)
|
||||
connection.servers.merge_attributes()
|
||||
end
|
||||
|
||||
|
|
|
@ -12,11 +12,10 @@ module Fog
|
|||
|
||||
class Real
|
||||
|
||||
def insert_server(server_name,
|
||||
image_name=@default_image,
|
||||
zone_name=@default_zone,
|
||||
machine_name=@default_machine,
|
||||
def insert_server(server_name, image_name,
|
||||
zone_name, machine_name,
|
||||
network_name=@default_network)
|
||||
|
||||
api_method = @compute.instances.insert
|
||||
parameters = {
|
||||
'project' => @project,
|
||||
|
|
Loading…
Add table
Reference in a new issue