def test_resource_link_with_mixins(self): r1 = resource.Resource(None, []) r2 = resource.Resource(None, []) r1.link(r2, [mixin.Mixin("s1", "term", "title"), mixin.Mixin("s2", "term", "title")]) r = self.renderer.get_renderer(r1) observed = r.render() self.assertResourceLink(r1, r2, observed)
def test_resource_mixins(self): mixins = [ mixin.Mixin("foo", "bar", None), mixin.Mixin("baz", "foobar", None), ] res = resource.Resource("title", mixins, "foo", "summary") r = self.renderer.get_renderer(res) observed = r.render() self.assertResourceMixins(res, mixins, observed)
def state(self): return self.attributes["occi.network.state"].value @property def message(self): return self.attributes["occi.network.state.message"].value ip_network = mixin.Mixin( helpers.build_scheme("infrastructure/network"), "ipnetwork", "IP Networking Mixin", attributes=attr.AttributeCollection({ "occi.network.address": attr.MutableAttribute( "occi.network.address", description="Internet Protocol (IP) network address", attr_type=attr.AttributeType.string_type), "occi.network.gateway": attr.MutableAttribute( "occi.network.gateway", description="Internet Protocol (IP) network address", attr_type=attr.AttributeType.string_type), "occi.network.allocation": attr.MutableAttribute( "occi.network.allocation", description="Address allocation mechanism: dynamic, static", attr_type=attr.AttributeType.string_type), }), applies=[NetworkResource.kind])
self.attributes["occi.networkinterface.mac"] = attr.MutableAttribute( "occi.networkinterface.mac", mac) self.attributes["occi.networkinterface.state"] = ( attr.InmutableAttribute("occi.networkinterface.state", state)) @property def interface(self): return self.attributes["occi.networkinterface.interface"].value @property def mac(self): return self.attributes["occi.networkinterface.mac"].value @mac.setter def mac(self, value): self.attributes["occi.networkinterface.mac"].value = value @property def state(self): return self.attributes["occi.networkinterface.state"].value ip_network_interface = mixin.Mixin( helpers.build_scheme("infrastructure/networkinterface"), "ipnetworkinterface", "IP Network interface Mixin", attributes=attr.AttributeCollection([ "occi.networkinterface.address", "occi.networkinterface.gateway", "occi.networkinterface.allocation" ]))
def test_mixins(self): m = mixin.Mixin(None, None, None) r = resource.Resource(None, [m]) self.assertIsInstance(r.kind, kind.Kind) self.assertEqual([m], r.mixins)
@property def address(self): return self.attributes["occi.network.address"].value @address.setter def address(self, value): self.attributes["occi.network.address"].value = value @property def gateway(self): return self.attributes["occi.network.gateway"].value @gateway.setter def gateway(self, value): self.attributes["occi.network.gateway"].value = value @property def allocation(self): return self.attributes["occi.network.allocation"].value @allocation.setter def allocation(self, value): self.attributes["occi.network.allocation"].value = value neutron_network = mixin.Mixin( helpers.build_scheme("infrastructure/network"), "neutron", "Network component", )
def test_mixin(self): mxn = mixin.Mixin("scheme", "term", "title") self.get_render_and_assert(mxn)
# -*- coding: utf-8 -*- # Copyright 2015 Spanish National Research Council # # 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. from ooi.occi.core import mixin from ooi.occi import helpers os_tpl = mixin.Mixin(helpers.build_scheme("infrastructure"), "os_tpl", "OCCI OS Template") resource_tpl = mixin.Mixin(helpers.build_scheme("infrastructure"), "resource_tpl", "OCCI Resource Template")