Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

Commit

Permalink
issue fix: handling correctly the VPC independent security groups (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
hodigy committed Mar 7, 2017
1 parent 7af6e7c commit d20736d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions otcclient/plugins/ecs/ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,16 +632,16 @@ def create_network_interface():
args = [
arg( '--vpc-name', dest='VPCNAME', help='Name of the VPC reference will use during VM creation'),
arg( '--vpc-id', dest='VPCID', help='Id of the VPC will use during VM creation'),
arg( '--group-names', dest='SECUGROUPNAME', help='Name of the security group'),
arg( '--security-group-ids', dest='SECUGROUP', help='Id of the security group')
arg( '--group-names', dest='SECUGROUPNAME', help='Name of the security group')
])
def create_security_group():
if not (OtcConfig.VPCNAME is None):
ecs.convertVPCNameToId()

REQ_CREATE_SECGROUP = "{ \"security_group\": { \"name\":\"" + OtcConfig.SECUGROUPNAME + "\", \"vpc_id\" : \"" + OtcConfig.VPCID + "\" } }"
url = "https://" + OtcConfig.DEFAULT_HOST+ "/v1/" + OtcConfig.PROJECT_ID + "/security-groups"
ret = utils_http.post(url, REQ_CREATE_SECGROUP)
req = utils_templates.create_request("add_sg")

url = "https://" + OtcConfig.DEFAULT_HOST+ "/v2/" + OtcConfig.PROJECT_ID + "/os-security-groups"
ret = utils_http.post(url, req)
return ret

@staticmethod
Expand Down
6 changes: 6 additions & 0 deletions otcclient/plugins/ecs/templates/add_sg.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ "security_group": { "name": "{{SECUGROUPNAME}}"
{% if VPCID %}
,"vpc_id": "{{VPCID}}"
{% endif %}

}}

0 comments on commit d20736d

Please sign in to comment.