From 800ed1d83b873b2e2fbb1204e5cf1767cc1f40e4 Mon Sep 17 00:00:00 2001 From: Enol Fernandez Date: Tue, 20 Oct 2015 08:11:40 +0000 Subject: [PATCH] Kind locations must be relative Change-Id: Icdf52cbe6cc3f5183c39b02f96c8dd6998cdb1aa Closes-Bug: #1507939 --- ooi/occi/infrastructure/network.py | 2 +- ooi/occi/infrastructure/network_link.py | 2 +- ooi/occi/infrastructure/storage.py | 2 +- ooi/occi/infrastructure/storage_link.py | 2 +- ooi/tests/occi/test_occi_infrastructure.py | 5 +++++ 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ooi/occi/infrastructure/network.py b/ooi/occi/infrastructure/network.py index 775c044..de41dc1 100644 --- a/ooi/occi/infrastructure/network.py +++ b/ooi/occi/infrastructure/network.py @@ -34,7 +34,7 @@ class NetworkResource(resource.Resource): "occi.network.state"]) actions = (up, down) kind = kind.Kind(helpers.build_scheme('infrastructure'), 'network', - 'network resource', attributes, '/network/', + 'network resource', attributes, 'network/', actions=actions, related=[resource.Resource.kind]) diff --git a/ooi/occi/infrastructure/network_link.py b/ooi/occi/infrastructure/network_link.py index b2c71a8..d73d74a 100644 --- a/ooi/occi/infrastructure/network_link.py +++ b/ooi/occi/infrastructure/network_link.py @@ -27,7 +27,7 @@ class NetworkInterface(link.Link): "occi.networkinterface.state"]) kind = kind.Kind(helpers.build_scheme('infrastructure'), 'networkinterface', 'network link resource', - attributes, '/networklink/', + attributes, 'networklink/', related=[link.Link.kind]) def __init__(self, mixins, source, target, id=None, interface=None, diff --git a/ooi/occi/infrastructure/storage.py b/ooi/occi/infrastructure/storage.py index 155060e..a1f8af6 100644 --- a/ooi/occi/infrastructure/storage.py +++ b/ooi/occi/infrastructure/storage.py @@ -41,7 +41,7 @@ class StorageResource(resource.Resource): "occi.storage.state"]) actions = (online, offline, backup, snapshot, resize) kind = kind.Kind(helpers.build_scheme('infrastructure'), 'storage', - 'storage resource', attributes, '/storage/', + 'storage resource', attributes, 'storage/', actions=actions, related=[resource.Resource.kind]) diff --git a/ooi/occi/infrastructure/storage_link.py b/ooi/occi/infrastructure/storage_link.py index e22d6cc..fbffbd8 100644 --- a/ooi/occi/infrastructure/storage_link.py +++ b/ooi/occi/infrastructure/storage_link.py @@ -25,7 +25,7 @@ class StorageLink(link.Link): "occi.storagelink.mountpoint", "occi.storagelink.state"]) kind = kind.Kind(helpers.build_scheme('infrastructure'), 'storagelink', - 'storage link resource', attributes, '/storagelink/', + 'storage link resource', attributes, 'storagelink/', related=[link.Link.kind]) def __init__(self, source, target, deviceid=None, mountpoint=None, diff --git a/ooi/tests/occi/test_occi_infrastructure.py b/ooi/tests/occi/test_occi_infrastructure.py index aab0400..56952f4 100644 --- a/ooi/tests/occi/test_occi_infrastructure.py +++ b/ooi/tests/occi/test_occi_infrastructure.py @@ -45,6 +45,7 @@ class TestOCCICompute(base.TestCase): self.assertIn("occi.compute.speed", c.attributes) self.assertIn("occi.compute.state", c.attributes) self.assertIn(resource.Resource.kind, c.kind.related) + self.assertEqual(c.kind.location, "compute/") # TODO(aloga): We need to check that the attributes are actually set # after we get an object (we have to check this for this but also for # the other resources) @@ -106,6 +107,7 @@ class TestOCCIStorage(base.TestCase): self.assertIn("occi.storage.size", s.attributes) self.assertIn("occi.storage.state", s.attributes) self.assertIn(resource.Resource.kind, s.kind.related) + self.assertEqual(s.kind.location, "storage/") # TODO(aloga): We need to check that the attributes are actually set # after we get an object (we have to check this for this but also for # the other resources) @@ -143,6 +145,7 @@ class TestOCCIStorageLink(base.TestCase): self.assertIn("occi.storagelink.deviceid", s.attributes) self.assertIn("occi.storagelink.state", s.attributes) self.assertIn(link.Link.kind, s.kind.related) + self.assertEqual(s.kind.location, "storagelink/") def test_storagelink(self): server_id = uuid.uuid4().hex @@ -215,6 +218,7 @@ class TestOCCINetwork(base.TestCase): self.assertIn("occi.network.label", n.attributes) self.assertIn("occi.network.state", n.attributes) self.assertIn(resource.Resource.kind, n.kind.related) + self.assertEqual(n.kind.location, "network/") # TODO(aloga): We need to check that the attributes are actually set # after we get an object (we have to check this for this but also for # the other resources) @@ -280,6 +284,7 @@ class TestOCCINetworkInterface(base.TestCase): self.assertIn("occi.networkinterface.mac", l.attributes) self.assertIn("occi.networkinterface.state", l.attributes) self.assertIn(link.Link.kind, l.kind.related) + self.assertEqual(l.kind.location, "networklink/") def test_networkinterface(self): c = compute.ComputeResource("foo",