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,131 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackIpForwardingRule < 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['protocol'] = get_protocol
|
17
|
+
args['startport'] = get_startport
|
18
|
+
args['cidrlist'] = get_cidrlist if @props.has_key?('cidrlist')
|
19
|
+
args['endport'] = get_endport if @props.has_key?('endport')
|
20
|
+
args['openfirewall'] = get_openfirewall if @props.has_key?('openfirewall')
|
21
|
+
|
22
|
+
logger.info("Creating resource #{@name} with following arguments")
|
23
|
+
p args
|
24
|
+
result_obj = make_async_request('createIpForwardingRule',args)
|
25
|
+
resource_obj = result_obj['IpForwardingRule'.downcase]
|
26
|
+
#doing it this way since it is easier to change later, rather than cloning whole object
|
27
|
+
resource_obj.each_key do |k|
|
28
|
+
val = resource_obj[k]
|
29
|
+
if('id'.eql?(k))
|
30
|
+
k = 'physical_id'
|
31
|
+
end
|
32
|
+
workitem[@name][k] = val
|
33
|
+
end
|
34
|
+
set_tags(@props['tags'],workitem[@name]['physical_id'],"IpForwardingRule") if @props.has_key?('tags')
|
35
|
+
workitem['ResolvedNames'][@name] = name_cs
|
36
|
+
workitem['IdMap'][workitem[@name]['physical_id']] = @name
|
37
|
+
|
38
|
+
rescue NoMethodError => nme
|
39
|
+
logger.error("Create request failed for resource . Cleaning up the stack")
|
40
|
+
raise nme
|
41
|
+
rescue Exception => e
|
42
|
+
logger.error(e.message)
|
43
|
+
raise e
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
def delete
|
49
|
+
logger.debug("Deleting resource #{@name}")
|
50
|
+
begin
|
51
|
+
physical_id = workitem[@name]['physical_id'] if !workitem[@name].nil?
|
52
|
+
if(!physical_id.nil?)
|
53
|
+
args = {'id' => physical_id
|
54
|
+
}
|
55
|
+
result_obj = make_async_request('deleteIpForwardingRule',args)
|
56
|
+
if (!(result_obj['error'] == true))
|
57
|
+
logger.info("Successfully deleted resource #{@name}")
|
58
|
+
else
|
59
|
+
logger.info("CloudStack error while deleting resource #{@name}")
|
60
|
+
end
|
61
|
+
else
|
62
|
+
logger.info("Resource not created in CloudStack. Skipping delete...")
|
63
|
+
end
|
64
|
+
rescue Exception => e
|
65
|
+
logger.error("Unable to delete resorce #{@name}")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def on_workitem
|
70
|
+
@name = workitem.participant_name
|
71
|
+
@props = workitem['Resources'][@name]['Properties']
|
72
|
+
@props.downcase_key
|
73
|
+
@resolved_names = workitem['ResolvedNames']
|
74
|
+
if workitem['params']['operation'] == 'create'
|
75
|
+
create
|
76
|
+
else
|
77
|
+
delete
|
78
|
+
end
|
79
|
+
reply
|
80
|
+
end
|
81
|
+
|
82
|
+
def get_ipaddressid
|
83
|
+
resolved_ipaddressid = get_resolved(@props["ipaddressid"],workitem)
|
84
|
+
if resolved_ipaddressid.nil? || !validate_param(resolved_ipaddressid,"uuid")
|
85
|
+
raise "Missing mandatory parameter ipaddressid for resource #{@name}"
|
86
|
+
end
|
87
|
+
resolved_ipaddressid
|
88
|
+
end
|
89
|
+
|
90
|
+
def get_protocol
|
91
|
+
resolved_protocol = get_resolved(@props["protocol"],workitem)
|
92
|
+
if resolved_protocol.nil? || !validate_param(resolved_protocol,"string")
|
93
|
+
raise "Missing mandatory parameter protocol for resource #{@name}"
|
94
|
+
end
|
95
|
+
resolved_protocol
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_startport
|
99
|
+
resolved_startport = get_resolved(@props["startport"],workitem)
|
100
|
+
if resolved_startport.nil? || !validate_param(resolved_startport,"integer")
|
101
|
+
raise "Missing mandatory parameter startport for resource #{@name}"
|
102
|
+
end
|
103
|
+
resolved_startport
|
104
|
+
end
|
105
|
+
|
106
|
+
def get_cidrlist
|
107
|
+
resolved_cidrlist = get_resolved(@props['cidrlist'],workitem)
|
108
|
+
if resolved_cidrlist.nil? || !validate_param(resolved_cidrlist,"list")
|
109
|
+
raise "Malformed optional parameter cidrlist for resource #{@name}"
|
110
|
+
end
|
111
|
+
resolved_cidrlist
|
112
|
+
end
|
113
|
+
|
114
|
+
def get_endport
|
115
|
+
resolved_endport = get_resolved(@props['endport'],workitem)
|
116
|
+
if resolved_endport.nil? || !validate_param(resolved_endport,"integer")
|
117
|
+
raise "Malformed optional parameter endport for resource #{@name}"
|
118
|
+
end
|
119
|
+
resolved_endport
|
120
|
+
end
|
121
|
+
|
122
|
+
def get_openfirewall
|
123
|
+
resolved_openfirewall = get_resolved(@props['openfirewall'],workitem)
|
124
|
+
if resolved_openfirewall.nil? || !validate_param(resolved_openfirewall,"boolean")
|
125
|
+
raise "Malformed optional parameter openfirewall for resource #{@name}"
|
126
|
+
end
|
127
|
+
resolved_openfirewall
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackIpToNic < 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['nicid'] = get_nicid
|
16
|
+
args['ipaddress'] = get_ipaddress if @props.has_key?('ipaddress')
|
17
|
+
|
18
|
+
logger.info("Creating resource #{@name} with following arguments")
|
19
|
+
p args
|
20
|
+
result_obj = make_async_request('addIpToNic',args)
|
21
|
+
resource_obj = result_obj['IpToNic'.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'],"IpToNic") 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('removeIpToNic',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_nicid
|
79
|
+
resolved_nicid = get_resolved(@props["nicid"],workitem)
|
80
|
+
if resolved_nicid.nil? || !validate_param(resolved_nicid,"uuid")
|
81
|
+
raise "Missing mandatory parameter nicid for resource #{@name}"
|
82
|
+
end
|
83
|
+
resolved_nicid
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_ipaddress
|
87
|
+
resolved_ipaddress = get_resolved(@props['ipaddress'],workitem)
|
88
|
+
if resolved_ipaddress.nil? || !validate_param(resolved_ipaddress,"string")
|
89
|
+
raise "Malformed optional parameter ipaddress for resource #{@name}"
|
90
|
+
end
|
91
|
+
resolved_ipaddress
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackIso < 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['id'] = get_id
|
16
|
+
args['virtualmachineid'] = get_virtualmachineid
|
17
|
+
|
18
|
+
logger.info("Creating resource #{@name} with following arguments")
|
19
|
+
p args
|
20
|
+
result_obj = make_async_request('attachIso',args)
|
21
|
+
resource_obj = result_obj['Iso'.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'],"Iso") 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 = {'virtualmachineid' => physical_id
|
50
|
+
}
|
51
|
+
result_obj = make_async_request('detachIso',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_id
|
79
|
+
resolved_id = get_resolved(@props["id"],workitem)
|
80
|
+
if resolved_id.nil? || !validate_param(resolved_id,"uuid")
|
81
|
+
raise "Missing mandatory parameter id for resource #{@name}"
|
82
|
+
end
|
83
|
+
resolved_id
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_virtualmachineid
|
87
|
+
resolved_virtualmachineid = get_resolved(@props["virtualmachineid"],workitem)
|
88
|
+
if resolved_virtualmachineid.nil? || !validate_param(resolved_virtualmachineid,"uuid")
|
89
|
+
raise "Missing mandatory parameter virtualmachineid for resource #{@name}"
|
90
|
+
end
|
91
|
+
resolved_virtualmachineid
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackLBHealthCheckPolicy < 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['lbruleid'] = get_lbruleid
|
16
|
+
args['responsetimeout'] = get_responsetimeout if @props.has_key?('responsetimeout')
|
17
|
+
args['unhealthythreshold'] = get_unhealthythreshold if @props.has_key?('unhealthythreshold')
|
18
|
+
args['pingpath'] = get_pingpath if @props.has_key?('pingpath')
|
19
|
+
args['description'] = get_description if @props.has_key?('description')
|
20
|
+
args['intervaltime'] = get_intervaltime if @props.has_key?('intervaltime')
|
21
|
+
args['healthythreshold'] = get_healthythreshold if @props.has_key?('healthythreshold')
|
22
|
+
|
23
|
+
logger.info("Creating resource #{@name} with following arguments")
|
24
|
+
p args
|
25
|
+
result_obj = make_async_request('createLBHealthCheckPolicy',args)
|
26
|
+
resource_obj = result_obj['LBHealthCheckPolicy'.downcase]
|
27
|
+
#doing it this way since it is easier to change later, rather than cloning whole object
|
28
|
+
resource_obj.each_key do |k|
|
29
|
+
val = resource_obj[k]
|
30
|
+
if('id'.eql?(k))
|
31
|
+
k = 'physical_id'
|
32
|
+
end
|
33
|
+
workitem[@name][k] = val
|
34
|
+
end
|
35
|
+
set_tags(@props['tags'],workitem[@name]['physical_id'],"LBHealthCheckPolicy") if @props.has_key?('tags')
|
36
|
+
workitem['ResolvedNames'][@name] = name_cs
|
37
|
+
workitem['IdMap'][workitem[@name]['physical_id']] = @name
|
38
|
+
|
39
|
+
rescue NoMethodError => nme
|
40
|
+
logger.error("Create request failed for resource . Cleaning up the stack")
|
41
|
+
raise nme
|
42
|
+
rescue Exception => e
|
43
|
+
logger.error(e.message)
|
44
|
+
raise e
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
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('deleteLBHealthCheckPolicy',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
|
+
def get_lbruleid
|
84
|
+
resolved_lbruleid = get_resolved(@props["lbruleid"],workitem)
|
85
|
+
if resolved_lbruleid.nil? || !validate_param(resolved_lbruleid,"uuid")
|
86
|
+
raise "Missing mandatory parameter lbruleid for resource #{@name}"
|
87
|
+
end
|
88
|
+
resolved_lbruleid
|
89
|
+
end
|
90
|
+
|
91
|
+
def get_responsetimeout
|
92
|
+
resolved_responsetimeout = get_resolved(@props['responsetimeout'],workitem)
|
93
|
+
if resolved_responsetimeout.nil? || !validate_param(resolved_responsetimeout,"integer")
|
94
|
+
raise "Malformed optional parameter responsetimeout for resource #{@name}"
|
95
|
+
end
|
96
|
+
resolved_responsetimeout
|
97
|
+
end
|
98
|
+
|
99
|
+
def get_unhealthythreshold
|
100
|
+
resolved_unhealthythreshold = get_resolved(@props['unhealthythreshold'],workitem)
|
101
|
+
if resolved_unhealthythreshold.nil? || !validate_param(resolved_unhealthythreshold,"integer")
|
102
|
+
raise "Malformed optional parameter unhealthythreshold for resource #{@name}"
|
103
|
+
end
|
104
|
+
resolved_unhealthythreshold
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_pingpath
|
108
|
+
resolved_pingpath = get_resolved(@props['pingpath'],workitem)
|
109
|
+
if resolved_pingpath.nil? || !validate_param(resolved_pingpath,"string")
|
110
|
+
raise "Malformed optional parameter pingpath for resource #{@name}"
|
111
|
+
end
|
112
|
+
resolved_pingpath
|
113
|
+
end
|
114
|
+
|
115
|
+
def get_description
|
116
|
+
resolved_description = get_resolved(@props['description'],workitem)
|
117
|
+
if resolved_description.nil? || !validate_param(resolved_description,"string")
|
118
|
+
raise "Malformed optional parameter description for resource #{@name}"
|
119
|
+
end
|
120
|
+
resolved_description
|
121
|
+
end
|
122
|
+
|
123
|
+
def get_intervaltime
|
124
|
+
resolved_intervaltime = get_resolved(@props['intervaltime'],workitem)
|
125
|
+
if resolved_intervaltime.nil? || !validate_param(resolved_intervaltime,"integer")
|
126
|
+
raise "Malformed optional parameter intervaltime for resource #{@name}"
|
127
|
+
end
|
128
|
+
resolved_intervaltime
|
129
|
+
end
|
130
|
+
|
131
|
+
def get_healthythreshold
|
132
|
+
resolved_healthythreshold = get_resolved(@props['healthythreshold'],workitem)
|
133
|
+
if resolved_healthythreshold.nil? || !validate_param(resolved_healthythreshold,"integer")
|
134
|
+
raise "Malformed optional parameter healthythreshold for resource #{@name}"
|
135
|
+
end
|
136
|
+
resolved_healthythreshold
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'stackmate/participants/cloudstack'
|
2
|
+
|
3
|
+
module StackMate
|
4
|
+
class CloudStackLBStickinessPolicy < 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['methodname'] = get_methodname
|
16
|
+
args['lbruleid'] = get_lbruleid
|
17
|
+
args['name'] = workitem['StackName'] +'-' +get_name
|
18
|
+
args['param'] = get_param if @props.has_key?('param')
|
19
|
+
args['description'] = get_description if @props.has_key?('description')
|
20
|
+
|
21
|
+
logger.info("Creating resource #{@name} with following arguments")
|
22
|
+
p args
|
23
|
+
result_obj = make_async_request('createLBStickinessPolicy',args)
|
24
|
+
resource_obj = result_obj['LBStickinessPolicy'.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'],"LBStickinessPolicy") 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_async_request('deleteLBStickinessPolicy',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_methodname
|
82
|
+
resolved_methodname = get_resolved(@props["methodname"],workitem)
|
83
|
+
if resolved_methodname.nil? || !validate_param(resolved_methodname,"string")
|
84
|
+
raise "Missing mandatory parameter methodname for resource #{@name}"
|
85
|
+
end
|
86
|
+
resolved_methodname
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_lbruleid
|
90
|
+
resolved_lbruleid = get_resolved(@props["lbruleid"],workitem)
|
91
|
+
if resolved_lbruleid.nil? || !validate_param(resolved_lbruleid,"uuid")
|
92
|
+
raise "Missing mandatory parameter lbruleid for resource #{@name}"
|
93
|
+
end
|
94
|
+
resolved_lbruleid
|
95
|
+
end
|
96
|
+
|
97
|
+
def get_name
|
98
|
+
resolved_name = get_resolved(@props["name"],workitem)
|
99
|
+
if resolved_name.nil? || !validate_param(resolved_name,"string")
|
100
|
+
raise "Missing mandatory parameter name for resource #{@name}"
|
101
|
+
end
|
102
|
+
resolved_name
|
103
|
+
end
|
104
|
+
|
105
|
+
def get_param
|
106
|
+
resolved_param = get_resolved(@props['param'],workitem)
|
107
|
+
if resolved_param.nil? || !validate_param(resolved_param,"map")
|
108
|
+
raise "Malformed optional parameter param for resource #{@name}"
|
109
|
+
end
|
110
|
+
resolved_param
|
111
|
+
end
|
112
|
+
|
113
|
+
def get_description
|
114
|
+
resolved_description = get_resolved(@props['description'],workitem)
|
115
|
+
if resolved_description.nil? || !validate_param(resolved_description,"string")
|
116
|
+
raise "Malformed optional parameter description for resource #{@name}"
|
117
|
+
end
|
118
|
+
resolved_description
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|