diff options
Diffstat (limited to 'snaps/domain')
-rw-r--r-- | snaps/domain/network.py | 14 | ||||
-rw-r--r-- | snaps/domain/stack.py | 10 | ||||
-rw-r--r-- | snaps/domain/test/network_tests.py | 40 | ||||
-rw-r--r-- | snaps/domain/test/stack_tests.py | 13 | ||||
-rw-r--r-- | snaps/domain/test/vm_inst_tests.py | 7 | ||||
-rw-r--r-- | snaps/domain/test/volume_tests.py | 9 | ||||
-rw-r--r-- | snaps/domain/vm_inst.py | 11 | ||||
-rw-r--r-- | snaps/domain/volume.py | 11 |
8 files changed, 85 insertions, 30 deletions
diff --git a/snaps/domain/network.py b/snaps/domain/network.py index 2d02966..3d5e4af 100644 --- a/snaps/domain/network.py +++ b/snaps/domain/network.py @@ -24,6 +24,7 @@ class Network: Constructor :param name: the network's name :param id: the network's ID + :param project_id: the associated project ID :param admin_state_up: T/F - network is up when True :param shared: T/F - network can be shared amongst other project's :param external: T/F - network is deemed to be external @@ -32,19 +33,22 @@ class Network: """ self.name = kwargs.get('name') self.id = kwargs.get('id') + self.project_id = kwargs.get('project_id') self.admin_state_up = kwargs.get('admin_state_up') self.shared = kwargs.get('shared') self.external = kwargs.get('router:external', kwargs.get('external')) self.type = kwargs.get('provider:network_type', kwargs.get('type')) self.subnets = kwargs.get('subnets', list()) + self.mtu = kwargs.get('mtu') def __eq__(self, other): return (self.name == other.name and self.id == other.id and + self.project_id == other.project_id and self.admin_state_up == other.admin_state_up and self.shared == other.shared and self.external == other.external and - self.type == other.type and - self.subnets == other.subnets) + self.subnets == other.subnets and + self.mtu == other.mtu) class Subnet: @@ -57,6 +61,7 @@ class Subnet: Constructor :param name: the network's name :param id: the subnet's ID + :param project_id: the associated project ID :param network_id: the network's ID :param cidr: the CIDR :param ip_version: the IP version @@ -71,6 +76,7 @@ class Subnet: """ self.name = kwargs.get('name') self.id = kwargs.get('id') + self.project_id = kwargs.get('project_id') self.network_id = kwargs.get('network_id') self.cidr = kwargs.get('cidr') self.ip_version = kwargs.get('ip_version') @@ -95,6 +101,7 @@ class Subnet: def __eq__(self, other): return (self.name == other.name and self.id == other.id and + self.project_id == other.project_id and self.network_id == other.network_id and self.cidr == other.cidr and self.ip_version == other.ip_version and @@ -181,8 +188,7 @@ class Router: self.port_subnets = kwargs.get('port_subnets') if (kwargs.get('external_gateway_info') and - isinstance(kwargs.get('external_gateway_info'), dict) and - kwargs.get('external_gateway_info').get('external_fixed_ips')): + isinstance(kwargs.get('external_gateway_info'), dict)): gateway_info = kwargs.get('external_gateway_info') self.external_network_id = gateway_info.get('network_id') diff --git a/snaps/domain/stack.py b/snaps/domain/stack.py index 080ab17..2c593d3 100644 --- a/snaps/domain/stack.py +++ b/snaps/domain/stack.py @@ -19,14 +19,22 @@ class Stack: SNAPS domain object for Heat Stacks. Should contain attributes that are shared amongst cloud providers """ - def __init__(self, name, stack_id): + def __init__(self, name, stack_id, stack_project_id, + status, status_reason): """ Constructor :param name: the stack's name :param stack_id: the stack's stack_id + :param stack_project_id: the project ID that was spawned from this + deployment + :param status: the stack's last known status code + :param status_reason: the stack's last known explanation of the status """ self.name = name self.id = stack_id + self.stack_project_id = stack_project_id + self.status = status + self.status_reason = status_reason def __eq__(self, other): return (self.name == other.name and diff --git a/snaps/domain/test/network_tests.py b/snaps/domain/test/network_tests.py index 3003326..2c4c841 100644 --- a/snaps/domain/test/network_tests.py +++ b/snaps/domain/test/network_tests.py @@ -26,28 +26,34 @@ class NetworkObjectTests(unittest.TestCase): def test_construction_kwargs_1(self): subnet = Subnet( - **{'name': 'foo', 'id': 'bar', 'network_id': 'foo-bar'}) + **{'name': 'foo', 'id': 'bar', 'project_id': 'proj1', + 'network_id': 'foo-bar'}) network = Network( - **{'name': 'foo', 'id': 'bar', 'provider:network_type': 'flat', - 'admin_state_up': False, 'shared': True, - 'router:external': False, 'subnets': [subnet]}) + **{'name': 'foo', 'id': 'bar', 'project_id': 'proj1', + 'provider:network_type': 'flat', 'admin_state_up': False, + 'shared': True, 'router:external': False, 'subnets': [subnet], + 'mtu': 999}) self.assertEqual('foo', network.name) self.assertEqual('bar', network.id) + self.assertEqual('proj1', network.project_id) self.assertEqual('flat', network.type) self.assertFalse(network.admin_state_up) self.assertFalse(network.external) self.assertTrue(network.shared) self.assertEqual([subnet], network.subnets) + self.assertEqual(999, network.mtu) def test_construction_kwargs_2(self): subnet = Subnet( - **{'name': 'foo', 'id': 'bar', 'network_id': 'foo-bar'}) + **{'name': 'foo', 'id': 'bar', 'project_id': 'proj1', + 'network_id': 'foo-bar'}) network = Network( - **{'name': 'foo', 'id': 'bar', 'type': 'flat', - 'admin_state_up': False, 'shared': True, 'external': False, - 'subnets': [subnet]}) + **{'name': 'foo', 'id': 'bar', 'project_id': 'proj1', + 'type': 'flat', 'admin_state_up': False, 'shared': True, + 'external': False, 'subnets': [subnet]}) self.assertEqual('foo', network.name) self.assertEqual('bar', network.id) + self.assertEqual('proj1', network.project_id) self.assertEqual('flat', network.type) self.assertFalse(network.admin_state_up) self.assertFalse(network.external) @@ -56,12 +62,15 @@ class NetworkObjectTests(unittest.TestCase): def test_construction_named(self): subnet = Subnet( - **{'name': 'foo', 'id': 'bar', 'network_id': 'foo-bar'}) + **{'name': 'foo', 'id': 'bar', 'project_id': 'proj1', + 'network_id': 'foo-bar'}) network = Network( - name='foo', id='bar', type='flat', admin_state_up=False, - shared=True, external=False, subnets=[subnet]) + name='foo', id='bar', project_id='proj1', type='flat', + admin_state_up=False, shared=True, external=False, + subnets=[subnet]) self.assertEqual('foo', network.name) self.assertEqual('bar', network.id) + self.assertEqual('proj1', network.project_id) self.assertEqual('flat', network.type) self.assertFalse(network.admin_state_up) self.assertFalse(network.external) @@ -76,12 +85,14 @@ class SubnetObjectTests(unittest.TestCase): def test_construction_kwargs(self): subnet = Subnet( - **{'name': 'foo', 'id': 'bar', 'cidr': '10.0.0.0/24', - 'ip_version': 4, 'gateway_ip': '10.0.0.1', 'enable_dhcp': True, + **{'name': 'foo', 'id': 'bar', 'project_id': 'proj1', + 'cidr': '10.0.0.0/24', 'ip_version': 4, + 'gateway_ip': '10.0.0.1', 'enable_dhcp': True, 'dns_nameservers': ['8.8.8.8'], 'host_routes': list(), 'ipv6_ra_mode': 'hello', 'ipv6_address_mode': 'world'}) self.assertEqual('foo', subnet.name) self.assertEqual('bar', subnet.id) + self.assertEqual('proj1', subnet.project_id) self.assertEqual('10.0.0.0/24', subnet.cidr) self.assertEqual(4, subnet.ip_version) self.assertEqual('10.0.0.1', subnet.gateway_ip) @@ -94,12 +105,13 @@ class SubnetObjectTests(unittest.TestCase): def test_construction_named(self): subnet = Subnet( - name='foo', id='bar', cidr='10.0.0.0/24', + name='foo', id='bar', project_id='proj1', cidr='10.0.0.0/24', ip_version=4, gateway_ip='10.0.0.1', enable_dhcp=True, dns_nameservers=['8.8.8.8'], host_routes=list(), ipv6_ra_mode='hello', ipv6_address_mode='world') self.assertEqual('foo', subnet.name) self.assertEqual('bar', subnet.id) + self.assertEqual('proj1', subnet.project_id) self.assertEqual('10.0.0.0/24', subnet.cidr) self.assertEqual(4, subnet.ip_version) self.assertEqual('10.0.0.1', subnet.gateway_ip) diff --git a/snaps/domain/test/stack_tests.py b/snaps/domain/test/stack_tests.py index 21e31d2..2ad690a 100644 --- a/snaps/domain/test/stack_tests.py +++ b/snaps/domain/test/stack_tests.py @@ -23,14 +23,23 @@ class StackDomainObjectTests(unittest.TestCase): """ def test_construction_positional(self): - stack = Stack('name', 'id') + stack = Stack( + 'name', 'id', 'stack_proj_id', 'fine', 'good') self.assertEqual('name', stack.name) self.assertEqual('id', stack.id) + self.assertEqual('stack_proj_id', stack.stack_project_id) + self.assertEqual('fine', stack.status) + self.assertEqual('good', stack.status_reason) def test_construction_named(self): - stack = Stack(stack_id='id', name='name') + stack = Stack( + stack_id='id', name='name', stack_project_id='stack_proj_id', + status='fine', status_reason='good') self.assertEqual('name', stack.name) self.assertEqual('id', stack.id) + self.assertEqual('stack_proj_id', stack.stack_project_id) + self.assertEqual('fine', stack.status) + self.assertEqual('good', stack.status_reason) class ResourceDomainObjectTests(unittest.TestCase): diff --git a/snaps/domain/test/vm_inst_tests.py b/snaps/domain/test/vm_inst_tests.py index ad7a9ce..c90837d 100644 --- a/snaps/domain/test/vm_inst_tests.py +++ b/snaps/domain/test/vm_inst_tests.py @@ -24,7 +24,7 @@ class VmInstDomainObjectTests(unittest.TestCase): def test_construction_positional(self): vm_inst = VmInst('name', 'id', '456', '123', list(), 'kp-name', - ['foo', 'bar'], ['123', '456']) + ['foo', 'bar'], ['123', '456'], 'host1', 'zone1') self.assertEqual('name', vm_inst.name) self.assertEqual('id', vm_inst.id) self.assertEqual('456', vm_inst.image_id) @@ -33,9 +33,12 @@ class VmInstDomainObjectTests(unittest.TestCase): self.assertEqual('kp-name', vm_inst.keypair_name) self.assertEqual(['foo', 'bar'], vm_inst.sec_grp_names) self.assertEqual(['123', '456'], vm_inst.volume_ids) + self.assertEqual('host1', vm_inst.compute_host) + self.assertEqual('zone1', vm_inst.availability_zone) def test_construction_named(self): vm_inst = VmInst( + availability_zone='zone1', compute_host='host1', volume_ids=['123', '456'], sec_grp_names=['foo', 'bar'], ports=list(), inst_id='id', name='name', flavor_id='123', image_id='456', keypair_name='kp-name') @@ -47,6 +50,8 @@ class VmInstDomainObjectTests(unittest.TestCase): self.assertEqual('kp-name', vm_inst.keypair_name) self.assertEqual(['foo', 'bar'], vm_inst.sec_grp_names) self.assertEqual(['123', '456'], vm_inst.volume_ids) + self.assertEqual('host1', vm_inst.compute_host) + self.assertEqual('zone1', vm_inst.availability_zone) class FloatingIpDomainObjectTests(unittest.TestCase): diff --git a/snaps/domain/test/volume_tests.py b/snaps/domain/test/volume_tests.py index 6feadc9..09401d3 100644 --- a/snaps/domain/test/volume_tests.py +++ b/snaps/domain/test/volume_tests.py @@ -24,10 +24,12 @@ class VolumeDomainObjectTests(unittest.TestCase): """ def test_construction_positional(self): - volume = Volume('name1', 'id1', 'desc_val1', 2, 'type_val1', - 'avail_zone1', False, [{'attached_at': 'foo'}]) + volume = Volume('name1', 'id1', 'proj_id1', 'desc_val1', 2, + 'type_val1', 'avail_zone1', False, + [{'attached_at': 'foo'}]) self.assertEqual('name1', volume.name) self.assertEqual('id1', volume.id) + self.assertEqual('proj_id1', volume.project_id) self.assertEqual('desc_val1', volume.description) self.assertEqual(2, volume.size) self.assertEqual('type_val1', volume.type) @@ -41,9 +43,10 @@ class VolumeDomainObjectTests(unittest.TestCase): volume = Volume(attachments=[{'attached_at': 'foo'}], multi_attach=True, availability_zone='avail_zone2', vol_type='type_val2', size=3, description='desc_val2', - volume_id='id2', name='name2') + volume_id='id2', name='name2', project_id='proj_id1') self.assertEqual('name2', volume.name) self.assertEqual('id2', volume.id) + self.assertEqual('proj_id1', volume.project_id) self.assertEqual('desc_val2', volume.description) self.assertEqual(3, volume.size) self.assertEqual('type_val2', volume.type) diff --git a/snaps/domain/vm_inst.py b/snaps/domain/vm_inst.py index c49b03e..f3b5381 100644 --- a/snaps/domain/vm_inst.py +++ b/snaps/domain/vm_inst.py @@ -20,7 +20,8 @@ class VmInst: are shared amongst cloud providers """ def __init__(self, name, inst_id, image_id, flavor_id, ports, - keypair_name, sec_grp_names, volume_ids): + keypair_name, sec_grp_names, volume_ids, compute_host, + availability_zone): """ Constructor :param name: the image's name @@ -32,6 +33,11 @@ class VmInst: :param keypair_name: the name of the associated keypair :param sec_grp_names: list of security group names :param volume_ids: list of attached volume IDs + :param compute_host: the name of the host on which this VM is running + When the user requesting this query is not part of + the 'admin' role, this value will be None + :param availability_zone: the name of the availability zone to which + this VM has been assigned """ self.name = name self.id = inst_id @@ -41,6 +47,8 @@ class VmInst: self.keypair_name = keypair_name self.sec_grp_names = sec_grp_names self.volume_ids = volume_ids + self.compute_host = compute_host + self.availability_zone = availability_zone def __eq__(self, other): return (self.name == other.name and @@ -49,7 +57,6 @@ class VmInst: self.flavor_id == other.flavor_id and self.ports == other.ports and self.keypair_name == other.keypair_name and - self.sec_grp_names == other.sec_grp_names and self.volume_ids == other.volume_ids) diff --git a/snaps/domain/volume.py b/snaps/domain/volume.py index 0042d71..0ab2a7d 100644 --- a/snaps/domain/volume.py +++ b/snaps/domain/volume.py @@ -19,12 +19,14 @@ class Volume: SNAPS domain object for Volumes. Should contain attributes that are shared amongst cloud providers """ - def __init__(self, name, volume_id, description, size, vol_type, - availability_zone, multi_attach, attachments=list()): + def __init__(self, name, volume_id, project_id, description, size, + vol_type, availability_zone, multi_attach, + attachments=list()): """ Constructor :param name: the volume's name :param volume_id: the volume's id + :param project_id: the volume's associated project id :param description: the volume's description :param size: the volume's size in GB :param vol_type: the volume's type @@ -35,6 +37,7 @@ class Volume: """ self.name = name self.id = volume_id + self.project_id = project_id self.description = description self.size = size self.type = vol_type @@ -43,7 +46,9 @@ class Volume: self.attachments = attachments def __eq__(self, other): - return (self.name == other.name and self.id == other.id + return (self.name == other.name + and self.id == other.id + and self.project_id == other.project_id and self.description == other.description and self.size == other.size and self.type == other.type |