Class: StackMate::CloudStackLBHealthCheckPolicy
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_lbhealthcheckpolicy.rb', line 9
def create
logger.debug("Creating resource #{@name}")
workitem[@name] = {}
name_cs = workitem['StackName'] + '-' + @name
args={}
begin
args['lbruleid'] = get_lbruleid
args['responsetimeout'] = get_responsetimeout if @props.has_key?('responsetimeout')
args['unhealthythreshold'] = get_unhealthythreshold if @props.has_key?('unhealthythreshold')
args['pingpath'] = get_pingpath if @props.has_key?('pingpath')
args['description'] = get_description if @props.has_key?('description')
args['intervaltime'] = get_intervaltime if @props.has_key?('intervaltime')
args['healthythreshold'] = get_healthythreshold if @props.has_key?('healthythreshold')
logger.info("Creating resource #{@name} with following arguments")
p args
result_obj = make_async_request('createLBHealthCheckPolicy',args)
resource_obj = result_obj['LBHealthCheckPolicy'.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'],"LBHealthCheckPolicy") 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_lbhealthcheckpolicy.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('deleteLBHealthCheckPolicy',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_description ⇒ Object
115
116
117
118
119
120
121
|
# File 'lib/stackmate/participants/cloudstack_lbhealthcheckpolicy.rb', line 115
def get_description
resolved_description = get_resolved(@props['description'],workitem)
if resolved_description.nil? || !validate_param(resolved_description,"string")
raise "Malformed optional parameter description for resource #{@name}"
end
resolved_description
end
|
#get_healthythreshold ⇒ Object
131
132
133
134
135
136
137
|
# File 'lib/stackmate/participants/cloudstack_lbhealthcheckpolicy.rb', line 131
def get_healthythreshold
resolved_healthythreshold = get_resolved(@props['healthythreshold'],workitem)
if resolved_healthythreshold.nil? || !validate_param(resolved_healthythreshold,"integer")
raise "Malformed optional parameter healthythreshold for resource #{@name}"
end
resolved_healthythreshold
end
|
#get_intervaltime ⇒ Object
123
124
125
126
127
128
129
|
# File 'lib/stackmate/participants/cloudstack_lbhealthcheckpolicy.rb', line 123
def get_intervaltime
resolved_intervaltime = get_resolved(@props['intervaltime'],workitem)
if resolved_intervaltime.nil? || !validate_param(resolved_intervaltime,"integer")
raise "Malformed optional parameter intervaltime for resource #{@name}"
end
resolved_intervaltime
end
|
#get_lbruleid ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/stackmate/participants/cloudstack_lbhealthcheckpolicy.rb', line 83
def get_lbruleid
resolved_lbruleid = get_resolved(@props["lbruleid"],workitem)
if resolved_lbruleid.nil? || !validate_param(resolved_lbruleid,"uuid")
raise "Missing mandatory parameter lbruleid for resource #{@name}"
end
resolved_lbruleid
end
|
#get_pingpath ⇒ Object
107
108
109
110
111
112
113
|
# File 'lib/stackmate/participants/cloudstack_lbhealthcheckpolicy.rb', line 107
def get_pingpath
resolved_pingpath = get_resolved(@props['pingpath'],workitem)
if resolved_pingpath.nil? || !validate_param(resolved_pingpath,"string")
raise "Malformed optional parameter pingpath for resource #{@name}"
end
resolved_pingpath
end
|
#get_responsetimeout ⇒ Object
91
92
93
94
95
96
97
|
# File 'lib/stackmate/participants/cloudstack_lbhealthcheckpolicy.rb', line 91
def get_responsetimeout
resolved_responsetimeout = get_resolved(@props['responsetimeout'],workitem)
if resolved_responsetimeout.nil? || !validate_param(resolved_responsetimeout,"integer")
raise "Malformed optional parameter responsetimeout for resource #{@name}"
end
resolved_responsetimeout
end
|
#get_unhealthythreshold ⇒ Object
99
100
101
102
103
104
105
|
# File 'lib/stackmate/participants/cloudstack_lbhealthcheckpolicy.rb', line 99
def get_unhealthythreshold
resolved_unhealthythreshold = get_resolved(@props['unhealthythreshold'],workitem)
if resolved_unhealthythreshold.nil? || !validate_param(resolved_unhealthythreshold,"integer")
raise "Malformed optional parameter unhealthythreshold for resource #{@name}"
end
resolved_unhealthythreshold
end
|
#on_workitem ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/stackmate/participants/cloudstack_lbhealthcheckpolicy.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
|