rename to ex_create_security_group(self, description=None, client_token=None)
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/5edbb6a9 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/5edbb6a9 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/5edbb6a9 Branch: refs/heads/trunk Commit: 5edbb6a99e71231bc454b5f948739adc58cdd8d6 Parents: 1e5c631 Author: netgenius <wuhen...@otcaix.iscas.ac.cn> Authored: Sat Jun 11 17:36:53 2016 +0800 Committer: Anthony Shaw <anthonys...@apache.org> Committed: Fri Jun 24 13:50:17 2016 +1000 ---------------------------------------------------------------------- example_aliyun_ecs.py | 6 +++--- libcloud/compute/drivers/ecs.py | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/5edbb6a9/example_aliyun_ecs.py ---------------------------------------------------------------------- diff --git a/example_aliyun_ecs.py b/example_aliyun_ecs.py index 5c223c6..c7de072 100644 --- a/example_aliyun_ecs.py +++ b/example_aliyun_ecs.py @@ -54,10 +54,10 @@ print('Use image %s' % image) sgs = ecs.ex_list_security_groups() print('Found %d security groups' % len(sgs)) if len(sgs) == 0: - sg = ecs.ex_create_security_groups(ex_description='test') + sg = ecs.ex_create_security_group(description='test') print('Create security group %s' % sg) else: - sg = sgs[0] + sg = sgs[0].id print('Use security group %s' % sg) nodes = ecs.list_nodes() @@ -73,7 +73,7 @@ if len(nodes) == 0: auth = NodeAuthPassword('P@$$w0rd') node = ecs.create_node(image=image, size=small, name='test', - ex_security_group_id=sg.id, + ex_security_group_id=sg, ex_internet_charge_type=ecs.internet_charge_types.BY_TRAFFIC, ex_internet_max_bandwidth_out=1, ex_data_disk=data_disk, http://git-wip-us.apache.org/repos/asf/libcloud/blob/5edbb6a9/libcloud/compute/drivers/ecs.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/ecs.py b/libcloud/compute/drivers/ecs.py index 787df7f..4198f07 100644 --- a/libcloud/compute/drivers/ecs.py +++ b/libcloud/compute/drivers/ecs.py @@ -768,26 +768,28 @@ class ECSDriver(NodeDriver): return resp.success() and \ self._wait_until_state([node], NodeState.STOPPED) - def ex_create_security_groups(self, ex_description=None, - ex_client_token=None): + def ex_create_security_group(self, description=None, + client_token=None): """ - Create a new security groups. + Create a new security group. - :keyword ex_description: volume description - :type ex_description: ``unicode`` + :keyword description: security group description + :type description: ``unicode`` - :keyword ex_client_token: a token generated by client to identify + :keyword client_token: a token generated by client to identify each request. - :type ex_client_token: ``str`` + :type client_token: ``str`` """ params = {'Action': 'CreateSecurityGroup', 'RegionId': self.region} - if ex_description: - params['Description'] = ex_description - if ex_client_token: - params['ClientToken'] = ex_client_token - return self.connection.request(self.path, params).object + if description: + params['Description'] = description + if client_token: + params['ClientToken'] = client_token + resp = self.connection.request(self.path, params) + return findtext(resp.object, 'SecurityGroupId', + namespace=self.namespace) def ex_list_security_groups(self, ex_filters=None): """