Skip to content

Commit

Permalink
[compute|ninefold] small consistency fixes for server
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed Jul 22, 2011
1 parent c0ca2cd commit 3e8a2f3
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions lib/fog/compute/models/ninefold/server.rb
Expand Up @@ -5,6 +5,9 @@ module Compute
class Ninefold

class Server < Fog::Model
extend Fog::Deprecation
deprecate :serviceofferingid, :flavor_id
deprecate :templateid, :image_id

identity :id

Expand All @@ -13,10 +16,11 @@ class Server < Fog::Model
attribute :cpuspeed

attribute :cpuused
attribute :created, :type => :time
attribute :created, :type => :time
attribute :displayname
attribute :domain
attribute :domainid
attribute :flavor_id, :aliases => :serviceofferingid
attribute :forvirtualnetwork
attribute :group
attribute :groupid
Expand All @@ -25,6 +29,7 @@ class Server < Fog::Model
attribute :hostid
attribute :hostname
attribute :hypervisor
attribute :image_id, :aliases => :templateid
#attribute :ipaddress
attribute :isodisplaytext
attribute :isoid
Expand All @@ -35,20 +40,18 @@ class Server < Fog::Model
attribute :name
attribute :networkkbsread
attribute :networkkbswrite
attribute :nic
attribute :password
attribute :passwordenabled
attribute :rootdeviceid
attribute :rootdevicetype
attribute :serviceofferingid
attribute :securitygroup
attribute :serviceofferingname
attribute :state
attribute :templatedisplaytext
attribute :templateid
attribute :templatename
attribute :zoneid
attribute :zonename
attribute :nic
attribute :securitygroup

# used for creation only.
attribute :networkids
Expand All @@ -66,7 +69,7 @@ class Server < Fog::Model

def initialize(attributes={})
merge_attributes({
:serviceofferingid => 105 # '1CPU, 384MB, 80GB HDD'
:flavor_id => 105 # '1CPU, 384MB, 80GB HDD'
})
super
end
Expand Down Expand Up @@ -102,13 +105,13 @@ def destroy
end

def flavor
requires :serviceofferingid
connection.flavors.get(serviceofferingid)
requires :flavor_id
connection.flavors.get(flavor_id)
end

def image
requires :templateid
connection.images.get(templateid)
requires :image_id
connection.images.get(image_id)
end

def ready?
Expand All @@ -130,9 +133,7 @@ def ready?

def save
raise "Operation not supported" if self.identity
requires :serviceofferingid
requires :templateid
requires :zoneid
requires :flavor_id, :image_id, :zoneid

unless networkids
# No network specified, use first in this zone.
Expand All @@ -146,8 +147,8 @@ def save
end

options = {
:serviceofferingid => serviceofferingid,
:templateid => templateid,
:serviceofferingid => flavor_id,
:templateid => image_id,
:name => name,
:zoneid => zoneid,
:networkids => networkids,
Expand Down

0 comments on commit 3e8a2f3

Please sign in to comment.