Class: Fog::Openstack::Planning::Plan

Inherits:
Fog::OpenStack::Model show all
Defined in:
lib/fog/openstack/models/planning/plan.rb

Constant Summary collapse

MASTER_TEMPLATE_NAME =
'plan.yaml'
ENVIRONMENT_NAME =
'environment.yaml'

Instance Attribute Summary

Attributes inherited from Fog::OpenStack::Model

#project

Instance Method Summary collapse

Methods inherited from Fog::OpenStack::Model

#initialize, #save

Constructor Details

This class inherits a constructor from Fog::OpenStack::Model

Instance Method Details

#add_role(role_uuid) ⇒ Object



42
43
44
# File 'lib/fog/openstack/models/planning/plan.rb', line 42

def add_role(role_uuid)
  service.add_role_to_plan(uuid, role_uuid)
end

#createObject



56
57
58
59
60
# File 'lib/fog/openstack/models/planning/plan.rb', line 56

def create
  requires :name
  merge_attributes(service.create_plan(self.attributes).body)
  self
end

#destroyObject



50
51
52
53
54
# File 'lib/fog/openstack/models/planning/plan.rb', line 50

def destroy
  requires :uuid
  service.delete_plan(uuid)
  true
end

#environmentObject



28
29
30
# File 'lib/fog/openstack/models/planning/plan.rb', line 28

def environment
  templates[ENVIRONMENT_NAME]
end

#master_templateObject



24
25
26
# File 'lib/fog/openstack/models/planning/plan.rb', line 24

def master_template
  templates[MASTER_TEMPLATE_NAME]
end

#patch(parameters) ⇒ Object



38
39
40
# File 'lib/fog/openstack/models/planning/plan.rb', line 38

def patch(parameters)
  service.patch_plan(uuid, parameters[:parameters]).body
end

#provider_resource_templatesObject



32
33
34
35
36
# File 'lib/fog/openstack/models/planning/plan.rb', line 32

def provider_resource_templates
  templates.select do |key, template|
    ![MASTER_TEMPLATE_NAME, ENVIRONMENT_NAME].include?(key)
  end
end

#remove_role(role_uuid) ⇒ Object



46
47
48
# File 'lib/fog/openstack/models/planning/plan.rb', line 46

def remove_role(role_uuid)
  service.remove_role_from_plan(uuid, role_uuid)
end

#templatesObject



20
21
22
# File 'lib/fog/openstack/models/planning/plan.rb', line 20

def templates
  service.get_plan_templates(uuid).body
end

#update(parameters = nil) ⇒ Object



62
63
64
65
66
# File 'lib/fog/openstack/models/planning/plan.rb', line 62

def update(parameters=nil)
  requires :uuid
  merge_attributes(service.patch_plan(uuid, parameters).body)
  self
end