stackmate 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.txt +7 -0
- data/README.md +25 -8
- data/bin/stackmate.rb +57 -53
- data/lib/stackmate/aws_attribs.rb +31 -31
- data/lib/stackmate/classmap.rb +33 -25
- data/lib/stackmate/client.rb +80 -0
- data/lib/stackmate/intrinsic_functions.rb +94 -38
- data/lib/stackmate/logging.rb +19 -19
- data/lib/stackmate/participants/cloudstack.rb +250 -165
- data/lib/stackmate/participants/cloudstack_affinitygroup.rb +122 -0
- data/lib/stackmate/participants/cloudstack_autoscalepolicy.rb +113 -0
- data/lib/stackmate/participants/cloudstack_autoscalevmgroup.rb +86 -0
- data/lib/stackmate/participants/cloudstack_autoscalevmprofile.rb +140 -0
- data/lib/stackmate/participants/cloudstack_condition.rb +122 -0
- data/lib/stackmate/participants/cloudstack_egressfirewallrule.rb +149 -0
- data/lib/stackmate/participants/cloudstack_firewallrule.rb +149 -0
- data/lib/stackmate/participants/cloudstack_globalloadbalancerrule.rb +158 -0
- data/lib/stackmate/participants/cloudstack_instancegroup.rb +113 -0
- data/lib/stackmate/participants/cloudstack_ipaddress.rb +149 -0
- data/lib/stackmate/participants/cloudstack_ipforwardingrule.rb +131 -0
- data/lib/stackmate/participants/cloudstack_iptonic.rb +95 -0
- data/lib/stackmate/participants/cloudstack_iso.rb +95 -0
- data/lib/stackmate/participants/cloudstack_lbhealthcheckpolicy.rb +140 -0
- data/lib/stackmate/participants/cloudstack_lbstickinesspolicy.rb +122 -0
- data/lib/stackmate/participants/cloudstack_loadbalancer.rb +158 -0
- data/lib/stackmate/participants/cloudstack_loadbalancerrule.rb +185 -0
- data/lib/stackmate/participants/cloudstack_network.rb +293 -0
- data/lib/stackmate/participants/cloudstack_networkacl.rb +176 -0
- data/lib/stackmate/participants/cloudstack_networkacllist.rb +104 -0
- data/lib/stackmate/participants/cloudstack_nictovirtualmachine.rb +104 -0
- data/lib/stackmate/participants/cloudstack_portforwardingrule.rb +176 -0
- data/lib/stackmate/participants/cloudstack_project.rb +113 -0
- data/lib/stackmate/participants/cloudstack_remoteaccessvpn.rb +122 -0
- data/lib/stackmate/participants/cloudstack_securitygroup.rb +122 -0
- data/lib/stackmate/participants/cloudstack_securitygroupegress.rb +185 -0
- data/lib/stackmate/participants/cloudstack_securitygroupingress.rb +185 -0
- data/lib/stackmate/participants/cloudstack_snapshot.rb +113 -0
- data/lib/stackmate/participants/cloudstack_snapshotpolicy.rb +122 -0
- data/lib/stackmate/participants/cloudstack_sshkeypair.rb +113 -0
- data/lib/stackmate/participants/cloudstack_staticnat.rb +113 -0
- data/lib/stackmate/participants/cloudstack_staticroute.rb +95 -0
- data/lib/stackmate/participants/cloudstack_tags.rb +113 -0
- data/lib/stackmate/participants/cloudstack_template.rb +212 -0
- data/lib/stackmate/participants/cloudstack_togloballoadbalancerrule.rb +104 -0
- data/lib/stackmate/participants/cloudstack_toloadbalancerrule.rb +95 -0
- data/lib/stackmate/participants/cloudstack_virtualmachine.rb +348 -0
- data/lib/stackmate/participants/cloudstack_virtualmachineops.rb +95 -0
- data/lib/stackmate/participants/cloudstack_vmsnapshot.rb +113 -0
- data/lib/stackmate/participants/cloudstack_volume.rb +176 -0
- data/lib/stackmate/participants/cloudstack_volumeops.rb +111 -0
- data/lib/stackmate/participants/cloudstack_vpc.rb +158 -0
- data/lib/stackmate/participants/cloudstack_vpnconnection.rb +95 -0
- data/lib/stackmate/participants/cloudstack_vpncustomergateway.rb +176 -0
- data/lib/stackmate/participants/cloudstack_vpngateway.rb +86 -0
- data/lib/stackmate/participants/cloudstack_vpnuser.rb +122 -0
- data/lib/stackmate/participants/common.rb +219 -70
- data/lib/stackmate/participants/stacknest.rb +6 -0
- data/lib/stackmate/resolver.rb +122 -0
- data/lib/stackmate/stack.rb +116 -60
- data/lib/stackmate/stack_executor.rb +99 -37
- data/lib/stackmate/stackpi.rb +46 -0
- data/lib/stackmate/version.rb +1 -1
- data/lib/stackmate/waitcondition_server.rb +15 -15
- data/lib/stackmate.rb +1 -1
- data/stackmate.gemspec +2 -4
- metadata +70 -19
@@ -0,0 +1,158 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackLoadBalancer < CloudStackResource
|
5
|
+
|
6
|
+
include Logging
|
7
|
+
include Intrinsic
|
8
|
+
include Resolver
|
9
|
+
def create
|
10
|
+
logger.debug("Creating resource #{@name}")
|
11
|
+
workitem[@name] = {}
|
12
|
+
name_cs = workitem['StackName'] + '-' + @name
|
13
|
+
args={}
|
14
|
+
begin
|
15
|
+
args['sourceport'] = get_sourceport
|
16
|
+
args['scheme'] = get_scheme
|
17
|
+
args['algorithm'] = get_algorithm
|
18
|
+
args['networkid'] = get_networkid
|
19
|
+
args['sourceipaddressnetworkid'] = get_sourceipaddressnetworkid
|
20
|
+
args['name'] = workitem['StackName'] +'-' +get_name
|
21
|
+
args['instanceport'] = get_instanceport
|
22
|
+
args['description'] = get_description if @props.has_key?('description')
|
23
|
+
args['sourceipaddress'] = get_sourceipaddress if @props.has_key?('sourceipaddress')
|
24
|
+
|
25
|
+
logger.info("Creating resource #{@name} with following arguments")
|
26
|
+
p args
|
27
|
+
result_obj = make_async_request('createLoadBalancer',args)
|
28
|
+
resource_obj = result_obj['LoadBalancer'.downcase]
|
29
|
+
#doing it this way since it is easier to change later, rather than cloning whole object
|
30
|
+
resource_obj.each_key do |k|
|
31
|
+
val = resource_obj[k]
|
32
|
+
if('id'.eql?(k))
|
33
|
+
k = 'physical_id'
|
34
|
+
end
|
35
|
+
workitem[@name][k] = val
|
36
|
+
end
|
37
|
+
set_tags(@props['tags'],workitem[@name]['physical_id'],"LoadBalancer") if @props.has_key?('tags')
|
38
|
+
workitem['ResolvedNames'][@name] = name_cs
|
39
|
+
workitem['IdMap'][workitem[@name]['physical_id']] = @name
|
40
|
+
|
41
|
+
rescue NoMethodError => nme
|
42
|
+
logger.error("Create request failed for resource . Cleaning up the stack")
|
43
|
+
raise nme
|
44
|
+
rescue Exception => e
|
45
|
+
logger.error(e.message)
|
46
|
+
raise e
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
def delete
|
52
|
+
logger.debug("Deleting resource #{@name}")
|
53
|
+
begin
|
54
|
+
physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
|
55
|
+
if(!physical_id.nil?)
|
56
|
+
args = {'id' => physical_id
|
57
|
+
}
|
58
|
+
result_obj = make_async_request('deleteLoadBalancer',args)
|
59
|
+
if (!(result_obj['error'] == true))
|
60
|
+
logger.info("Successfully deleted resource #{@name}")
|
61
|
+
else
|
62
|
+
logger.info("CloudStack error while deleting resource #{@name}")
|
63
|
+
end
|
64
|
+
else
|
65
|
+
logger.info("Resource not created in CloudStack. Skipping delete...")
|
66
|
+
end
|
67
|
+
rescue Exception => e
|
68
|
+
logger.error("Unable to delete resorce #{@name}")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def on_workitem
|
73
|
+
@name = workitem.participant_name
|
74
|
+
@props = workitem['Resources'][@name]['Properties']
|
75
|
+
@props.downcase_key
|
76
|
+
@resolved_names = workitem['ResolvedNames']
|
77
|
+
if workitem['params']['operation'] == 'create'
|
78
|
+
create
|
79
|
+
else
|
80
|
+
delete
|
81
|
+
end
|
82
|
+
reply
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_sourceport
|
86
|
+
resolved_sourceport = get_resolved(@props["sourceport"],workitem)
|
87
|
+
if resolved_sourceport.nil? || !validate_param(resolved_sourceport,"integer")
|
88
|
+
raise "Missing mandatory parameter sourceport for resource #{@name}"
|
89
|
+
end
|
90
|
+
resolved_sourceport
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_scheme
|
94
|
+
resolved_scheme = get_resolved(@props["scheme"],workitem)
|
95
|
+
if resolved_scheme.nil? || !validate_param(resolved_scheme,"string")
|
96
|
+
raise "Missing mandatory parameter scheme for resource #{@name}"
|
97
|
+
end
|
98
|
+
resolved_scheme
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_algorithm
|
102
|
+
resolved_algorithm = get_resolved(@props["algorithm"],workitem)
|
103
|
+
if resolved_algorithm.nil? || !validate_param(resolved_algorithm,"string")
|
104
|
+
raise "Missing mandatory parameter algorithm for resource #{@name}"
|
105
|
+
end
|
106
|
+
resolved_algorithm
|
107
|
+
end
|
108
|
+
|
109
|
+
def get_networkid
|
110
|
+
resolved_networkid = get_resolved(@props["networkid"],workitem)
|
111
|
+
if resolved_networkid.nil? || !validate_param(resolved_networkid,"uuid")
|
112
|
+
raise "Missing mandatory parameter networkid for resource #{@name}"
|
113
|
+
end
|
114
|
+
resolved_networkid
|
115
|
+
end
|
116
|
+
|
117
|
+
def get_sourceipaddressnetworkid
|
118
|
+
resolved_sourceipaddressnetworkid = get_resolved(@props["sourceipaddressnetworkid"],workitem)
|
119
|
+
if resolved_sourceipaddressnetworkid.nil? || !validate_param(resolved_sourceipaddressnetworkid,"uuid")
|
120
|
+
raise "Missing mandatory parameter sourceipaddressnetworkid for resource #{@name}"
|
121
|
+
end
|
122
|
+
resolved_sourceipaddressnetworkid
|
123
|
+
end
|
124
|
+
|
125
|
+
def get_name
|
126
|
+
resolved_name = get_resolved(@props["name"],workitem)
|
127
|
+
if resolved_name.nil? || !validate_param(resolved_name,"string")
|
128
|
+
raise "Missing mandatory parameter name for resource #{@name}"
|
129
|
+
end
|
130
|
+
resolved_name
|
131
|
+
end
|
132
|
+
|
133
|
+
def get_instanceport
|
134
|
+
resolved_instanceport = get_resolved(@props["instanceport"],workitem)
|
135
|
+
if resolved_instanceport.nil? || !validate_param(resolved_instanceport,"integer")
|
136
|
+
raise "Missing mandatory parameter instanceport for resource #{@name}"
|
137
|
+
end
|
138
|
+
resolved_instanceport
|
139
|
+
end
|
140
|
+
|
141
|
+
def get_description
|
142
|
+
resolved_description = get_resolved(@props['description'],workitem)
|
143
|
+
if resolved_description.nil? || !validate_param(resolved_description,"string")
|
144
|
+
raise "Malformed optional parameter description for resource #{@name}"
|
145
|
+
end
|
146
|
+
resolved_description
|
147
|
+
end
|
148
|
+
|
149
|
+
def get_sourceipaddress
|
150
|
+
resolved_sourceipaddress = get_resolved(@props['sourceipaddress'],workitem)
|
151
|
+
if resolved_sourceipaddress.nil? || !validate_param(resolved_sourceipaddress,"string")
|
152
|
+
raise "Malformed optional parameter sourceipaddress for resource #{@name}"
|
153
|
+
end
|
154
|
+
resolved_sourceipaddress
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
@@ -0,0 +1,185 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackLoadBalancerRule < CloudStackResource
|
5
|
+
|
6
|
+
include Logging
|
7
|
+
include Intrinsic
|
8
|
+
include Resolver
|
9
|
+
def create
|
10
|
+
logger.debug("Creating resource #{@name}")
|
11
|
+
workitem[@name] = {}
|
12
|
+
name_cs = workitem['StackName'] + '-' + @name
|
13
|
+
args={}
|
14
|
+
begin
|
15
|
+
args['publicport'] = get_publicport
|
16
|
+
args['privateport'] = get_privateport
|
17
|
+
args['name'] = workitem['StackName'] +'-' +get_name
|
18
|
+
args['algorithm'] = get_algorithm
|
19
|
+
args['description'] = get_description if @props.has_key?('description')
|
20
|
+
args['networkid'] = get_networkid if @props.has_key?('networkid')
|
21
|
+
args['openfirewall'] = get_openfirewall if @props.has_key?('openfirewall')
|
22
|
+
args['account'] = get_account if @props.has_key?('account')
|
23
|
+
args['domainid'] = get_domainid if @props.has_key?('domainid')
|
24
|
+
args['publicipid'] = get_publicipid if @props.has_key?('publicipid')
|
25
|
+
args['zoneid'] = get_zoneid if @props.has_key?('zoneid')
|
26
|
+
args['cidrlist'] = get_cidrlist if @props.has_key?('cidrlist')
|
27
|
+
|
28
|
+
logger.info("Creating resource #{@name} with following arguments")
|
29
|
+
p args
|
30
|
+
result_obj = make_async_request('createLoadBalancerRule',args)
|
31
|
+
resource_obj = result_obj['LoadBalancerRule'.downcase]
|
32
|
+
#doing it this way since it is easier to change later, rather than cloning whole object
|
33
|
+
resource_obj.each_key do |k|
|
34
|
+
val = resource_obj[k]
|
35
|
+
if('id'.eql?(k))
|
36
|
+
k = 'physical_id'
|
37
|
+
end
|
38
|
+
workitem[@name][k] = val
|
39
|
+
end
|
40
|
+
set_tags(@props['tags'],workitem[@name]['physical_id'],"LoadBalancerRule") if @props.has_key?('tags')
|
41
|
+
workitem['ResolvedNames'][@name] = name_cs
|
42
|
+
workitem['IdMap'][workitem[@name]['physical_id']] = @name
|
43
|
+
|
44
|
+
rescue NoMethodError => nme
|
45
|
+
logger.error("Create request failed for resource . Cleaning up the stack")
|
46
|
+
raise nme
|
47
|
+
rescue Exception => e
|
48
|
+
logger.error(e.message)
|
49
|
+
raise e
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def delete
|
55
|
+
logger.debug("Deleting resource #{@name}")
|
56
|
+
begin
|
57
|
+
physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
|
58
|
+
if(!physical_id.nil?)
|
59
|
+
args = {'id' => physical_id
|
60
|
+
}
|
61
|
+
result_obj = make_async_request('deleteLoadBalancerRule',args)
|
62
|
+
if (!(result_obj['error'] == true))
|
63
|
+
logger.info("Successfully deleted resource #{@name}")
|
64
|
+
else
|
65
|
+
logger.info("CloudStack error while deleting resource #{@name}")
|
66
|
+
end
|
67
|
+
else
|
68
|
+
logger.info("Resource not created in CloudStack. Skipping delete...")
|
69
|
+
end
|
70
|
+
rescue Exception => e
|
71
|
+
logger.error("Unable to delete resorce #{@name}")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def on_workitem
|
76
|
+
@name = workitem.participant_name
|
77
|
+
@props = workitem['Resources'][@name]['Properties']
|
78
|
+
@props.downcase_key
|
79
|
+
@resolved_names = workitem['ResolvedNames']
|
80
|
+
if workitem['params']['operation'] == 'create'
|
81
|
+
create
|
82
|
+
else
|
83
|
+
delete
|
84
|
+
end
|
85
|
+
reply
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_publicport
|
89
|
+
resolved_publicport = get_resolved(@props["publicport"],workitem)
|
90
|
+
if resolved_publicport.nil? || !validate_param(resolved_publicport,"integer")
|
91
|
+
raise "Missing mandatory parameter publicport for resource #{@name}"
|
92
|
+
end
|
93
|
+
resolved_publicport
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_privateport
|
97
|
+
resolved_privateport = get_resolved(@props["privateport"],workitem)
|
98
|
+
if resolved_privateport.nil? || !validate_param(resolved_privateport,"integer")
|
99
|
+
raise "Missing mandatory parameter privateport for resource #{@name}"
|
100
|
+
end
|
101
|
+
resolved_privateport
|
102
|
+
end
|
103
|
+
|
104
|
+
def get_name
|
105
|
+
resolved_name = get_resolved(@props["name"],workitem)
|
106
|
+
if resolved_name.nil? || !validate_param(resolved_name,"string")
|
107
|
+
raise "Missing mandatory parameter name for resource #{@name}"
|
108
|
+
end
|
109
|
+
resolved_name
|
110
|
+
end
|
111
|
+
|
112
|
+
def get_algorithm
|
113
|
+
resolved_algorithm = get_resolved(@props["algorithm"],workitem)
|
114
|
+
if resolved_algorithm.nil? || !validate_param(resolved_algorithm,"string")
|
115
|
+
raise "Missing mandatory parameter algorithm for resource #{@name}"
|
116
|
+
end
|
117
|
+
resolved_algorithm
|
118
|
+
end
|
119
|
+
|
120
|
+
def get_description
|
121
|
+
resolved_description = get_resolved(@props['description'],workitem)
|
122
|
+
if resolved_description.nil? || !validate_param(resolved_description,"string")
|
123
|
+
raise "Malformed optional parameter description for resource #{@name}"
|
124
|
+
end
|
125
|
+
resolved_description
|
126
|
+
end
|
127
|
+
|
128
|
+
def get_networkid
|
129
|
+
resolved_networkid = get_resolved(@props['networkid'],workitem)
|
130
|
+
if resolved_networkid.nil? || !validate_param(resolved_networkid,"uuid")
|
131
|
+
raise "Malformed optional parameter networkid for resource #{@name}"
|
132
|
+
end
|
133
|
+
resolved_networkid
|
134
|
+
end
|
135
|
+
|
136
|
+
def get_openfirewall
|
137
|
+
resolved_openfirewall = get_resolved(@props['openfirewall'],workitem)
|
138
|
+
if resolved_openfirewall.nil? || !validate_param(resolved_openfirewall,"boolean")
|
139
|
+
raise "Malformed optional parameter openfirewall for resource #{@name}"
|
140
|
+
end
|
141
|
+
resolved_openfirewall
|
142
|
+
end
|
143
|
+
|
144
|
+
def get_account
|
145
|
+
resolved_account = get_resolved(@props['account'],workitem)
|
146
|
+
if resolved_account.nil? || !validate_param(resolved_account,"string")
|
147
|
+
raise "Malformed optional parameter account for resource #{@name}"
|
148
|
+
end
|
149
|
+
resolved_account
|
150
|
+
end
|
151
|
+
|
152
|
+
def get_domainid
|
153
|
+
resolved_domainid = get_resolved(@props['domainid'],workitem)
|
154
|
+
if resolved_domainid.nil? || !validate_param(resolved_domainid,"uuid")
|
155
|
+
raise "Malformed optional parameter domainid for resource #{@name}"
|
156
|
+
end
|
157
|
+
resolved_domainid
|
158
|
+
end
|
159
|
+
|
160
|
+
def get_publicipid
|
161
|
+
resolved_publicipid = get_resolved(@props['publicipid'],workitem)
|
162
|
+
if resolved_publicipid.nil? || !validate_param(resolved_publicipid,"uuid")
|
163
|
+
raise "Malformed optional parameter publicipid for resource #{@name}"
|
164
|
+
end
|
165
|
+
resolved_publicipid
|
166
|
+
end
|
167
|
+
|
168
|
+
def get_zoneid
|
169
|
+
resolved_zoneid = get_resolved(@props['zoneid'],workitem)
|
170
|
+
if resolved_zoneid.nil? || !validate_param(resolved_zoneid,"uuid")
|
171
|
+
raise "Malformed optional parameter zoneid for resource #{@name}"
|
172
|
+
end
|
173
|
+
resolved_zoneid
|
174
|
+
end
|
175
|
+
|
176
|
+
def get_cidrlist
|
177
|
+
resolved_cidrlist = get_resolved(@props['cidrlist'],workitem)
|
178
|
+
if resolved_cidrlist.nil? || !validate_param(resolved_cidrlist,"list")
|
179
|
+
raise "Malformed optional parameter cidrlist for resource #{@name}"
|
180
|
+
end
|
181
|
+
resolved_cidrlist
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
@@ -0,0 +1,293 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackNetwork < CloudStackResource
|
5
|
+
|
6
|
+
include Logging
|
7
|
+
include Intrinsic
|
8
|
+
include Resolver
|
9
|
+
def create
|
10
|
+
logger.debug("Creating resource #{@name}")
|
11
|
+
workitem[@name] = {}
|
12
|
+
name_cs = workitem['StackName'] + '-' + @name
|
13
|
+
args={}
|
14
|
+
begin
|
15
|
+
args['displaytext'] = get_displaytext
|
16
|
+
args['networkofferingid'] = get_networkofferingid
|
17
|
+
args['name'] = workitem['StackName'] +'-' +get_name
|
18
|
+
args['zoneid'] = get_zoneid
|
19
|
+
args['networkdomain'] = get_networkdomain if @props.has_key?('networkdomain')
|
20
|
+
args['projectid'] = get_projectid if @props.has_key?('projectid')
|
21
|
+
args['startip'] = get_startip if @props.has_key?('startip')
|
22
|
+
args['domainid'] = get_domainid if @props.has_key?('domainid')
|
23
|
+
args['displaynetwork'] = get_displaynetwork if @props.has_key?('displaynetwork')
|
24
|
+
args['startipv6'] = get_startipv6 if @props.has_key?('startipv6')
|
25
|
+
args['acltype'] = get_acltype if @props.has_key?('acltype')
|
26
|
+
args['endip'] = get_endip if @props.has_key?('endip')
|
27
|
+
args['account'] = get_account if @props.has_key?('account')
|
28
|
+
args['gateway'] = get_gateway if @props.has_key?('gateway')
|
29
|
+
args['vlan'] = get_vlan if @props.has_key?('vlan')
|
30
|
+
args['endipv6'] = get_endipv6 if @props.has_key?('endipv6')
|
31
|
+
args['ip6cidr'] = get_ip6cidr if @props.has_key?('ip6cidr')
|
32
|
+
args['aclid'] = get_aclid if @props.has_key?('aclid')
|
33
|
+
args['isolatedpvlan'] = get_isolatedpvlan if @props.has_key?('isolatedpvlan')
|
34
|
+
args['ip6gateway'] = get_ip6gateway if @props.has_key?('ip6gateway')
|
35
|
+
args['netmask'] = get_netmask if @props.has_key?('netmask')
|
36
|
+
args['subdomainaccess'] = get_subdomainaccess if @props.has_key?('subdomainaccess')
|
37
|
+
args['vpcid'] = get_vpcid if @props.has_key?('vpcid')
|
38
|
+
args['physicalnetworkid'] = get_physicalnetworkid if @props.has_key?('physicalnetworkid')
|
39
|
+
|
40
|
+
logger.info("Creating resource #{@name} with following arguments")
|
41
|
+
p args
|
42
|
+
result_obj = make_sync_request('createNetwork',args)
|
43
|
+
resource_obj = result_obj['Network'.downcase]
|
44
|
+
#doing it this way since it is easier to change later, rather than cloning whole object
|
45
|
+
resource_obj.each_key do |k|
|
46
|
+
val = resource_obj[k]
|
47
|
+
if('id'.eql?(k))
|
48
|
+
k = 'physical_id'
|
49
|
+
end
|
50
|
+
workitem[@name][k] = val
|
51
|
+
end
|
52
|
+
set_tags(@props['tags'],workitem[@name]['physical_id'],"Network") if @props.has_key?('tags')
|
53
|
+
workitem['ResolvedNames'][@name] = name_cs
|
54
|
+
workitem['IdMap'][workitem[@name]['physical_id']] = @name
|
55
|
+
|
56
|
+
rescue NoMethodError => nme
|
57
|
+
logger.error("Create request failed for resource . Cleaning up the stack")
|
58
|
+
raise nme
|
59
|
+
rescue Exception => e
|
60
|
+
logger.error(e.message)
|
61
|
+
raise e
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def delete
|
67
|
+
logger.debug("Deleting resource #{@name}")
|
68
|
+
begin
|
69
|
+
physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
|
70
|
+
if(!physical_id.nil?)
|
71
|
+
args = {'id' => physical_id
|
72
|
+
}
|
73
|
+
result_obj = make_async_request('deleteNetwork',args)
|
74
|
+
if (!(result_obj['error'] == true))
|
75
|
+
logger.info("Successfully deleted resource #{@name}")
|
76
|
+
else
|
77
|
+
logger.info("CloudStack error while deleting resource #{@name}")
|
78
|
+
end
|
79
|
+
else
|
80
|
+
logger.info("Resource not created in CloudStack. Skipping delete...")
|
81
|
+
end
|
82
|
+
rescue Exception => e
|
83
|
+
logger.error("Unable to delete resorce #{@name}")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def on_workitem
|
88
|
+
@name = workitem.participant_name
|
89
|
+
@props = workitem['Resources'][@name]['Properties']
|
90
|
+
@props.downcase_key
|
91
|
+
@resolved_names = workitem['ResolvedNames']
|
92
|
+
if workitem['params']['operation'] == 'create'
|
93
|
+
create
|
94
|
+
else
|
95
|
+
delete
|
96
|
+
end
|
97
|
+
reply
|
98
|
+
end
|
99
|
+
|
100
|
+
def get_displaytext
|
101
|
+
resolved_displaytext = get_resolved(@props["displaytext"],workitem)
|
102
|
+
if resolved_displaytext.nil? || !validate_param(resolved_displaytext,"string")
|
103
|
+
raise "Missing mandatory parameter displaytext for resource #{@name}"
|
104
|
+
end
|
105
|
+
resolved_displaytext
|
106
|
+
end
|
107
|
+
|
108
|
+
def get_networkofferingid
|
109
|
+
resolved_networkofferingid = get_resolved(@props["networkofferingid"],workitem)
|
110
|
+
if resolved_networkofferingid.nil? || !validate_param(resolved_networkofferingid,"uuid")
|
111
|
+
raise "Missing mandatory parameter networkofferingid for resource #{@name}"
|
112
|
+
end
|
113
|
+
resolved_networkofferingid
|
114
|
+
end
|
115
|
+
|
116
|
+
def get_name
|
117
|
+
resolved_name = get_resolved(@props["name"],workitem)
|
118
|
+
if resolved_name.nil? || !validate_param(resolved_name,"string")
|
119
|
+
raise "Missing mandatory parameter name for resource #{@name}"
|
120
|
+
end
|
121
|
+
resolved_name
|
122
|
+
end
|
123
|
+
|
124
|
+
def get_zoneid
|
125
|
+
resolved_zoneid = get_resolved(@props["zoneid"],workitem)
|
126
|
+
if resolved_zoneid.nil? || !validate_param(resolved_zoneid,"uuid")
|
127
|
+
raise "Missing mandatory parameter zoneid for resource #{@name}"
|
128
|
+
end
|
129
|
+
resolved_zoneid
|
130
|
+
end
|
131
|
+
|
132
|
+
def get_networkdomain
|
133
|
+
resolved_networkdomain = get_resolved(@props['networkdomain'],workitem)
|
134
|
+
if resolved_networkdomain.nil? || !validate_param(resolved_networkdomain,"string")
|
135
|
+
raise "Malformed optional parameter networkdomain for resource #{@name}"
|
136
|
+
end
|
137
|
+
resolved_networkdomain
|
138
|
+
end
|
139
|
+
|
140
|
+
def get_projectid
|
141
|
+
resolved_projectid = get_resolved(@props['projectid'],workitem)
|
142
|
+
if resolved_projectid.nil? || !validate_param(resolved_projectid,"uuid")
|
143
|
+
raise "Malformed optional parameter projectid for resource #{@name}"
|
144
|
+
end
|
145
|
+
resolved_projectid
|
146
|
+
end
|
147
|
+
|
148
|
+
def get_startip
|
149
|
+
resolved_startip = get_resolved(@props['startip'],workitem)
|
150
|
+
if resolved_startip.nil? || !validate_param(resolved_startip,"string")
|
151
|
+
raise "Malformed optional parameter startip for resource #{@name}"
|
152
|
+
end
|
153
|
+
resolved_startip
|
154
|
+
end
|
155
|
+
|
156
|
+
def get_domainid
|
157
|
+
resolved_domainid = get_resolved(@props['domainid'],workitem)
|
158
|
+
if resolved_domainid.nil? || !validate_param(resolved_domainid,"uuid")
|
159
|
+
raise "Malformed optional parameter domainid for resource #{@name}"
|
160
|
+
end
|
161
|
+
resolved_domainid
|
162
|
+
end
|
163
|
+
|
164
|
+
def get_displaynetwork
|
165
|
+
resolved_displaynetwork = get_resolved(@props['displaynetwork'],workitem)
|
166
|
+
if resolved_displaynetwork.nil? || !validate_param(resolved_displaynetwork,"boolean")
|
167
|
+
raise "Malformed optional parameter displaynetwork for resource #{@name}"
|
168
|
+
end
|
169
|
+
resolved_displaynetwork
|
170
|
+
end
|
171
|
+
|
172
|
+
def get_startipv6
|
173
|
+
resolved_startipv6 = get_resolved(@props['startipv6'],workitem)
|
174
|
+
if resolved_startipv6.nil? || !validate_param(resolved_startipv6,"string")
|
175
|
+
raise "Malformed optional parameter startipv6 for resource #{@name}"
|
176
|
+
end
|
177
|
+
resolved_startipv6
|
178
|
+
end
|
179
|
+
|
180
|
+
def get_acltype
|
181
|
+
resolved_acltype = get_resolved(@props['acltype'],workitem)
|
182
|
+
if resolved_acltype.nil? || !validate_param(resolved_acltype,"string")
|
183
|
+
raise "Malformed optional parameter acltype for resource #{@name}"
|
184
|
+
end
|
185
|
+
resolved_acltype
|
186
|
+
end
|
187
|
+
|
188
|
+
def get_endip
|
189
|
+
resolved_endip = get_resolved(@props['endip'],workitem)
|
190
|
+
if resolved_endip.nil? || !validate_param(resolved_endip,"string")
|
191
|
+
raise "Malformed optional parameter endip for resource #{@name}"
|
192
|
+
end
|
193
|
+
resolved_endip
|
194
|
+
end
|
195
|
+
|
196
|
+
def get_account
|
197
|
+
resolved_account = get_resolved(@props['account'],workitem)
|
198
|
+
if resolved_account.nil? || !validate_param(resolved_account,"string")
|
199
|
+
raise "Malformed optional parameter account for resource #{@name}"
|
200
|
+
end
|
201
|
+
resolved_account
|
202
|
+
end
|
203
|
+
|
204
|
+
def get_gateway
|
205
|
+
resolved_gateway = get_resolved(@props['gateway'],workitem)
|
206
|
+
if resolved_gateway.nil? || !validate_param(resolved_gateway,"string")
|
207
|
+
raise "Malformed optional parameter gateway for resource #{@name}"
|
208
|
+
end
|
209
|
+
resolved_gateway
|
210
|
+
end
|
211
|
+
|
212
|
+
def get_vlan
|
213
|
+
resolved_vlan = get_resolved(@props['vlan'],workitem)
|
214
|
+
if resolved_vlan.nil? || !validate_param(resolved_vlan,"string")
|
215
|
+
raise "Malformed optional parameter vlan for resource #{@name}"
|
216
|
+
end
|
217
|
+
resolved_vlan
|
218
|
+
end
|
219
|
+
|
220
|
+
def get_endipv6
|
221
|
+
resolved_endipv6 = get_resolved(@props['endipv6'],workitem)
|
222
|
+
if resolved_endipv6.nil? || !validate_param(resolved_endipv6,"string")
|
223
|
+
raise "Malformed optional parameter endipv6 for resource #{@name}"
|
224
|
+
end
|
225
|
+
resolved_endipv6
|
226
|
+
end
|
227
|
+
|
228
|
+
def get_ip6cidr
|
229
|
+
resolved_ip6cidr = get_resolved(@props['ip6cidr'],workitem)
|
230
|
+
if resolved_ip6cidr.nil? || !validate_param(resolved_ip6cidr,"string")
|
231
|
+
raise "Malformed optional parameter ip6cidr for resource #{@name}"
|
232
|
+
end
|
233
|
+
resolved_ip6cidr
|
234
|
+
end
|
235
|
+
|
236
|
+
def get_aclid
|
237
|
+
resolved_aclid = get_resolved(@props['aclid'],workitem)
|
238
|
+
if resolved_aclid.nil? || !validate_param(resolved_aclid,"uuid")
|
239
|
+
raise "Malformed optional parameter aclid for resource #{@name}"
|
240
|
+
end
|
241
|
+
resolved_aclid
|
242
|
+
end
|
243
|
+
|
244
|
+
def get_isolatedpvlan
|
245
|
+
resolved_isolatedpvlan = get_resolved(@props['isolatedpvlan'],workitem)
|
246
|
+
if resolved_isolatedpvlan.nil? || !validate_param(resolved_isolatedpvlan,"string")
|
247
|
+
raise "Malformed optional parameter isolatedpvlan for resource #{@name}"
|
248
|
+
end
|
249
|
+
resolved_isolatedpvlan
|
250
|
+
end
|
251
|
+
|
252
|
+
def get_ip6gateway
|
253
|
+
resolved_ip6gateway = get_resolved(@props['ip6gateway'],workitem)
|
254
|
+
if resolved_ip6gateway.nil? || !validate_param(resolved_ip6gateway,"string")
|
255
|
+
raise "Malformed optional parameter ip6gateway for resource #{@name}"
|
256
|
+
end
|
257
|
+
resolved_ip6gateway
|
258
|
+
end
|
259
|
+
|
260
|
+
def get_netmask
|
261
|
+
resolved_netmask = get_resolved(@props['netmask'],workitem)
|
262
|
+
if resolved_netmask.nil? || !validate_param(resolved_netmask,"string")
|
263
|
+
raise "Malformed optional parameter netmask for resource #{@name}"
|
264
|
+
end
|
265
|
+
resolved_netmask
|
266
|
+
end
|
267
|
+
|
268
|
+
def get_subdomainaccess
|
269
|
+
resolved_subdomainaccess = get_resolved(@props['subdomainaccess'],workitem)
|
270
|
+
if resolved_subdomainaccess.nil? || !validate_param(resolved_subdomainaccess,"boolean")
|
271
|
+
raise "Malformed optional parameter subdomainaccess for resource #{@name}"
|
272
|
+
end
|
273
|
+
resolved_subdomainaccess
|
274
|
+
end
|
275
|
+
|
276
|
+
def get_vpcid
|
277
|
+
resolved_vpcid = get_resolved(@props['vpcid'],workitem)
|
278
|
+
if resolved_vpcid.nil? || !validate_param(resolved_vpcid,"uuid")
|
279
|
+
raise "Malformed optional parameter vpcid for resource #{@name}"
|
280
|
+
end
|
281
|
+
resolved_vpcid
|
282
|
+
end
|
283
|
+
|
284
|
+
def get_physicalnetworkid
|
285
|
+
resolved_physicalnetworkid = get_resolved(@props['physicalnetworkid'],workitem)
|
286
|
+
if resolved_physicalnetworkid.nil? || !validate_param(resolved_physicalnetworkid,"uuid")
|
287
|
+
raise "Malformed optional parameter physicalnetworkid for resource #{@name}"
|
288
|
+
end
|
289
|
+
resolved_physicalnetworkid
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|