Add missing location to mixins

Change-Id: I25d3a2ae81c42f24d98ed2536e3dd0acb06b96e3
Closes-Bug: 1687933
This commit is contained in:
Enol Fernandez 2017-08-23 07:49:09 +01:00
parent 8f3a0de485
commit 3647b2bbf0
9 changed files with 37 additions and 13 deletions

View File

@ -36,6 +36,7 @@ class SSHKey(mixin.Mixin):
super(SSHKey, self).__init__(SSHKey.scheme, SSHKey.term,
"Credentials mixin",
attributes=attrs,
location="ssh_key/",
applies=[compute.ComputeResource.kind])
@property
@ -69,6 +70,7 @@ class UserData(mixin.Mixin):
UserData.term,
"Contextualization mixin",
attributes=attrs,
location="user_data/",
applies=[compute.ComputeResource.kind])
@property

View File

@ -91,6 +91,7 @@ class NetworkResource(resource.Resource):
ip_network = mixin.Mixin(
helpers.build_scheme("infrastructure/network"),
"ipnetwork", "IP Networking Mixin",
location="ipnetwork/",
attributes=attr.AttributeCollection({
"occi.network.address": attr.MutableAttribute(
"occi.network.address",

View File

@ -88,6 +88,7 @@ class NetworkInterface(link.Link):
ip_network_interface = mixin.Mixin(
helpers.build_scheme("infrastructure/networkinterface"),
"ipnetworkinterface", "IP Network interface Mixin",
location="ipnetworkinterface/",
attributes=attr.AttributeCollection({
"occi.networkinterface.address": attr.MutableAttribute(
"occi.networkinterface.address",

View File

@ -33,6 +33,7 @@ class OpenStackUserData(mixin.Mixin):
super(OpenStackUserData, self).__init__(
OpenStackUserData.scheme, OpenStackUserData.term,
"Contextualization extension - user_data",
location="openstack_user_data/",
attributes=attrs)
@property
@ -59,6 +60,7 @@ class OpenStackPublicKey(mixin.Mixin):
super(OpenStackPublicKey, self).__init__(
OpenStackPublicKey.scheme, OpenStackPublicKey.term,
"Contextualization extension - public_key",
location="openstack_public_key/",
attributes=attrs)
@property

View File

@ -24,7 +24,9 @@ class OSFloatingIPPool(mixin.Mixin):
scheme = helpers.build_scheme("network/floatingippool")
def __init__(self, pool=None):
super(OSFloatingIPPool, self).__init__(self.scheme, pool, pool)
location = "floatingippool/%s" % pool
super(OSFloatingIPPool, self).__init__(self.scheme, pool, pool,
location=location)
class OSNetworkInterface(network_link.NetworkInterface):
@ -94,6 +96,7 @@ class OSNetwork(mixin.Mixin):
scheme=self.scheme,
term=term,
title=title,
location="osnetwork/",
attributes=attr.AttributeCollection([
"org.openstack.network.ip_version"
])
@ -174,4 +177,4 @@ class OSNetworkResource(network.NetworkResource):
neutron_network = mixin.Mixin(helpers.build_scheme("infrastructure/network"),
"neutron", "Network component",
)
location="neutron/")

View File

@ -467,7 +467,8 @@ def fake_query_results():
cats.append(
'ipnetwork; '
'scheme="http://schemas.ogf.org/occi/infrastructure/network#"; '
'class="mixin"; title="IP Networking Mixin"')
'class="mixin"; title="IP Networking Mixin"; '
'location="%s/ipnetwork/"' % application_url)
cats.append(
'up; '
'scheme="http://schemas.ogf.org/occi/infrastructure/network/action#"; '
@ -486,7 +487,8 @@ def fake_query_results():
'ipnetworkinterface; '
'scheme="http://schemas.ogf.org/occi/infrastructure/'
'networkinterface#"; '
'class="mixin"; title="IP Network interface Mixin"')
'class="mixin"; title="IP Network interface Mixin"; '
'location="%s/ipnetworkinterface/"' % application_url)
cats.append(
'ipreservation; '
'scheme="http://schemas.ogf.org/occi/infrastructure#"; '
@ -532,21 +534,25 @@ def fake_query_results():
cats.append(
'user_data; '
'scheme="http://schemas.openstack.org/compute/instance#"; '
'class="mixin"; title="Contextualization extension - user_data"')
'class="mixin"; title="Contextualization extension - user_data"; '
'location="%s/openstack_user_data/"' % application_url)
cats.append(
'public_key; '
'scheme="http://schemas.openstack.org/instance/credentials#"; '
'class="mixin"; title="Contextualization extension - public_key"')
'class="mixin"; title="Contextualization extension - public_key"; '
'location="%s/openstack_public_key/"' % application_url)
# OCCI contextualization
cats.append(
'user_data; '
'scheme="http://schemas.ogf.org/occi/infrastructure/compute#"; '
'class="mixin"; title="Contextualization mixin"')
'class="mixin"; title="Contextualization mixin"; '
'location="%s/user_data/"' % application_url)
cats.append(
'ssh_key; '
'scheme="http://schemas.ogf.org/occi/infrastructure/credentials#"; '
'class="mixin"; title="Credentials mixin"')
'class="mixin"; title="Credentials mixin"; '
'location="%s/ssh_key/"' % application_url)
result = []
for c in cats:

View File

@ -354,11 +354,13 @@ def build_occi_network(network):
cats.append('ipnetwork; '
'scheme='
'"http://schemas.ogf.org/occi/infrastructure/network#";'
' class="mixin"; title="IP Networking Mixin"')
' class="mixin"; title="IP Networking Mixin";'
' location="%s/ipnetwork/"' % app_url)
cats.append('osnetwork; '
'scheme='
'"http://schemas.openstack.org/infrastructure/network#";'
' class="mixin"; title="openstack network"')
' class="mixin"; title="openstack network";'
' location="%s/osnetwork/"' % app_url)
links = []
links.append('<%s/network/%s?action=up>; '
@ -407,11 +409,13 @@ def build_occi_nova(network):
cats.append('ipnetwork; '
'scheme='
'"http://schemas.ogf.org/occi/infrastructure/network#";'
' class="mixin"; title="IP Networking Mixin"')
' class="mixin"; title="IP Networking Mixin";'
' location="%s/ipnetwork/"' % app_url)
cats.append('osnetwork; '
'scheme='
'"http://schemas.openstack.org/infrastructure/network#";'
' class="mixin"; title="openstack network"')
' class="mixin"; title="openstack network";'
' location="%s/osnetwork/"' % app_url)
links = []
links.append('<%s/network/%s?action=up>; '
@ -469,4 +473,4 @@ def build_occi_securitygroup(secgroup):
result.append(("X-OCCI-Attribute", a))
for l in links:
result.append(("Link", l))
return result
return result

View File

@ -357,6 +357,7 @@ class TestOCCIUserData(base.TestCase):
self.assertEqual("user_data", mxn.term)
self.assertEqual(user_data, mxn.user_data)
self.assertEqual([compute.ComputeResource.kind], mxn.applies)
self.assertEqual("user_data/", mxn.location)
class TestOCCISSHKey(base.TestCase):
@ -366,6 +367,7 @@ class TestOCCISSHKey(base.TestCase):
self.assertEqual("ssh_key", mxn.term)
self.assertEqual(key_data, mxn.ssh_key)
self.assertEqual([compute.ComputeResource.kind], mxn.applies)
self.assertEqual("ssh_key/", mxn.location)
class TestOCCISecurityGRoup(base.TestCase):

View File

@ -104,6 +104,7 @@ class TestOpenStackUserData(base.TestCase):
self.assertEqual("user_data", mxn.term)
self.assertTrue(mxn.scheme.startswith(helpers._PREFIX))
self.assertEqual(user_data, mxn.user_data)
self.assertEqual("openstack_user_data/", mxn.location)
class TestOpenStackPublicKey(base.TestCase):
@ -117,6 +118,7 @@ class TestOpenStackPublicKey(base.TestCase):
self.assertTrue(mxn.scheme.startswith(helpers._PREFIX))
self.assertEqual(key_name, mxn.name)
self.assertEqual(key_data, mxn.data)
self.assertEqual("openstack_public_key/", mxn.location)
class TestOSNetworkInterface(base.TestCase):
@ -144,6 +146,7 @@ class TestOSNetworkInterface(base.TestCase):
for m in i.mixins:
if isinstance(m, os_network.OSFloatingIPPool):
self.assertEqual("foo", m.term)
self.assertEqual("floatingippool/foo", m.location)
has_pool = True
break
self.assertTrue(has_pool)