Class: Fog::OpenStack::Planning::Plan

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

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from Model

#project

Instance Method Summary collapse

Methods inherited from Model

#initialize, #save

Constructor Details

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

Instance Method Details

#add_role(role_uuid) ⇒ Object



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

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

#createObject



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

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

#destroyObject



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

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

#environmentObject



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

def environment
  templates[ENVIRONMENT_NAME]
end

#master_templateObject



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

def master_template
  templates[MASTER_TEMPLATE_NAME]
end

#patch(parameters) ⇒ Object



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

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

#provider_resource_templatesObject



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

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

#remove_role(role_uuid) ⇒ Object



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

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

#templatesObject



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

def templates
  service.get_plan_templates(uuid).body
end

#update(parameters = nil) ⇒ Object



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

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