stackmate 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/CHANGELOG.txt +7 -0
  2. data/README.md +25 -8
  3. data/bin/stackmate.rb +57 -53
  4. data/lib/stackmate/aws_attribs.rb +31 -31
  5. data/lib/stackmate/classmap.rb +33 -25
  6. data/lib/stackmate/client.rb +80 -0
  7. data/lib/stackmate/intrinsic_functions.rb +94 -38
  8. data/lib/stackmate/logging.rb +19 -19
  9. data/lib/stackmate/participants/cloudstack.rb +250 -165
  10. data/lib/stackmate/participants/cloudstack_affinitygroup.rb +122 -0
  11. data/lib/stackmate/participants/cloudstack_autoscalepolicy.rb +113 -0
  12. data/lib/stackmate/participants/cloudstack_autoscalevmgroup.rb +86 -0
  13. data/lib/stackmate/participants/cloudstack_autoscalevmprofile.rb +140 -0
  14. data/lib/stackmate/participants/cloudstack_condition.rb +122 -0
  15. data/lib/stackmate/participants/cloudstack_egressfirewallrule.rb +149 -0
  16. data/lib/stackmate/participants/cloudstack_firewallrule.rb +149 -0
  17. data/lib/stackmate/participants/cloudstack_globalloadbalancerrule.rb +158 -0
  18. data/lib/stackmate/participants/cloudstack_instancegroup.rb +113 -0
  19. data/lib/stackmate/participants/cloudstack_ipaddress.rb +149 -0
  20. data/lib/stackmate/participants/cloudstack_ipforwardingrule.rb +131 -0
  21. data/lib/stackmate/participants/cloudstack_iptonic.rb +95 -0
  22. data/lib/stackmate/participants/cloudstack_iso.rb +95 -0
  23. data/lib/stackmate/participants/cloudstack_lbhealthcheckpolicy.rb +140 -0
  24. data/lib/stackmate/participants/cloudstack_lbstickinesspolicy.rb +122 -0
  25. data/lib/stackmate/participants/cloudstack_loadbalancer.rb +158 -0
  26. data/lib/stackmate/participants/cloudstack_loadbalancerrule.rb +185 -0
  27. data/lib/stackmate/participants/cloudstack_network.rb +293 -0
  28. data/lib/stackmate/participants/cloudstack_networkacl.rb +176 -0
  29. data/lib/stackmate/participants/cloudstack_networkacllist.rb +104 -0
  30. data/lib/stackmate/participants/cloudstack_nictovirtualmachine.rb +104 -0
  31. data/lib/stackmate/participants/cloudstack_portforwardingrule.rb +176 -0
  32. data/lib/stackmate/participants/cloudstack_project.rb +113 -0
  33. data/lib/stackmate/participants/cloudstack_remoteaccessvpn.rb +122 -0
  34. data/lib/stackmate/participants/cloudstack_securitygroup.rb +122 -0
  35. data/lib/stackmate/participants/cloudstack_securitygroupegress.rb +185 -0
  36. data/lib/stackmate/participants/cloudstack_securitygroupingress.rb +185 -0
  37. data/lib/stackmate/participants/cloudstack_snapshot.rb +113 -0
  38. data/lib/stackmate/participants/cloudstack_snapshotpolicy.rb +122 -0
  39. data/lib/stackmate/participants/cloudstack_sshkeypair.rb +113 -0
  40. data/lib/stackmate/participants/cloudstack_staticnat.rb +113 -0
  41. data/lib/stackmate/participants/cloudstack_staticroute.rb +95 -0
  42. data/lib/stackmate/participants/cloudstack_tags.rb +113 -0
  43. data/lib/stackmate/participants/cloudstack_template.rb +212 -0
  44. data/lib/stackmate/participants/cloudstack_togloballoadbalancerrule.rb +104 -0
  45. data/lib/stackmate/participants/cloudstack_toloadbalancerrule.rb +95 -0
  46. data/lib/stackmate/participants/cloudstack_virtualmachine.rb +348 -0
  47. data/lib/stackmate/participants/cloudstack_virtualmachineops.rb +95 -0
  48. data/lib/stackmate/participants/cloudstack_vmsnapshot.rb +113 -0
  49. data/lib/stackmate/participants/cloudstack_volume.rb +176 -0
  50. data/lib/stackmate/participants/cloudstack_volumeops.rb +111 -0
  51. data/lib/stackmate/participants/cloudstack_vpc.rb +158 -0
  52. data/lib/stackmate/participants/cloudstack_vpnconnection.rb +95 -0
  53. data/lib/stackmate/participants/cloudstack_vpncustomergateway.rb +176 -0
  54. data/lib/stackmate/participants/cloudstack_vpngateway.rb +86 -0
  55. data/lib/stackmate/participants/cloudstack_vpnuser.rb +122 -0
  56. data/lib/stackmate/participants/common.rb +219 -70
  57. data/lib/stackmate/participants/stacknest.rb +6 -0
  58. data/lib/stackmate/resolver.rb +122 -0
  59. data/lib/stackmate/stack.rb +116 -60
  60. data/lib/stackmate/stack_executor.rb +99 -37
  61. data/lib/stackmate/stackpi.rb +46 -0
  62. data/lib/stackmate/version.rb +1 -1
  63. data/lib/stackmate/waitcondition_server.rb +15 -15
  64. data/lib/stackmate.rb +1 -1
  65. data/stackmate.gemspec +2 -4
  66. metadata +70 -19
@@ -0,0 +1,176 @@
1
+ require 'stackmate/participants/cloudstack'
2
+
3
+ module StackMate
4
+ class CloudStackVolume < 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['name'] = workitem['StackName'] +'-' +get_name
16
+ args['maxiops'] = get_maxiops if @props.has_key?('maxiops')
17
+ args['domainid'] = get_domainid if @props.has_key?('domainid')
18
+ args['projectid'] = get_projectid if @props.has_key?('projectid')
19
+ args['displayvolume'] = get_displayvolume if @props.has_key?('displayvolume')
20
+ args['snapshotid'] = get_snapshotid if @props.has_key?('snapshotid')
21
+ args['miniops'] = get_miniops if @props.has_key?('miniops')
22
+ args['diskofferingid'] = get_diskofferingid if @props.has_key?('diskofferingid')
23
+ args['size'] = get_size if @props.has_key?('size')
24
+ args['account'] = get_account if @props.has_key?('account')
25
+ args['zoneid'] = get_zoneid if @props.has_key?('zoneid')
26
+
27
+ logger.info("Creating resource #{@name} with following arguments")
28
+ p args
29
+ result_obj = make_async_request('createVolume',args)
30
+ resource_obj = result_obj['Volume'.downcase]
31
+ #doing it this way since it is easier to change later, rather than cloning whole object
32
+ resource_obj.each_key do |k|
33
+ val = resource_obj[k]
34
+ if('id'.eql?(k))
35
+ k = 'physical_id'
36
+ end
37
+ workitem[@name][k] = val
38
+ end
39
+ set_tags(@props['tags'],workitem[@name]['physical_id'],"Volume") if @props.has_key?('tags')
40
+ workitem['ResolvedNames'][@name] = name_cs
41
+ workitem['IdMap'][workitem[@name]['physical_id']] = @name
42
+
43
+ rescue NoMethodError => nme
44
+ logger.error("Create request failed for resource . Cleaning up the stack")
45
+ raise nme
46
+ rescue Exception => e
47
+ logger.error(e.message)
48
+ raise e
49
+ end
50
+
51
+ end
52
+
53
+ def delete
54
+ logger.debug("Deleting resource #{@name}")
55
+ begin
56
+ physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
57
+ if(!physical_id.nil?)
58
+ args = {'id' => physical_id
59
+ }
60
+ result_obj = make_sync_request('deleteVolume',args)
61
+ if (!(result_obj['error'] == true))
62
+ logger.info("Successfully deleted resource #{@name}")
63
+ else
64
+ logger.info("CloudStack error while deleting resource #{@name}")
65
+ end
66
+ else
67
+ logger.info("Resource not created in CloudStack. Skipping delete...")
68
+ end
69
+ rescue Exception => e
70
+ logger.error("Unable to delete resorce #{@name}")
71
+ end
72
+ end
73
+
74
+ def on_workitem
75
+ @name = workitem.participant_name
76
+ @props = workitem['Resources'][@name]['Properties']
77
+ @props.downcase_key
78
+ @resolved_names = workitem['ResolvedNames']
79
+ if workitem['params']['operation'] == 'create'
80
+ create
81
+ else
82
+ delete
83
+ end
84
+ reply
85
+ end
86
+
87
+ def get_name
88
+ resolved_name = get_resolved(@props["name"],workitem)
89
+ if resolved_name.nil? || !validate_param(resolved_name,"string")
90
+ raise "Missing mandatory parameter name for resource #{@name}"
91
+ end
92
+ resolved_name
93
+ end
94
+
95
+ def get_maxiops
96
+ resolved_maxiops = get_resolved(@props['maxiops'],workitem)
97
+ if resolved_maxiops.nil? || !validate_param(resolved_maxiops,"long")
98
+ raise "Malformed optional parameter maxiops for resource #{@name}"
99
+ end
100
+ resolved_maxiops
101
+ end
102
+
103
+ def get_domainid
104
+ resolved_domainid = get_resolved(@props['domainid'],workitem)
105
+ if resolved_domainid.nil? || !validate_param(resolved_domainid,"uuid")
106
+ raise "Malformed optional parameter domainid for resource #{@name}"
107
+ end
108
+ resolved_domainid
109
+ end
110
+
111
+ def get_projectid
112
+ resolved_projectid = get_resolved(@props['projectid'],workitem)
113
+ if resolved_projectid.nil? || !validate_param(resolved_projectid,"uuid")
114
+ raise "Malformed optional parameter projectid for resource #{@name}"
115
+ end
116
+ resolved_projectid
117
+ end
118
+
119
+ def get_displayvolume
120
+ resolved_displayvolume = get_resolved(@props['displayvolume'],workitem)
121
+ if resolved_displayvolume.nil? || !validate_param(resolved_displayvolume,"boolean")
122
+ raise "Malformed optional parameter displayvolume for resource #{@name}"
123
+ end
124
+ resolved_displayvolume
125
+ end
126
+
127
+ def get_snapshotid
128
+ resolved_snapshotid = get_resolved(@props['snapshotid'],workitem)
129
+ if resolved_snapshotid.nil? || !validate_param(resolved_snapshotid,"uuid")
130
+ raise "Malformed optional parameter snapshotid for resource #{@name}"
131
+ end
132
+ resolved_snapshotid
133
+ end
134
+
135
+ def get_miniops
136
+ resolved_miniops = get_resolved(@props['miniops'],workitem)
137
+ if resolved_miniops.nil? || !validate_param(resolved_miniops,"long")
138
+ raise "Malformed optional parameter miniops for resource #{@name}"
139
+ end
140
+ resolved_miniops
141
+ end
142
+
143
+ def get_diskofferingid
144
+ resolved_diskofferingid = get_resolved(@props['diskofferingid'],workitem)
145
+ if resolved_diskofferingid.nil? || !validate_param(resolved_diskofferingid,"uuid")
146
+ raise "Malformed optional parameter diskofferingid for resource #{@name}"
147
+ end
148
+ resolved_diskofferingid
149
+ end
150
+
151
+ def get_size
152
+ resolved_size = get_resolved(@props['size'],workitem)
153
+ if resolved_size.nil? || !validate_param(resolved_size,"long")
154
+ raise "Malformed optional parameter size for resource #{@name}"
155
+ end
156
+ resolved_size
157
+ end
158
+
159
+ def get_account
160
+ resolved_account = get_resolved(@props['account'],workitem)
161
+ if resolved_account.nil? || !validate_param(resolved_account,"string")
162
+ raise "Malformed optional parameter account for resource #{@name}"
163
+ end
164
+ resolved_account
165
+ end
166
+
167
+ def get_zoneid
168
+ resolved_zoneid = get_resolved(@props['zoneid'],workitem)
169
+ if resolved_zoneid.nil? || !validate_param(resolved_zoneid,"uuid")
170
+ raise "Malformed optional parameter zoneid for resource #{@name}"
171
+ end
172
+ resolved_zoneid
173
+ end
174
+ end
175
+ end
176
+
@@ -0,0 +1,111 @@
1
+ require 'stackmate/participants/cloudstack'
2
+
3
+ module StackMate
4
+ class CloudStackVolumeOps < 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
+
16
+ args['id'] = get_id
17
+ args['virtualmachineid'] = get_virtualmachineid
18
+ args['deviceid'] = get_deviceid if @props.has_key?('deviceid')
19
+
20
+ logger.info("Creating resource #{@name} with following arguments")
21
+ p args
22
+ result_obj = make_async_request('attachVolume',args)
23
+ resource_obj = result_obj['Volume'.downcase]
24
+ #doing it this way since it is easier to change later, rather than cloning whole object
25
+ resource_obj.each_key do |k|
26
+ val = resource_obj[k]
27
+ if('id'.eql?(k))
28
+ k = 'physical_id'
29
+ end
30
+ workitem[@name][k] = val
31
+ end
32
+ set_tags(@props['tags'],workitem[@name]['physical_id'],"Volume") if @props.has_key?('tags')
33
+ workitem['ResolvedNames'][@name] = name_cs
34
+ workitem['IdMap'][workitem[@name]['physical_id']] = @name
35
+
36
+ rescue NoMethodError => nme
37
+ logger.error("Create request failed for resource #{@name}. Cleaning up the stack")
38
+ raise nme
39
+
40
+ rescue Exception => e
41
+ logger.error(e.message)
42
+ raise e
43
+ end
44
+
45
+
46
+ end
47
+
48
+
49
+ def delete
50
+ logger.debug("Deleting resource #{@name}")
51
+ begin
52
+ physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
53
+ if(!physical_id.nil?)
54
+ args = {'id' => physical_id
55
+ }
56
+ result_obj = make_async_request('detachVolume',args)
57
+ if (!(result_obj['error'] == true))
58
+ logger.info("Successfully deleted resource #{@name}")
59
+ else
60
+ logger.info("CloudStack error while deleting resource #{@name}")
61
+ end
62
+ else
63
+ logger.info("Resource not created in CloudStack. Skipping delete...")
64
+ end
65
+ rescue Exception => e
66
+ logger.error("Unable to delete resorce #{@name}")
67
+ end
68
+ end
69
+
70
+ def on_workitem
71
+ @name = workitem.participant_name
72
+ @props = workitem['Resources'][@name]['Properties']
73
+ @props.downcase_key
74
+ @resolved_names = workitem['ResolvedNames']
75
+ if workitem['params']['operation'] == 'create'
76
+ create
77
+ else
78
+ delete
79
+ end
80
+ reply
81
+ end
82
+
83
+
84
+ def get_id
85
+ resolved_id = get_resolved(@props["id"],workitem)
86
+ if resolved_id.nil? || !validate_param(resolved_id,"uuid")
87
+ raise "Missing mandatory parameter id for resource #{@name}"
88
+ end
89
+ resolved_id
90
+ end
91
+
92
+
93
+ def get_virtualmachineid
94
+ resolved_virtualmachineid = get_resolved(@props["virtualmachineid"],workitem)
95
+ if resolved_virtualmachineid.nil? || !validate_param(resolved_virtualmachineid,"uuid")
96
+ raise "Missing mandatory parameter virtualmachineid for resource #{@name}"
97
+ end
98
+ resolved_virtualmachineid
99
+ end
100
+
101
+
102
+ def get_deviceid
103
+ resolved_deviceid = get_resolved(@props['deviceid'],workitem)
104
+ if resolved_deviceid.nil? || !validate_param(resolved_deviceid,"long")
105
+ raise "Malformed optional parameter deviceid for resource #{@name}"
106
+ end
107
+ resolved_deviceid
108
+ end
109
+
110
+ end
111
+ end
@@ -0,0 +1,158 @@
1
+ require 'stackmate/participants/cloudstack'
2
+
3
+ module StackMate
4
+ class CloudStackVPC < 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['cidr'] = get_cidr
16
+ args['zoneid'] = get_zoneid
17
+ args['name'] = workitem['StackName'] +'-' +get_name
18
+ args['vpcofferingid'] = get_vpcofferingid
19
+ args['displaytext'] = get_displaytext
20
+ args['projectid'] = get_projectid if @props.has_key?('projectid')
21
+ args['account'] = get_account if @props.has_key?('account')
22
+ args['domainid'] = get_domainid if @props.has_key?('domainid')
23
+ args['networkdomain'] = get_networkdomain if @props.has_key?('networkdomain')
24
+
25
+ logger.info("Creating resource #{@name} with following arguments")
26
+ p args
27
+ result_obj = make_async_request('createVPC',args)
28
+ resource_obj = result_obj['VPC'.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'],"VPC") 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('deleteVPC',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_cidr
86
+ resolved_cidr = get_resolved(@props["cidr"],workitem)
87
+ if resolved_cidr.nil? || !validate_param(resolved_cidr,"string")
88
+ raise "Missing mandatory parameter cidr for resource #{@name}"
89
+ end
90
+ resolved_cidr
91
+ end
92
+
93
+ def get_zoneid
94
+ resolved_zoneid = get_resolved(@props["zoneid"],workitem)
95
+ if resolved_zoneid.nil? || !validate_param(resolved_zoneid,"uuid")
96
+ raise "Missing mandatory parameter zoneid for resource #{@name}"
97
+ end
98
+ resolved_zoneid
99
+ end
100
+
101
+ def get_name
102
+ resolved_name = get_resolved(@props["name"],workitem)
103
+ if resolved_name.nil? || !validate_param(resolved_name,"string")
104
+ raise "Missing mandatory parameter name for resource #{@name}"
105
+ end
106
+ resolved_name
107
+ end
108
+
109
+ def get_vpcofferingid
110
+ resolved_vpcofferingid = get_resolved(@props["vpcofferingid"],workitem)
111
+ if resolved_vpcofferingid.nil? || !validate_param(resolved_vpcofferingid,"uuid")
112
+ raise "Missing mandatory parameter vpcofferingid for resource #{@name}"
113
+ end
114
+ resolved_vpcofferingid
115
+ end
116
+
117
+ def get_displaytext
118
+ resolved_displaytext = get_resolved(@props["displaytext"],workitem)
119
+ if resolved_displaytext.nil? || !validate_param(resolved_displaytext,"string")
120
+ raise "Missing mandatory parameter displaytext for resource #{@name}"
121
+ end
122
+ resolved_displaytext
123
+ end
124
+
125
+ def get_projectid
126
+ resolved_projectid = get_resolved(@props['projectid'],workitem)
127
+ if resolved_projectid.nil? || !validate_param(resolved_projectid,"uuid")
128
+ raise "Malformed optional parameter projectid for resource #{@name}"
129
+ end
130
+ resolved_projectid
131
+ end
132
+
133
+ def get_account
134
+ resolved_account = get_resolved(@props['account'],workitem)
135
+ if resolved_account.nil? || !validate_param(resolved_account,"string")
136
+ raise "Malformed optional parameter account for resource #{@name}"
137
+ end
138
+ resolved_account
139
+ end
140
+
141
+ def get_domainid
142
+ resolved_domainid = get_resolved(@props['domainid'],workitem)
143
+ if resolved_domainid.nil? || !validate_param(resolved_domainid,"uuid")
144
+ raise "Malformed optional parameter domainid for resource #{@name}"
145
+ end
146
+ resolved_domainid
147
+ end
148
+
149
+ def get_networkdomain
150
+ resolved_networkdomain = get_resolved(@props['networkdomain'],workitem)
151
+ if resolved_networkdomain.nil? || !validate_param(resolved_networkdomain,"string")
152
+ raise "Malformed optional parameter networkdomain for resource #{@name}"
153
+ end
154
+ resolved_networkdomain
155
+ end
156
+ end
157
+ end
158
+
@@ -0,0 +1,95 @@
1
+ require 'stackmate/participants/cloudstack'
2
+
3
+ module StackMate
4
+ class CloudStackVpnConnection < 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['s2scustomergatewayid'] = get_s2scustomergatewayid
16
+ args['s2svpngatewayid'] = get_s2svpngatewayid
17
+
18
+ logger.info("Creating resource #{@name} with following arguments")
19
+ p args
20
+ result_obj = make_async_request('createVpnConnection',args)
21
+ resource_obj = result_obj['VpnConnection'.downcase]
22
+ #doing it this way since it is easier to change later, rather than cloning whole object
23
+ resource_obj.each_key do |k|
24
+ val = resource_obj[k]
25
+ if('id'.eql?(k))
26
+ k = 'physical_id'
27
+ end
28
+ workitem[@name][k] = val
29
+ end
30
+ set_tags(@props['tags'],workitem[@name]['physical_id'],"VpnConnection") if @props.has_key?('tags')
31
+ workitem['ResolvedNames'][@name] = name_cs
32
+ workitem['IdMap'][workitem[@name]['physical_id']] = @name
33
+
34
+ rescue NoMethodError => nme
35
+ logger.error("Create request failed for resource . Cleaning up the stack")
36
+ raise nme
37
+ rescue Exception => e
38
+ logger.error(e.message)
39
+ raise e
40
+ end
41
+
42
+ end
43
+
44
+ def delete
45
+ logger.debug("Deleting resource #{@name}")
46
+ begin
47
+ physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
48
+ if(!physical_id.nil?)
49
+ args = {'id' => physical_id
50
+ }
51
+ result_obj = make_async_request('deleteVpnConnection',args)
52
+ if (!(result_obj['error'] == true))
53
+ logger.info("Successfully deleted resource #{@name}")
54
+ else
55
+ logger.info("CloudStack error while deleting resource #{@name}")
56
+ end
57
+ else
58
+ logger.info("Resource not created in CloudStack. Skipping delete...")
59
+ end
60
+ rescue Exception => e
61
+ logger.error("Unable to delete resorce #{@name}")
62
+ end
63
+ end
64
+
65
+ def on_workitem
66
+ @name = workitem.participant_name
67
+ @props = workitem['Resources'][@name]['Properties']
68
+ @props.downcase_key
69
+ @resolved_names = workitem['ResolvedNames']
70
+ if workitem['params']['operation'] == 'create'
71
+ create
72
+ else
73
+ delete
74
+ end
75
+ reply
76
+ end
77
+
78
+ def get_s2scustomergatewayid
79
+ resolved_s2scustomergatewayid = get_resolved(@props["s2scustomergatewayid"],workitem)
80
+ if resolved_s2scustomergatewayid.nil? || !validate_param(resolved_s2scustomergatewayid,"uuid")
81
+ raise "Missing mandatory parameter s2scustomergatewayid for resource #{@name}"
82
+ end
83
+ resolved_s2scustomergatewayid
84
+ end
85
+
86
+ def get_s2svpngatewayid
87
+ resolved_s2svpngatewayid = get_resolved(@props["s2svpngatewayid"],workitem)
88
+ if resolved_s2svpngatewayid.nil? || !validate_param(resolved_s2svpngatewayid,"uuid")
89
+ raise "Missing mandatory parameter s2svpngatewayid for resource #{@name}"
90
+ end
91
+ resolved_s2svpngatewayid
92
+ end
93
+ end
94
+ end
95
+