class OVH::Provisioner::Spawner
Is responsible for spawning other cells
Constants
- NAME
Public Instance Methods
get(class_name, *args, parent: nil, id: nil)
click to toggle source
Return and create on demand a given api_object or api_list
-
class_name is an api_object class name
-
args is an array of arguments used to object creation
-
parent is the requester (like a vrack asking for its tasks)
-
id is the id of the api_object (nil for api_list)
Example:
-
get('Vrack', id: 'pn-123'): Vrack.new('pn-123')
-
get('Task', parent: 'vrack/pn-12', id: '98'):
Task('98', 'vrack/pn-12')
-
get('DedicatedServer', '03'):
APIList.new
(DedicatedServer, '03')
# File lib/ovh/provisioner/spawner.rb, line 42 def get(class_name, *args, parent: nil, id: nil) cell_name = "#{parent}:#{class_name}@#{id}##{args}" cell = Actor[cell_name.to_sym] ||= create(class_name, parent, id, args) cell.init_properties cell end
Private Instance Methods
create(class_name, parent, id, args)
click to toggle source
# File lib/ovh/provisioner/spawner.rb, line 51 def create(class_name, parent, id, args) exclusive do cell_class = APIObject.const_get(class_name.to_sym) if id.nil? APIList.new(cell_class, parent, *args) else cell_class.new(id, parent, *args) end end end