Class: StackMate::CloudStackNetworkACL
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
48
49
50
51
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 9
def create
logger.debug("Creating resource #{@name}")
workitem[@name] = {}
name_cs = workitem['StackName'] + '-' + @name
args={}
begin
args['protocol'] = get_protocol
args['networkid'] = get_networkid if @props.has_key?('networkid')
args['endport'] = get_endport if @props.has_key?('endport')
args['action'] = get_action if @props.has_key?('action')
args['startport'] = get_startport if @props.has_key?('startport')
args['traffictype'] = get_traffictype if @props.has_key?('traffictype')
args['cidrlist'] = get_cidrlist if @props.has_key?('cidrlist')
args['icmpcode'] = get_icmpcode if @props.has_key?('icmpcode')
args['aclid'] = get_aclid if @props.has_key?('aclid')
args['number'] = get_number if @props.has_key?('number')
args['icmptype'] = get_icmptype if @props.has_key?('icmptype')
logger.info("Creating resource #{@name} with following arguments")
p args
result_obj = make_async_request('createNetworkACL',args)
resource_obj = result_obj['NetworkACL'.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'],"NetworkACL") 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 53
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('deleteNetworkACL',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_aclid ⇒ Object
151
152
153
154
155
156
157
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 151
def get_aclid
resolved_aclid = get_resolved(@props['aclid'],workitem)
if resolved_aclid.nil? || !validate_param(resolved_aclid,"uuid")
raise "Malformed optional parameter aclid for resource #{@name}"
end
resolved_aclid
end
|
#get_action ⇒ Object
111
112
113
114
115
116
117
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 111
def get_action
resolved_action = get_resolved(@props['action'],workitem)
if resolved_action.nil? || !validate_param(resolved_action,"string")
raise "Malformed optional parameter action for resource #{@name}"
end
resolved_action
end
|
#get_cidrlist ⇒ Object
135
136
137
138
139
140
141
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 135
def get_cidrlist
resolved_cidrlist = get_resolved(@props['cidrlist'],workitem)
if resolved_cidrlist.nil? || !validate_param(resolved_cidrlist,"list")
raise "Malformed optional parameter cidrlist for resource #{@name}"
end
resolved_cidrlist
end
|
#get_endport ⇒ Object
103
104
105
106
107
108
109
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 103
def get_endport
resolved_endport = get_resolved(@props['endport'],workitem)
if resolved_endport.nil? || !validate_param(resolved_endport,"integer")
raise "Malformed optional parameter endport for resource #{@name}"
end
resolved_endport
end
|
#get_icmpcode ⇒ Object
143
144
145
146
147
148
149
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 143
def get_icmpcode
resolved_icmpcode = get_resolved(@props['icmpcode'],workitem)
if resolved_icmpcode.nil? || !validate_param(resolved_icmpcode,"integer")
raise "Malformed optional parameter icmpcode for resource #{@name}"
end
resolved_icmpcode
end
|
#get_icmptype ⇒ Object
167
168
169
170
171
172
173
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 167
def get_icmptype
resolved_icmptype = get_resolved(@props['icmptype'],workitem)
if resolved_icmptype.nil? || !validate_param(resolved_icmptype,"integer")
raise "Malformed optional parameter icmptype for resource #{@name}"
end
resolved_icmptype
end
|
#get_networkid ⇒ Object
95
96
97
98
99
100
101
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 95
def get_networkid
resolved_networkid = get_resolved(@props['networkid'],workitem)
if resolved_networkid.nil? || !validate_param(resolved_networkid,"uuid")
raise "Malformed optional parameter networkid for resource #{@name}"
end
resolved_networkid
end
|
#get_number ⇒ Object
159
160
161
162
163
164
165
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 159
def get_number
resolved_number = get_resolved(@props['number'],workitem)
if resolved_number.nil? || !validate_param(resolved_number,"integer")
raise "Malformed optional parameter number for resource #{@name}"
end
resolved_number
end
|
#get_protocol ⇒ Object
87
88
89
90
91
92
93
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 87
def get_protocol
resolved_protocol = get_resolved(@props["protocol"],workitem)
if resolved_protocol.nil? || !validate_param(resolved_protocol,"string")
raise "Missing mandatory parameter protocol for resource #{@name}"
end
resolved_protocol
end
|
#get_startport ⇒ Object
119
120
121
122
123
124
125
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 119
def get_startport
resolved_startport = get_resolved(@props['startport'],workitem)
if resolved_startport.nil? || !validate_param(resolved_startport,"integer")
raise "Malformed optional parameter startport for resource #{@name}"
end
resolved_startport
end
|
#get_traffictype ⇒ Object
127
128
129
130
131
132
133
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 127
def get_traffictype
resolved_traffictype = get_resolved(@props['traffictype'],workitem)
if resolved_traffictype.nil? || !validate_param(resolved_traffictype,"string")
raise "Malformed optional parameter traffictype for resource #{@name}"
end
resolved_traffictype
end
|
#on_workitem ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/stackmate/participants/cloudstack_networkacl.rb', line 74
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
|