From 09d033212848a48f2248ce9678e7b29e4c37ea92 Mon Sep 17 00:00:00 2001 From: hequn Date: Wed, 16 Nov 2016 10:26:40 +0800 Subject: [PATCH] Modified some method in ecs driver 1, Increase the parameters `zone` at create_node method for specify the zone of new node 2, Increase the parameters `security_group_name` at ex_create_security_group method for specify the name of new security group. --- libcloud/compute/drivers/ecs.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libcloud/compute/drivers/ecs.py b/libcloud/compute/drivers/ecs.py index 03105ca084..658df41d74 100644 --- a/libcloud/compute/drivers/ecs.py +++ b/libcloud/compute/drivers/ecs.py @@ -569,7 +569,7 @@ def list_locations(self): locations = [self._to_location(each) for each in location_elements] return locations - def create_node(self, name, size, image, auth=None, + def create_node(self, name, size, image, auth=None, zone=None, ex_security_group_id=None, ex_description=None, ex_internet_charge_type=None, ex_internet_max_bandwidth_out=None, @@ -594,6 +594,9 @@ def create_node(self, name, size, image, auth=None, (optional) :type auth: :class:`NodeAuthSSHKey` or :class:`NodeAuthPassword` + :param zone: The zone for this new node. + :type zone: ``str`` + :keyword ex_security_group_id: The id of the security group the new created node is attached to. (required) @@ -672,6 +675,9 @@ def create_node(self, name, size, image, auth=None, auth = self._get_and_check_auth(auth) params['Password'] = auth.password + if zone: + params['ZoneId'] = zone + if ex_io_optimized is not None: optimized = ex_io_optimized if isinstance(optimized, bool): @@ -785,7 +791,8 @@ def ex_stop_node(self, node, ex_force_stop=False): return resp.success() and \ self._wait_until_state([node], NodeState.STOPPED) - def ex_create_security_group(self, description=None, client_token=None): + def ex_create_security_group(self, description=None, client_token=None, + security_group_name=None): """ Create a new security group. @@ -795,6 +802,9 @@ def ex_create_security_group(self, description=None, client_token=None): :keyword client_token: a token generated by client to identify each request. :type client_token: ``str`` + + :keyword security_group_name: security group name + :type security_group_name: ``str`` """ params = {'Action': 'CreateSecurityGroup', 'RegionId': self.region} @@ -803,6 +813,8 @@ def ex_create_security_group(self, description=None, client_token=None): params['Description'] = description if client_token: params['ClientToken'] = client_token + if security_group_name: + params['SecurityGroupName'] = security_group_name resp = self.connection.request(self.path, params) return findtext(resp.object, 'SecurityGroupId', namespace=self.namespace)