Class: Fog::Compute::Serverlove::Server

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/serverlove/models/compute/server.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultsObject



59
60
61
62
63
64
65
66
# File 'lib/fog/serverlove/models/compute/server.rb', line 59

def self.defaults
  # TODO: Document default settings.
  # Note that VNC password standards are strict (need explaining)
  { 'nic:0:model' => 'e1000', 'nic:0:dhcp' => 'auto',
    'smp' => 'auto', 'vnc' => 'auto',
    'vnc:password' => Fog::Compute::Serverlove::PasswordGenerator.generate
  }
end

Instance Method Details

#allowed_attributesObject



49
50
51
52
53
54
55
56
57
# File 'lib/fog/serverlove/models/compute/server.rb', line 49

def allowed_attributes
  allowed = [
              :name, :cpu, :smp, :mem, :persistent,
              :vnc_password, :vnc,
              :ide_0_0, :ide_0_1, :ide_1_0, :ide_1_1,
              :boot, :nic_0_model, :nic_0_dhcp
            ]
  attributes.select {|k,v| allowed.include? k}
end

#destroyObject



43
44
45
46
47
# File 'lib/fog/serverlove/models/compute/server.rb', line 43

def destroy
  requires :identity
  service.destroy_server(identity)
  self
end

#saveObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/serverlove/models/compute/server.rb', line 28

def save
  attributes = {}

  if(identity)
    attributes = service.update_server(identity, allowed_attributes).body
  else
    requires :name
    requires :cpu
    attributes = service.create_server(self.class.defaults.merge(allowed_attributes)).body
  end

  merge_attributes(attributes)
  self
end