Class: Scalarium::Cloud

Inherits:
Resource
  • Object
show all
Defined in:
lib/scalarium/rol.rb,
lib/scalarium/cloud.rb,
lib/scalarium/instance.rb

Defined Under Namespace

Classes: Instance, Rol

Instance Method Summary (collapse)

Methods inherited from Resource

#initialize

Methods included from Api

#get, #post

Constructor Details

This class inherits a constructor from Scalarium::Resource

Instance Method Details

- (Object) check_deploy(deploy_id)



8
9
10
# File 'lib/scalarium/cloud.rb', line 8

def check_deploy(deploy_id)
  get("clouds/#{id}/deployments/#{deploy_id}")
end

- (Object) find_instance(name_or_id)



26
27
28
# File 'lib/scalarium/cloud.rb', line 26

def find_instance(name_or_id)
  instances.find{|i| [i.name.downcase, i.nickname.downcase, i.id].include?(name_or_id.downcase)}
end

- (Object) find_instances(rol_or_instance)



30
31
32
33
34
35
36
37
# File 'lib/scalarium/cloud.rb', line 30

def find_instances(rol_or_instance)
	return instances  if rol_or_instance == "all"
	rol = find_rol(rol_or_instance)
	return rol.instances if rol
	instance = find_instance(rol_or_instance)
	return [instance] if instance
	nil
end

- (Object) find_rol(name_or_id)



46
47
48
# File 'lib/scalarium/cloud.rb', line 46

def find_rol(name_or_id)
  roles.find{|r| [r.name.downcase, r.shortname.downcase, r.id].include?(name_or_id.downcase)}
end

- (Object) instances



19
20
21
22
23
24
# File 'lib/scalarium/cloud.rb', line 19

def instances
  return @instances if @instances
  @instances = get("clouds/#{id}/instances").map{|hash|
    Instance.new(@token, self, hash)
  }
end

- (Object) roles



39
40
41
42
43
44
# File 'lib/scalarium/cloud.rb', line 39

def roles
  return @roles if @roles
  @roles = get("clouds/#{id}/roles").map{|hash|
    Rol.new(@token, self, hash)
  }
end

- (Object) run_recipe!(recipe, instances = nil)



12
13
14
15
16
17
# File 'lib/scalarium/cloud.rb', line 12

def run_recipe!(recipe, instances = nil)
  opt = {:command => "execute_recipes", :recipes => recipe}
  opt[:instances] = instances if instances

  post("clouds/#{id}/deploy", opt)
end

- (Object) update_cookbooks!



4
5
6
# File 'lib/scalarium/cloud.rb', line 4

def update_cookbooks!
  post("clouds/#{id}/deploy", :command => 'update_custom_cookbooks' )
end