Class: StackMate::CloudStackAutoScaleVmProfile
Constant Summary
Constants included
from Resolver
Resolver::INTEXP, Resolver::STRINGEXP, Resolver::UUIDEXP
Instance Attribute Summary
#name
Instance Method Summary
collapse
Methods included from Resolver
#get_named_tag, #get_resolved, #resolve_tags, #resolve_to_deviceid, #validate_param
Methods included from Intrinsic
#fn_base64, #fn_getatt, #fn_join, #fn_lookup, #fn_map, #fn_ref, #fn_select, #intrinsic
Methods included from Logging
configure_logger_for, #logger, logger_for
#initialize
Instance Method Details
#create ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/stackmate/participants/cloudstack_autoscalevmprofile.rb', line 9
def create
logger.debug("Creating resource #{@name}")
workitem[@name] = {}
name_cs = workitem['StackName'] + '-' + @name
args={}
begin
args['zoneid'] = get_zoneid
args['serviceofferingid'] = get_serviceofferingid
args['templateid'] = get_templateid
args['otherdeployparams'] = get_otherdeployparams if @props.has_key?('otherdeployparams')
args['destroyvmgraceperiod'] = get_destroyvmgraceperiod if @props.has_key?('destroyvmgraceperiod')
args['autoscaleuserid'] = get_autoscaleuserid if @props.has_key?('autoscaleuserid')
args['counterparam'] = get_counterparam if @props.has_key?('counterparam')
logger.info("Creating resource #{@name} with following arguments")
p args
result_obj = make_async_request('createAutoScaleVmProfile',args)
resource_obj = result_obj['AutoScaleVmProfile'.downcase]
resource_obj.each_key do |k|
val = resource_obj[k]
if('id'.eql?(k))
k = 'physical_id'
end
workitem[@name][k] = val
end
set_tags(@props['tags'],workitem[@name]['physical_id'],"AutoScaleVmProfile") if @props.has_key?('tags')
workitem['ResolvedNames'][@name] = name_cs
workitem['IdMap'][workitem[@name]['physical_id']] = @name
rescue NoMethodError => nme
logger.error("Create request failed for resource . Cleaning up the stack")
raise nme
rescue Exception => e
logger.error(e.message)
raise e
end
end
|
#delete ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/stackmate/participants/cloudstack_autoscalevmprofile.rb', line 49
def delete
logger.debug("Deleting resource #{@name}")
begin
physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
if(!physical_id.nil?)
args = {'id' => physical_id
}
result_obj = make_async_request('deleteAutoScaleVmProfile',args)
if (!(result_obj['error'] == true))
logger.info("Successfully deleted resource #{@name}")
else
logger.info("CloudStack error while deleting resource #{@name}")
end
else
logger.info("Resource not created in CloudStack. Skipping delete...")
end
rescue Exception => e
logger.error("Unable to delete resorce #{@name}")
end
end
|
#get_autoscaleuserid ⇒ Object
123
124
125
126
127
128
129
|
# File 'lib/stackmate/participants/cloudstack_autoscalevmprofile.rb', line 123
def get_autoscaleuserid
resolved_autoscaleuserid = get_resolved(@props['autoscaleuserid'],workitem)
if resolved_autoscaleuserid.nil? || !validate_param(resolved_autoscaleuserid,"uuid")
raise "Malformed optional parameter autoscaleuserid for resource #{@name}"
end
resolved_autoscaleuserid
end
|
#get_counterparam ⇒ Object
131
132
133
134
135
136
137
|
# File 'lib/stackmate/participants/cloudstack_autoscalevmprofile.rb', line 131
def get_counterparam
resolved_counterparam = get_resolved(@props['counterparam'],workitem)
if resolved_counterparam.nil? || !validate_param(resolved_counterparam,"map")
raise "Malformed optional parameter counterparam for resource #{@name}"
end
resolved_counterparam
end
|
#get_destroyvmgraceperiod ⇒ Object
115
116
117
118
119
120
121
|
# File 'lib/stackmate/participants/cloudstack_autoscalevmprofile.rb', line 115
def get_destroyvmgraceperiod
resolved_destroyvmgraceperiod = get_resolved(@props['destroyvmgraceperiod'],workitem)
if resolved_destroyvmgraceperiod.nil? || !validate_param(resolved_destroyvmgraceperiod,"integer")
raise "Malformed optional parameter destroyvmgraceperiod for resource #{@name}"
end
resolved_destroyvmgraceperiod
end
|
#get_otherdeployparams ⇒ Object
107
108
109
110
111
112
113
|
# File 'lib/stackmate/participants/cloudstack_autoscalevmprofile.rb', line 107
def get_otherdeployparams
resolved_otherdeployparams = get_resolved(@props['otherdeployparams'],workitem)
if resolved_otherdeployparams.nil? || !validate_param(resolved_otherdeployparams,"string")
raise "Malformed optional parameter otherdeployparams for resource #{@name}"
end
resolved_otherdeployparams
end
|
#get_serviceofferingid ⇒ Object
91
92
93
94
95
96
97
|
# File 'lib/stackmate/participants/cloudstack_autoscalevmprofile.rb', line 91
def get_serviceofferingid
resolved_serviceofferingid = get_resolved(@props["serviceofferingid"],workitem)
if resolved_serviceofferingid.nil? || !validate_param(resolved_serviceofferingid,"uuid")
raise "Missing mandatory parameter serviceofferingid for resource #{@name}"
end
resolved_serviceofferingid
end
|
#get_templateid ⇒ Object
99
100
101
102
103
104
105
|
# File 'lib/stackmate/participants/cloudstack_autoscalevmprofile.rb', line 99
def get_templateid
resolved_templateid = get_resolved(@props["templateid"],workitem)
if resolved_templateid.nil? || !validate_param(resolved_templateid,"uuid")
raise "Missing mandatory parameter templateid for resource #{@name}"
end
resolved_templateid
end
|
#get_zoneid ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/stackmate/participants/cloudstack_autoscalevmprofile.rb', line 83
def get_zoneid
resolved_zoneid = get_resolved(@props["zoneid"],workitem)
if resolved_zoneid.nil? || !validate_param(resolved_zoneid,"uuid")
raise "Missing mandatory parameter zoneid for resource #{@name}"
end
resolved_zoneid
end
|
#on_workitem ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/stackmate/participants/cloudstack_autoscalevmprofile.rb', line 70
def on_workitem
@name = workitem.participant_name
@props = workitem['Resources'][@name]['Properties']
@props.downcase_key
@resolved_names = workitem['ResolvedNames']
if workitem['params']['operation'] == 'create'
create
else
delete
end
reply
end
|