summaryrefslogtreecommitdiffstats
path: root/snaps/domain
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-06-22 12:43:09 -0600
committerspisarski <s.pisarski@cablelabs.com>2017-06-22 14:28:08 -0600
commitc7ba89444d160cb81656a49cb93416ee5013aa8f (patch)
tree0f46d74f98e17e256c3e1eb9a592c3bcc29044e8 /snaps/domain
parentdbfb9c4e94e500592a8b93f42b7b87230d0af311 (diff)
Use neutron to create floating IPs.
This patch moves the floating IP creation out of nova and into neutron. Other changes include the use of domain objects for VM and Floating IP instances, addition of new nova_utils tests to exercise the create server functionality, and more PEP8 compliance. JIRA: SNAPS-92 Change-Id: I16c12b26b56008901633e90ae307586ad2045f9b Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/domain')
-rw-r--r--snaps/domain/test/vm_inst_tests.py49
-rw-r--r--snaps/domain/vm_inst.py44
2 files changed, 93 insertions, 0 deletions
diff --git a/snaps/domain/test/vm_inst_tests.py b/snaps/domain/test/vm_inst_tests.py
new file mode 100644
index 0000000..e722a06
--- /dev/null
+++ b/snaps/domain/test/vm_inst_tests.py
@@ -0,0 +1,49 @@
+# Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
+# and others. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import unittest
+from snaps.domain.vm_inst import VmInst, FloatingIp
+
+
+class VmInstDomainObjectTests(unittest.TestCase):
+ """
+ Tests the construction of the snaps.domain.test.Image class
+ """
+
+ def test_construction_positional(self):
+ vm_inst = VmInst('name', 'id')
+ self.assertEqual('name', vm_inst.name)
+ self.assertEqual('id', vm_inst.id)
+
+ def test_construction_named(self):
+ vm_inst = VmInst(inst_id='id', name='name')
+ self.assertEqual('name', vm_inst.name)
+ self.assertEqual('id', vm_inst.id)
+
+
+class FloatingIpDomainObjectTests(unittest.TestCase):
+ """
+ Tests the construction of the snaps.domain.test.Image class
+ """
+
+ def test_construction_positional(self):
+ vm_inst = FloatingIp('id-123', '10.0.0.1')
+ self.assertEqual('id-123', vm_inst.id)
+ self.assertEqual('10.0.0.1', vm_inst.ip)
+
+ def test_construction_named(self):
+ vm_inst = FloatingIp(ip='10.0.0.1', inst_id='id-123')
+ self.assertEqual('id-123', vm_inst.id)
+ self.assertEqual('10.0.0.1', vm_inst.ip)
diff --git a/snaps/domain/vm_inst.py b/snaps/domain/vm_inst.py
new file mode 100644
index 0000000..0e12d14
--- /dev/null
+++ b/snaps/domain/vm_inst.py
@@ -0,0 +1,44 @@
+# Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
+# and others. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+class VmInst:
+ """
+ SNAPS domain object for Images. Should contain attributes that
+ are shared amongst cloud providers
+ """
+ def __init__(self, name, inst_id):
+ """
+ Constructor
+ :param name: the image's name
+ :param inst_id: the instance's id
+ """
+ self.name = name
+ self.id = inst_id
+
+
+class FloatingIp:
+ """
+ SNAPS domain object for Images. Should contain attributes that
+ are shared amongst cloud providers
+ """
+ def __init__(self, inst_id, ip):
+ """
+ Constructor
+ :param inst_id: the floating ip's id
+ :param ip: the IP address
+ """
+ self.id = inst_id
+ self.ip = ip