Class: Pec::Builder::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/pec/builder/server.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resource(name) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/pec/builder/server.rb', line 16

def self.resource(name)
  define_method("fetch_#{name}", -> (host) {
    r = Pec.compute.send("#{name}s").find {|val|val.name == host.send(name)}
    raise "not fond #{name} #{host.send(name)}" unless r
    r
  })
end

Instance Method Details

#build(host) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/pec/builder/server.rb', line 4

def build(host)
  Pec::Logger.notice "flavor is #{host.flavor}"
  Pec::Logger.notice "image is #{host.image}"
  hash = {
    name: host.name,
    flavor_ref: fetch_flavor(host).id,
    image_ref:  fetch_image(host).id
  }
  hash[:availability_zone] = host.availability_zone if host.availability_zone
  hash
end