Class: Ironfan::Provider::Static::Machine

Inherits:
IaasProvider::Machine show all
Defined in:
lib/ironfan/headers.rb,
lib/ironfan/provider/static/machine.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IaasProvider::Machine

cloud_init_user_data

Class Method Details

.block_device_mapping(computer) ⇒ Object

An array of hashes with dorky-looking keys, just like Fog wants it.


173
174
175
# File 'lib/ironfan/provider/static/machine.rb', line 173

def self.block_device_mapping(computer)
  []
end

.create!(computer) ⇒ Object

Manipulation


154
155
156
# File 'lib/ironfan/provider/static/machine.rb', line 154

def self.create!(computer)
  nil
end

.destroy!(computer) ⇒ Object


177
178
179
180
181
182
# File 'lib/ironfan/provider/static/machine.rb', line 177

def self.destroy!(computer)
  return unless computer.machine?
  forget computer.machine.name
  computer.machine.destroy
  computer.machine.reload            # show the node as shutting down
end

.expected_ids(computer) ⇒ Object


9
# File 'lib/ironfan/provider/static/machine.rb', line 9

def self.expected_ids(computer) [computer.server.full_name];   end

.launch_description(computer) ⇒ Object


168
169
170
# File 'lib/ironfan/provider/static/machine.rb', line 168

def self.launch_description(computer)
  nil
end

.lint(computer) ⇒ Object


159
160
161
162
163
164
165
166
# File 'lib/ironfan/provider/static/machine.rb', line 159

def self.lint(computer)
  cloud = computer.server.cloud(:static)
  info  = [computer.name, cloud.inspect]
  errors = {}
  server_errors = computer.server.lint
  errors["No Private IP"]       = info if cloud.private_ip.blank?
  errors
end

.load!(cluster = nil) ⇒ Object

Discovery


124
125
126
127
128
129
130
131
# File 'lib/ironfan/provider/static/machine.rb', line 124

def self.load!(cluster=nil)
  cluster.facets.each do |facet| 
    facet.servers.each do |server|
      machine = new(:adaptee => server)
      remember machine
    end
  end
end

.multiple?Boolean

Returns:

  • (Boolean)

7
# File 'lib/ironfan/provider/static/machine.rb', line 7

def self.multiple?()    false;  end

.resource_typeObject


8
# File 'lib/ironfan/provider/static/machine.rb', line 8

def self.resource_type()        :machine;   end

.save!(computer) ⇒ Object


184
185
186
187
188
# File 'lib/ironfan/provider/static/machine.rb', line 184

def self.save!(computer)
  return unless computer.machine?
  return unless computer.created?
  nil
end

.shared?Boolean

Returns:

  • (Boolean)

6
# File 'lib/ironfan/provider/static/machine.rb', line 6

def self.shared?()      false;  end

.validate_resources!(computers) ⇒ Object

Find active machines that haven't matched, but should have,

make sure all bogus machines have a computer to attach to
for display purposes

136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/ironfan/provider/static/machine.rb', line 136

def self.validate_resources!(computers)
  recall.each_value do |machine|
    next unless machine.users.empty? and machine.name
    if machine.name.match("^#{computers.cluster.name}-")
      machine.bogus << :unexpected_machine
    end
    next unless machine.bogus?
    fake           = Ironfan::Broker::Computer.new
    fake[:machine] = machine
    fake.name      = machine.name
    machine.users << fake
    computers     << fake
  end
end

Instance Method Details

#availability_zoneObject


109
110
111
# File 'lib/ironfan/provider/static/machine.rb', line 109

def availability_zone
  'none'
end

#created?Boolean

Returns:

  • (Boolean)

45
46
47
# File 'lib/ironfan/provider/static/machine.rb', line 45

def created?
  false
end

#created_atObject


21
22
23
# File 'lib/ironfan/provider/static/machine.rb', line 21

def created_at
  nil
end

#destroyObject


113
114
# File 'lib/ironfan/provider/static/machine.rb', line 113

def destroy
end

#dns_nameObject


41
# File 'lib/ironfan/provider/static/machine.rb', line 41

def dns_name            ; public_ip_address ; end

#error?Boolean

Returns:

  • (Boolean)

62
63
64
# File 'lib/ironfan/provider/static/machine.rb', line 62

def error?
  false
end

#flavor_idObject


25
26
27
# File 'lib/ironfan/provider/static/machine.rb', line 25

def flavor_id
  return nil
end

#flavor_nameObject


29
30
31
# File 'lib/ironfan/provider/static/machine.rb', line 29

def flavor_name
  "nil"
end

#groupsObject


37
# File 'lib/ironfan/provider/static/machine.rb', line 37

def groups           ; []   ;   end

#image_idObject


33
34
35
# File 'lib/ironfan/provider/static/machine.rb', line 33

def image_id
  "none"
end

#key_nameObject


101
102
103
# File 'lib/ironfan/provider/static/machine.rb', line 101

def key_name
  keypair
end

#keypairObject


43
# File 'lib/ironfan/provider/static/machine.rb', line 43

def keypair          ; adaptee.cloud(:static).keypair ; end

#nameObject


11
# File 'lib/ironfan/provider/static/machine.rb', line 11

def name()  adaptee.full_name; end

#pending?Boolean

Returns:

  • (Boolean)

48
49
50
# File 'lib/ironfan/provider/static/machine.rb', line 48

def pending?
  false
end

#perform_after_launch_tasks?Boolean

Returns:

  • (Boolean)

72
73
74
# File 'lib/ironfan/provider/static/machine.rb', line 72

def perform_after_launch_tasks?
  true
end

#private_ip_addressObject


105
106
107
# File 'lib/ironfan/provider/static/machine.rb', line 105

def private_ip_address
  adaptee.cloud(:static).private_ip
end

#public_hostnameObject


39
# File 'lib/ironfan/provider/static/machine.rb', line 39

def public_hostname    ; adaptee.cloud(:static).public_hostname || public_ip_address ; end

#public_ip_addressObject


40
# File 'lib/ironfan/provider/static/machine.rb', line 40

def public_ip_address  ; adaptee.cloud(:static).public_ip || private_ip_address ; end

#running?Boolean

Returns:

  • (Boolean)

51
52
53
# File 'lib/ironfan/provider/static/machine.rb', line 51

def running?
  true
end

#ssh_keyObject


97
98
99
# File 'lib/ironfan/provider/static/machine.rb', line 97

def ssh_key
  keypair = cloud.keypair || computer.server.cluster_name
end

#startObject


66
67
# File 'lib/ironfan/provider/static/machine.rb', line 66

def start
end

#stopObject


69
70
# File 'lib/ironfan/provider/static/machine.rb', line 69

def stop
end

#stopped?Boolean

Returns:

  • (Boolean)

58
59
60
# File 'lib/ironfan/provider/static/machine.rb', line 58

def stopped?
  false
end

#stopping?Boolean

Returns:

  • (Boolean)

54
55
56
# File 'lib/ironfan/provider/static/machine.rb', line 54

def stopping?
  false
end

#tagsObject


12
13
14
15
# File 'lib/ironfan/provider/static/machine.rb', line 12

def tags
  t = {"Name" => @adaptee.name}
  return t.keys.inject({}) {|h,k| h[k]=t[k]; h[k.to_sym]=t[k]; h}
end

#to_display(style, values = {}) ⇒ Object


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/ironfan/provider/static/machine.rb', line 76

def to_display(style,values={})
  # style == :minimal
  values["State"] =             "???"
  values["MachineID"] =         private_ip_address
  values["Public IP"] =         private_ip_address
  values["Private IP"] =        public_ip_address
  values["Created On"] =        "???"
  return values if style == :minimal

  # style == :default
  values["Flavor"] =            nil
  values["AZ"] =                nil
  return values if style == :default

  # style == :expanded
  values["Image"] =             "none"
  #values["Volumes"] =           volumes.map(&:id).join(', ')
  values["SSH Key"] =           "none"
  values
end

#to_sObject


116
117
118
119
# File 'lib/ironfan/provider/static/machine.rb', line 116

def to_s
  "<%-15s %-12s %-25s %-25s %-15s %-15s %-12s %-12s %s:%s>" % [
    self.class.handle, "", created_at, name, private_ip_address, public_ip_address, flavor_name, availability_zone, key_name, groups.join(',') ]
end

#vpc_idObject


17
18
19
# File 'lib/ironfan/provider/static/machine.rb', line 17

def vpc_id
  return nil
end