stackmate 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,113 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackSnapshot < 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['volumeid'] = get_volumeid
|
16
|
+
args['domainid'] = get_domainid if @props.has_key?('domainid')
|
17
|
+
args['account'] = get_account if @props.has_key?('account')
|
18
|
+
args['policyid'] = get_policyid if @props.has_key?('policyid')
|
19
|
+
|
20
|
+
logger.info("Creating resource #{@name} with following arguments")
|
21
|
+
p args
|
22
|
+
result_obj = make_async_request('createSnapshot',args)
|
23
|
+
resource_obj = result_obj['Snapshot'.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'],"Snapshot") 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 . Cleaning up the stack")
|
38
|
+
raise nme
|
39
|
+
rescue Exception => e
|
40
|
+
logger.error(e.message)
|
41
|
+
raise e
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete
|
47
|
+
logger.debug("Deleting resource #{@name}")
|
48
|
+
begin
|
49
|
+
physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
|
50
|
+
if(!physical_id.nil?)
|
51
|
+
args = {'id' => physical_id
|
52
|
+
}
|
53
|
+
result_obj = make_async_request('deleteSnapshot',args)
|
54
|
+
if (!(result_obj['error'] == true))
|
55
|
+
logger.info("Successfully deleted resource #{@name}")
|
56
|
+
else
|
57
|
+
logger.info("CloudStack error while deleting resource #{@name}")
|
58
|
+
end
|
59
|
+
else
|
60
|
+
logger.info("Resource not created in CloudStack. Skipping delete...")
|
61
|
+
end
|
62
|
+
rescue Exception => e
|
63
|
+
logger.error("Unable to delete resorce #{@name}")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def on_workitem
|
68
|
+
@name = workitem.participant_name
|
69
|
+
@props = workitem['Resources'][@name]['Properties']
|
70
|
+
@props.downcase_key
|
71
|
+
@resolved_names = workitem['ResolvedNames']
|
72
|
+
if workitem['params']['operation'] == 'create'
|
73
|
+
create
|
74
|
+
else
|
75
|
+
delete
|
76
|
+
end
|
77
|
+
reply
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_volumeid
|
81
|
+
resolved_volumeid = get_resolved(@props["volumeid"],workitem)
|
82
|
+
if resolved_volumeid.nil? || !validate_param(resolved_volumeid,"uuid")
|
83
|
+
raise "Missing mandatory parameter volumeid for resource #{@name}"
|
84
|
+
end
|
85
|
+
resolved_volumeid
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_domainid
|
89
|
+
resolved_domainid = get_resolved(@props['domainid'],workitem)
|
90
|
+
if resolved_domainid.nil? || !validate_param(resolved_domainid,"uuid")
|
91
|
+
raise "Malformed optional parameter domainid for resource #{@name}"
|
92
|
+
end
|
93
|
+
resolved_domainid
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_account
|
97
|
+
resolved_account = get_resolved(@props['account'],workitem)
|
98
|
+
if resolved_account.nil? || !validate_param(resolved_account,"string")
|
99
|
+
raise "Malformed optional parameter account for resource #{@name}"
|
100
|
+
end
|
101
|
+
resolved_account
|
102
|
+
end
|
103
|
+
|
104
|
+
def get_policyid
|
105
|
+
resolved_policyid = get_resolved(@props['policyid'],workitem)
|
106
|
+
if resolved_policyid.nil? || !validate_param(resolved_policyid,"uuid")
|
107
|
+
raise "Malformed optional parameter policyid for resource #{@name}"
|
108
|
+
end
|
109
|
+
resolved_policyid
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackSnapshotPolicy < 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['volumeid'] = get_volumeid
|
16
|
+
args['maxsnaps'] = get_maxsnaps
|
17
|
+
args['schedule'] = get_schedule
|
18
|
+
args['intervaltype'] = get_intervaltype
|
19
|
+
args['timezone'] = get_timezone
|
20
|
+
|
21
|
+
logger.info("Creating resource #{@name} with following arguments")
|
22
|
+
p args
|
23
|
+
result_obj = make_sync_request('createSnapshotPolicy',args)
|
24
|
+
resource_obj = result_obj['SnapshotPolicy'.downcase]
|
25
|
+
#doing it this way since it is easier to change later, rather than cloning whole object
|
26
|
+
resource_obj.each_key do |k|
|
27
|
+
val = resource_obj[k]
|
28
|
+
if('id'.eql?(k))
|
29
|
+
k = 'physical_id'
|
30
|
+
end
|
31
|
+
workitem[@name][k] = val
|
32
|
+
end
|
33
|
+
set_tags(@props['tags'],workitem[@name]['physical_id'],"SnapshotPolicy") if @props.has_key?('tags')
|
34
|
+
workitem['ResolvedNames'][@name] = name_cs
|
35
|
+
workitem['IdMap'][workitem[@name]['physical_id']] = @name
|
36
|
+
|
37
|
+
rescue NoMethodError => nme
|
38
|
+
logger.error("Create request failed for resource . Cleaning up the stack")
|
39
|
+
raise nme
|
40
|
+
rescue Exception => e
|
41
|
+
logger.error(e.message)
|
42
|
+
raise e
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete
|
48
|
+
logger.debug("Deleting resource #{@name}")
|
49
|
+
begin
|
50
|
+
physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
|
51
|
+
if(!physical_id.nil?)
|
52
|
+
args = {'id' => physical_id
|
53
|
+
}
|
54
|
+
result_obj = make_sync_request('deleteSnapshotPolicy',args)
|
55
|
+
if (!(result_obj['error'] == true))
|
56
|
+
logger.info("Successfully deleted resource #{@name}")
|
57
|
+
else
|
58
|
+
logger.info("CloudStack error while deleting resource #{@name}")
|
59
|
+
end
|
60
|
+
else
|
61
|
+
logger.info("Resource not created in CloudStack. Skipping delete...")
|
62
|
+
end
|
63
|
+
rescue Exception => e
|
64
|
+
logger.error("Unable to delete resorce #{@name}")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def on_workitem
|
69
|
+
@name = workitem.participant_name
|
70
|
+
@props = workitem['Resources'][@name]['Properties']
|
71
|
+
@props.downcase_key
|
72
|
+
@resolved_names = workitem['ResolvedNames']
|
73
|
+
if workitem['params']['operation'] == 'create'
|
74
|
+
create
|
75
|
+
else
|
76
|
+
delete
|
77
|
+
end
|
78
|
+
reply
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_volumeid
|
82
|
+
resolved_volumeid = get_resolved(@props["volumeid"],workitem)
|
83
|
+
if resolved_volumeid.nil? || !validate_param(resolved_volumeid,"uuid")
|
84
|
+
raise "Missing mandatory parameter volumeid for resource #{@name}"
|
85
|
+
end
|
86
|
+
resolved_volumeid
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_maxsnaps
|
90
|
+
resolved_maxsnaps = get_resolved(@props["maxsnaps"],workitem)
|
91
|
+
if resolved_maxsnaps.nil? || !validate_param(resolved_maxsnaps,"integer")
|
92
|
+
raise "Missing mandatory parameter maxsnaps for resource #{@name}"
|
93
|
+
end
|
94
|
+
resolved_maxsnaps
|
95
|
+
end
|
96
|
+
|
97
|
+
def get_schedule
|
98
|
+
resolved_schedule = get_resolved(@props["schedule"],workitem)
|
99
|
+
if resolved_schedule.nil? || !validate_param(resolved_schedule,"string")
|
100
|
+
raise "Missing mandatory parameter schedule for resource #{@name}"
|
101
|
+
end
|
102
|
+
resolved_schedule
|
103
|
+
end
|
104
|
+
|
105
|
+
def get_intervaltype
|
106
|
+
resolved_intervaltype = get_resolved(@props["intervaltype"],workitem)
|
107
|
+
if resolved_intervaltype.nil? || !validate_param(resolved_intervaltype,"string")
|
108
|
+
raise "Missing mandatory parameter intervaltype for resource #{@name}"
|
109
|
+
end
|
110
|
+
resolved_intervaltype
|
111
|
+
end
|
112
|
+
|
113
|
+
def get_timezone
|
114
|
+
resolved_timezone = get_resolved(@props["timezone"],workitem)
|
115
|
+
if resolved_timezone.nil? || !validate_param(resolved_timezone,"string")
|
116
|
+
raise "Missing mandatory parameter timezone for resource #{@name}"
|
117
|
+
end
|
118
|
+
resolved_timezone
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackSSHKeyPair < 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['account'] = get_account if @props.has_key?('account')
|
17
|
+
args['domainid'] = get_domainid if @props.has_key?('domainid')
|
18
|
+
args['projectid'] = get_projectid if @props.has_key?('projectid')
|
19
|
+
|
20
|
+
logger.info("Creating resource #{@name} with following arguments")
|
21
|
+
p args
|
22
|
+
result_obj = make_sync_request('createSSHKeyPair',args)
|
23
|
+
resource_obj = result_obj['SSHKeyPair'.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'],"SSHKeyPair") 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 . Cleaning up the stack")
|
38
|
+
raise nme
|
39
|
+
rescue Exception => e
|
40
|
+
logger.error(e.message)
|
41
|
+
raise e
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete
|
47
|
+
logger.debug("Deleting resource #{@name}")
|
48
|
+
begin
|
49
|
+
physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
|
50
|
+
if(!physical_id.nil?)
|
51
|
+
args = {'name' => physical_id
|
52
|
+
}
|
53
|
+
result_obj = make_sync_request('deleteSSHKeyPair',args)
|
54
|
+
if (!(result_obj['error'] == true))
|
55
|
+
logger.info("Successfully deleted resource #{@name}")
|
56
|
+
else
|
57
|
+
logger.info("CloudStack error while deleting resource #{@name}")
|
58
|
+
end
|
59
|
+
else
|
60
|
+
logger.info("Resource not created in CloudStack. Skipping delete...")
|
61
|
+
end
|
62
|
+
rescue Exception => e
|
63
|
+
logger.error("Unable to delete resorce #{@name}")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def on_workitem
|
68
|
+
@name = workitem.participant_name
|
69
|
+
@props = workitem['Resources'][@name]['Properties']
|
70
|
+
@props.downcase_key
|
71
|
+
@resolved_names = workitem['ResolvedNames']
|
72
|
+
if workitem['params']['operation'] == 'create'
|
73
|
+
create
|
74
|
+
else
|
75
|
+
delete
|
76
|
+
end
|
77
|
+
reply
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_name
|
81
|
+
resolved_name = get_resolved(@props["name"],workitem)
|
82
|
+
if resolved_name.nil? || !validate_param(resolved_name,"string")
|
83
|
+
raise "Missing mandatory parameter name for resource #{@name}"
|
84
|
+
end
|
85
|
+
resolved_name
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_account
|
89
|
+
resolved_account = get_resolved(@props['account'],workitem)
|
90
|
+
if resolved_account.nil? || !validate_param(resolved_account,"string")
|
91
|
+
raise "Malformed optional parameter account for resource #{@name}"
|
92
|
+
end
|
93
|
+
resolved_account
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_domainid
|
97
|
+
resolved_domainid = get_resolved(@props['domainid'],workitem)
|
98
|
+
if resolved_domainid.nil? || !validate_param(resolved_domainid,"uuid")
|
99
|
+
raise "Malformed optional parameter domainid for resource #{@name}"
|
100
|
+
end
|
101
|
+
resolved_domainid
|
102
|
+
end
|
103
|
+
|
104
|
+
def get_projectid
|
105
|
+
resolved_projectid = get_resolved(@props['projectid'],workitem)
|
106
|
+
if resolved_projectid.nil? || !validate_param(resolved_projectid,"uuid")
|
107
|
+
raise "Malformed optional parameter projectid for resource #{@name}"
|
108
|
+
end
|
109
|
+
resolved_projectid
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackStaticNat < 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['ipaddressid'] = get_ipaddressid
|
16
|
+
args['virtualmachineid'] = get_virtualmachineid
|
17
|
+
args['networkid'] = get_networkid if @props.has_key?('networkid')
|
18
|
+
args['vmguestip'] = get_vmguestip if @props.has_key?('vmguestip')
|
19
|
+
|
20
|
+
logger.info("Creating resource #{@name} with following arguments")
|
21
|
+
p args
|
22
|
+
result_obj = make_sync_request('enableStaticNat',args)
|
23
|
+
resource_obj = result_obj['StaticNat'.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'],"StaticNat") 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 . Cleaning up the stack")
|
38
|
+
raise nme
|
39
|
+
rescue Exception => e
|
40
|
+
logger.error(e.message)
|
41
|
+
raise e
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete
|
47
|
+
logger.debug("Deleting resource #{@name}")
|
48
|
+
begin
|
49
|
+
physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
|
50
|
+
if(!physical_id.nil?)
|
51
|
+
args = {'ipaddressid' => physical_id
|
52
|
+
}
|
53
|
+
result_obj = make_async_request('disableStaticNat',args)
|
54
|
+
if (!(result_obj['error'] == true))
|
55
|
+
logger.info("Successfully deleted resource #{@name}")
|
56
|
+
else
|
57
|
+
logger.info("CloudStack error while deleting resource #{@name}")
|
58
|
+
end
|
59
|
+
else
|
60
|
+
logger.info("Resource not created in CloudStack. Skipping delete...")
|
61
|
+
end
|
62
|
+
rescue Exception => e
|
63
|
+
logger.error("Unable to delete resorce #{@name}")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def on_workitem
|
68
|
+
@name = workitem.participant_name
|
69
|
+
@props = workitem['Resources'][@name]['Properties']
|
70
|
+
@props.downcase_key
|
71
|
+
@resolved_names = workitem['ResolvedNames']
|
72
|
+
if workitem['params']['operation'] == 'create'
|
73
|
+
create
|
74
|
+
else
|
75
|
+
delete
|
76
|
+
end
|
77
|
+
reply
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_ipaddressid
|
81
|
+
resolved_ipaddressid = get_resolved(@props["ipaddressid"],workitem)
|
82
|
+
if resolved_ipaddressid.nil? || !validate_param(resolved_ipaddressid,"uuid")
|
83
|
+
raise "Missing mandatory parameter ipaddressid for resource #{@name}"
|
84
|
+
end
|
85
|
+
resolved_ipaddressid
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_virtualmachineid
|
89
|
+
resolved_virtualmachineid = get_resolved(@props["virtualmachineid"],workitem)
|
90
|
+
if resolved_virtualmachineid.nil? || !validate_param(resolved_virtualmachineid,"uuid")
|
91
|
+
raise "Missing mandatory parameter virtualmachineid for resource #{@name}"
|
92
|
+
end
|
93
|
+
resolved_virtualmachineid
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_networkid
|
97
|
+
resolved_networkid = get_resolved(@props['networkid'],workitem)
|
98
|
+
if resolved_networkid.nil? || !validate_param(resolved_networkid,"uuid")
|
99
|
+
raise "Malformed optional parameter networkid for resource #{@name}"
|
100
|
+
end
|
101
|
+
resolved_networkid
|
102
|
+
end
|
103
|
+
|
104
|
+
def get_vmguestip
|
105
|
+
resolved_vmguestip = get_resolved(@props['vmguestip'],workitem)
|
106
|
+
if resolved_vmguestip.nil? || !validate_param(resolved_vmguestip,"string")
|
107
|
+
raise "Malformed optional parameter vmguestip for resource #{@name}"
|
108
|
+
end
|
109
|
+
resolved_vmguestip
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackStaticRoute < 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['gatewayid'] = get_gatewayid
|
16
|
+
args['cidr'] = get_cidr
|
17
|
+
|
18
|
+
logger.info("Creating resource #{@name} with following arguments")
|
19
|
+
p args
|
20
|
+
result_obj = make_async_request('createStaticRoute',args)
|
21
|
+
resource_obj = result_obj['StaticRoute'.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'],"StaticRoute") 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('deleteStaticRoute',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_gatewayid
|
79
|
+
resolved_gatewayid = get_resolved(@props["gatewayid"],workitem)
|
80
|
+
if resolved_gatewayid.nil? || !validate_param(resolved_gatewayid,"uuid")
|
81
|
+
raise "Missing mandatory parameter gatewayid for resource #{@name}"
|
82
|
+
end
|
83
|
+
resolved_gatewayid
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_cidr
|
87
|
+
resolved_cidr = get_resolved(@props["cidr"],workitem)
|
88
|
+
if resolved_cidr.nil? || !validate_param(resolved_cidr,"string")
|
89
|
+
raise "Missing mandatory parameter cidr for resource #{@name}"
|
90
|
+
end
|
91
|
+
resolved_cidr
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackTags < 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['resourceids'] = get_resourceids
|
16
|
+
args['tags'] = get_tags
|
17
|
+
args['resourcetype'] = get_resourcetype
|
18
|
+
args['customer'] = get_customer if @props.has_key?('customer')
|
19
|
+
|
20
|
+
logger.info("Creating resource #{@name} with following arguments")
|
21
|
+
p args
|
22
|
+
result_obj = make_async_request('createTags',args)
|
23
|
+
resource_obj = result_obj['Tags'.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'],"Tags") 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 . Cleaning up the stack")
|
38
|
+
raise nme
|
39
|
+
rescue Exception => e
|
40
|
+
logger.error(e.message)
|
41
|
+
raise e
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete
|
47
|
+
logger.debug("Deleting resource #{@name}")
|
48
|
+
begin
|
49
|
+
physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
|
50
|
+
if(!physical_id.nil?)
|
51
|
+
args = {'resourcetype' => physical_id
|
52
|
+
}
|
53
|
+
result_obj = make_async_request('deleteTags',args)
|
54
|
+
if (!(result_obj['error'] == true))
|
55
|
+
logger.info("Successfully deleted resource #{@name}")
|
56
|
+
else
|
57
|
+
logger.info("CloudStack error while deleting resource #{@name}")
|
58
|
+
end
|
59
|
+
else
|
60
|
+
logger.info("Resource not created in CloudStack. Skipping delete...")
|
61
|
+
end
|
62
|
+
rescue Exception => e
|
63
|
+
logger.error("Unable to delete resorce #{@name}")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def on_workitem
|
68
|
+
@name = workitem.participant_name
|
69
|
+
@props = workitem['Resources'][@name]['Properties']
|
70
|
+
@props.downcase_key
|
71
|
+
@resolved_names = workitem['ResolvedNames']
|
72
|
+
if workitem['params']['operation'] == 'create'
|
73
|
+
create
|
74
|
+
else
|
75
|
+
delete
|
76
|
+
end
|
77
|
+
reply
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_resourceids
|
81
|
+
resolved_resourceids = get_resolved(@props["resourceids"],workitem)
|
82
|
+
if resolved_resourceids.nil? || !validate_param(resolved_resourceids,"list")
|
83
|
+
raise "Missing mandatory parameter resourceids for resource #{@name}"
|
84
|
+
end
|
85
|
+
resolved_resourceids
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_tags
|
89
|
+
resolved_tags = get_resolved(@props["tags"],workitem)
|
90
|
+
if resolved_tags.nil? || !validate_param(resolved_tags,"map")
|
91
|
+
raise "Missing mandatory parameter tags for resource #{@name}"
|
92
|
+
end
|
93
|
+
resolved_tags
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_resourcetype
|
97
|
+
resolved_resourcetype = get_resolved(@props["resourcetype"],workitem)
|
98
|
+
if resolved_resourcetype.nil? || !validate_param(resolved_resourcetype,"string")
|
99
|
+
raise "Missing mandatory parameter resourcetype for resource #{@name}"
|
100
|
+
end
|
101
|
+
resolved_resourcetype
|
102
|
+
end
|
103
|
+
|
104
|
+
def get_customer
|
105
|
+
resolved_customer = get_resolved(@props['customer'],workitem)
|
106
|
+
if resolved_customer.nil? || !validate_param(resolved_customer,"string")
|
107
|
+
raise "Malformed optional parameter customer for resource #{@name}"
|
108
|
+
end
|
109
|
+
resolved_customer
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|