diff options
author | spisarski <s.pisarski@cablelabs.com> | 2018-03-07 14:52:44 -0700 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2018-03-08 15:11:23 -0700 |
commit | fb0ab37c323717ca10ac3f3bda24ae390635495e (patch) | |
tree | f65435ee1d602981867bd67455aa20923a75b691 /snaps/domain | |
parent | f77540b440d3e5224eb1648339dc8c945f29bbe2 (diff) |
Added members to VmInst that will contain the availability_zone
and compute_host names while deprecating the method get_vm_info().
JIRA: SNAPS-277
Change-Id: Idc8578b3f2cf2be8ef90f52dd025dbea729b222b
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/domain')
-rw-r--r-- | snaps/domain/test/vm_inst_tests.py | 7 | ||||
-rw-r--r-- | snaps/domain/vm_inst.py | 11 |
2 files changed, 15 insertions, 3 deletions
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/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) |