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

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

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Plan

Returns a new instance of Plan.



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

def initialize(attributes)
  # Old 'connection' is renamed as service and should be used instead
  prepare_service_value(attributes)
  super
end

Instance Method Details

#add_role(role_uuid) ⇒ Object



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

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

#createObject



67
68
69
70
71
# File 'lib/fog/openstack/models/planning/plan.rb', line 67

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

#destroyObject



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

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

#environmentObject



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

def environment
  templates[ENVIRONMENT_NAME]
end

#master_templateObject



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

def master_template
  templates[MASTER_TEMPLATE_NAME]
end

#patch(parameters) ⇒ Object



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

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

#provider_resource_templatesObject



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

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

#remove_role(role_uuid) ⇒ Object



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

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

#saveObject



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

def save
  requires :name
  identity ? update : create
end

#templatesObject



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

def templates
  service.get_plan_templates(uuid).body
end

#update(parameters = nil) ⇒ Object



73
74
75
76
77
# File 'lib/fog/openstack/models/planning/plan.rb', line 73

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