Skip to content

Commit e03233c

Browse files
authored
Merge pull request #7 from ribeiro-rodrigo/feature/lb_globo_create
Feature/lb globo create
2 parents b33559c + 392d50c commit e03233c

File tree

5 files changed

+114
-3
lines changed

5 files changed

+114
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ url: http://localhost:8080/client/api
4444
* `lb_list_members` - list members from a LoadBalancer
4545
* `lb_attach_member` - Assigns virtual machine or a list of virtual machines to a load balancer
4646
* `lb_dettach_member` - Removes a virtual machine or a list of virtual machines from a load balancer
47+
* `lb_globo_create` - Creates a load balancer Globo
4748

4849
### AutoScale
4950
* `listAutoScaleVmGroups` - list listAutoScaleVmGroups

actions/lb_dettach_member.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ parameters:
2626
vm_ids:
2727
type: array
2828
description: Array of ID members atach LoadBalancer to retrieve members.
29-
required: true
29+
required: true

actions/lb_globo_create.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
3+
from lib.cloudstack import CloudStackAPI
4+
5+
__all__ = [
6+
'LBGloboCreate'
7+
]
8+
9+
10+
class LBGloboCreate(CloudStackAPI):
11+
def run(self, url, apikey, secretkey, name, algorithm, publicport,
12+
privateport, projectid, openfirewall, networkid,
13+
additionalportmap, healthchecktype, healthcheckrequest,
14+
expectedhealthcheck, lbenvironmentid, timeoutrequest):
15+
16+
cs = self.get_client(url, apikey, secretkey, timeout=timeoutrequest)
17+
18+
return cs.createGloboLoadBalancer(
19+
algorithm=algorithm,
20+
name=name,
21+
publicport=publicport,
22+
projectid=projectid,
23+
privateport=privateport,
24+
openfirewall=str(openfirewall),
25+
networkid=networkid,
26+
additionalportmap=additionalportmap,
27+
healthcheckType=healthchecktype,
28+
healthcheckrequest=healthcheckrequest,
29+
expectedhealthcheck=expectedhealthcheck,
30+
lbenvironmentid=str(lbenvironmentid)
31+
)

actions/lb_globo_create.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
name: lb_globo_create
3+
runner_type: python-script
4+
description: Create Globo LoadBalancer
5+
enabled: true
6+
entry_point: lb_globo_create.py
7+
parameters:
8+
url:
9+
type: string
10+
description: URL to use at ACS request
11+
required: false
12+
apikey:
13+
type: string
14+
description: API KEY to use at ACS request
15+
required: true
16+
secret: true
17+
secretkey:
18+
type: string
19+
description: Secret KEY to use at ACS request
20+
required: true
21+
secret: true
22+
name:
23+
type: string
24+
description: name of the load balancer
25+
required: true
26+
algorithm:
27+
type: string
28+
description: load balancer algorithm (source, roundrobin, leastconn)
29+
required: true
30+
publicport:
31+
type: integer
32+
description: the public port from where the network traffic will be load balanced from
33+
required: true
34+
privateport:
35+
type: integer
36+
description: the private port of the private IP address/virtual machine where the network traffic will be load balanced to
37+
required: true
38+
projectid:
39+
type: string
40+
description: id of the project to which the loadbalancer belongs
41+
required: true
42+
openfirewall:
43+
type: boolean
44+
description: id of the project to which the loadbalancer belongs
45+
default: false
46+
required: false
47+
networkid:
48+
type: string
49+
description: The guest network this rule will be created for. Required when public Ip address is not associated with any Guest network yet (VPC case)
50+
required: true
51+
additionalportmap:
52+
type: string
53+
description: "Addional port map (pattern sample: 80:80)"
54+
required: false
55+
healthchecktype:
56+
type: string
57+
description: "Heath check protocol (example: HTTP, TCP)"
58+
required: false
59+
default: HTTP
60+
healthcheckrequest:
61+
type: string
62+
description: "Path health check request (example: /healthcheck.html)"
63+
required: false
64+
default: "/"
65+
expectedhealthcheck:
66+
type: string
67+
description: "Expected health check (example: 200 ok)"
68+
required: false
69+
default: "200 OK"
70+
lbenvironmentid:
71+
type: integer
72+
description: "Load balancer environment id"
73+
required: true
74+
timeoutrequest:
75+
type: integer
76+
description: Timeout request in seconds
77+
required: false
78+
default: 35

actions/lib/cloudstack.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CloudStackAPI(Action):
1212
def __init__(self, config):
1313
super(CloudStackAPI, self).__init__(config=config)
1414

15-
def get_client(self, url, apikey, secretkey):
15+
def get_client(self, url, apikey, secretkey, timeout=10):
1616
url_temp = self.config.get('url')
1717

1818
if url != "" and url is not None:
@@ -23,5 +23,6 @@ def get_client(self, url, apikey, secretkey):
2323
secret=secretkey,
2424
dangerous_no_tls_verify=True,
2525
fetch_result=True,
26-
method='POST')
26+
method='POST',
27+
timeout=timeout)
2728
return cs

0 commit comments

Comments
 (0)