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

#id, #initialize

Methods included from Api

#get, #post

Constructor Details

This class inherits a constructor from Scalarium::Resource

Instance Method Details

#check_deploy(deploy_id) ⇒ Object



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

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

#find_instance(name_or_id) ⇒ Object



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

#find_instances(rol_or_instance) ⇒ Object



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

#find_rol(name_or_id) ⇒ Object



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

#instancesObject



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

#rolesObject



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

#run_recipe!(recipe, instances = nil) ⇒ Object



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

#update_cookbooks!Object



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

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