Updated ex_create_network to return an EC2Network object
Updated test_ex_create_network accordingly


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/78e45c4e
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/78e45c4e
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/78e45c4e

Branch: refs/heads/trunk
Commit: 78e45c4ead96ddb12f29c14680756aadc37f747a
Parents: e35c989
Author: Chris DeRamus <[email protected]>
Authored: Tue Dec 24 08:33:13 2013 -0500
Committer: Chris DeRamus <[email protected]>
Committed: Tue Dec 24 08:33:13 2013 -0500

----------------------------------------------------------------------
 libcloud/compute/drivers/ec2.py   | 26 ++++++--------------------
 libcloud/test/compute/test_ec2.py | 11 +++++------
 2 files changed, 11 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/78e45c4e/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index 30bd4cd..ca43ac2 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -1527,30 +1527,16 @@ class BaseEC2NodeDriver(NodeDriver):
                   'CidrBlock': cidr_block,
                   'InstanceTenancy':  instance_tenancy}
 
-        result = self.connection.request(self.path, params=params).object
+        response = self.connection.request(self.path, params=params).object
+        element = response.findall(fixxpath(xpath='vpc',
+                                            namespace=NAMESPACE))[0]
 
-        # Get our properties
-        response = {'vpc_id': findtext(element=result,
-                                       xpath='vpc/vpcId',
-                                       namespace=NAMESPACE),
-                    'state': findtext(element=result,
-                                      xpath='vpc/state',
-                                      namespace=NAMESPACE),
-                    'cidr_block': findtext(element=result,
-                                           xpath='vpc/cidrBlock',
-                                           namespace=NAMESPACE)}
+        network = self._to_network(element)
 
-        # Attempt to tag our network if the name was provided
         if name is not None:
-            # Build a resource object
-            class Resource:
-                pass
-
-            resource = Resource()
-            resource.id = response['vpc_id']
-            self.ex_create_tags(resource, {'Name': name})
+            self.ex_create_tags(network, {'Name': name})
 
-        return response
+        return network
 
     def ex_destroy_network(self, vpc_id):
         """

http://git-wip-us.apache.org/repos/asf/libcloud/blob/78e45c4e/libcloud/test/compute/test_ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ec2.py 
b/libcloud/test/compute/test_ec2.py
index 2074a51..f6bb902 100644
--- a/libcloud/test/compute/test_ec2.py
+++ b/libcloud/test/compute/test_ec2.py
@@ -800,9 +800,9 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin):
                                             name='Test VPC',
                                             instance_tenancy='default')
 
-        self.assertEqual('vpc-ad3527cf', vpc['vpc_id'])
-        self.assertEqual('pending', vpc['state'])
-        self.assertEqual('192.168.55.0/24', vpc['cidr_block'])
+        self.assertEqual('vpc-ad3527cf', vpc.id)
+        self.assertEqual('192.168.55.0/24', vpc.cidr_block)
+        self.assertEqual('pending', vpc.extra['state'])
 
     def test_ex_destroy_network(self):
         vpcs = self.driver.ex_list_networks()
@@ -1090,10 +1090,10 @@ class EC2MockHttp(MockHttpTestCase):
         body = self.fixtures.load('describe_account_attributes.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
-<<<<<<< HEAD
     def _CreateSecurityGroup(self, method, url, body, headers):
         body = self.fixtures.load('create_security_group.xml')
-=======
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
     def _DescribeVpcs(self, method, url, body, headers):
         body = self.fixtures.load('describe_vpcs.xml')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
@@ -1104,7 +1104,6 @@ class EC2MockHttp(MockHttpTestCase):
 
     def _DeleteVpc(self, method, url, body, headers):
         body = self.fixtures.load('delete_vpc.xml')
->>>>>>> LIBCLOUD-467_Add_VPC_Lifecycle_Support
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
 

Reply via email to