Exemple #1
0
    def __init__(self,
                 title,
                 summary=None,
                 id=None,
                 architecture=None,
                 cores=None,
                 hostname=None,
                 speed=None,
                 memory=None,
                 state=None,
                 mixins=[]):

        super(ComputeResource, self).__init__(title,
                                              mixins,
                                              summary=summary,
                                              id=id)

        self.attributes["occi.compute.architecture"] = attr.MutableAttribute(
            "occi.compute.architecture", architecture)
        self.attributes["occi.compute.cores"] = attr.MutableAttribute(
            "occi.compute.cores", cores)
        self.attributes["occi.compute.hostname"] = attr.MutableAttribute(
            "occi.compute.hostname", hostname)
        self.attributes["occi.compute.speed"] = attr.MutableAttribute(
            "occi.compute.speed", speed)
        self.attributes["occi.compute.memory"] = attr.MutableAttribute(
            "occi.compute.memory", memory)
        self.attributes["occi.compute.state"] = attr.InmutableAttribute(
            "occi.compute.state", state)
Exemple #2
0
 def __init__(self, source, target, mac, address, ip_id=None):
     link_id = '_'.join([source.id, address])
     mixins = [network_link.ip_network_interface]
     super(OSNetworkInterface,
           self).__init__(mixins, source, target, link_id, "eth0", mac,
                          "active")
     self.ip_id = ip_id
     self.attributes["occi.networkinterface.address"] = (
         attr.MutableAttribute("occi.networkinterface.address", address))
     self.attributes["occi.networkinterface.gateway"] = (
         attr.MutableAttribute("occi.networkinterface.gateway", None))
     self.attributes["occi.networkinterface.allocation"] = (
         attr.MutableAttribute("occi.networkinterface.allocation",
                               "dynamic"))
Exemple #3
0
 def test_resource_bool_attr(self):
     res = resource.Resource("title", [], "foo", "summary")
     attr = ("org.example.bool", True)
     res.attributes[attr[0]] = attribute.MutableAttribute(attr[0], attr[1])
     r = self.renderer.get_renderer(res)
     observed = r.render()
     self.assertResourceBoolAttr(res, attr, observed)
Exemple #4
0
 def test_resource_string_attr(self):
     res = resource.Resource("title", [], "foo", "summary")
     attr = ("org.example.str", "baz")
     res.attributes[attr[0]] = attribute.MutableAttribute(attr[0], attr[1])
     r = self.renderer.get_renderer(res)
     observed = r.render()
     self.assertResourceStringAttr(res, attr, observed)
Exemple #5
0
class IPReservation(network.NetworkResource):
    attributes = attr.AttributeCollection({
        "occi.ipreservation.address":
        attr.MutableAttribute("occi.ipreservation.address",
                              description="Internet Protocol(IP) network"
                              " address re-served for Compute instances"
                              " linking with this IPReservation instance",
                              attr_type=attr.AttributeType.string_type),
        "occi.ipreservation.used":
        attr.InmutableAttribute("occi.ipreservation.used",
                                description="Indication whether"
                                " the reserved address is currently in use.",
                                attr_type=attr.AttributeType.boolean_type),
        "occi.ipreservation.state":
        attr.InmutableAttribute(
            "occi.ipreservation.state",
            description="Indicates the state of the resource.",
            attr_type=attr.AttributeType.string_type),
    })

    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'ipreservation',
                     'IPReservation',
                     attributes,
                     'ipreservation/',
                     parent=network.NetworkResource.kind)

    def __init__(self,
                 title,
                 address,
                 id=None,
                 used=False,
                 state=None,
                 mixins=[]):
        super(IPReservation, self).__init__(title, id=id, mixins=mixins)

        self.address = address
        self.attributes["occi.ipreservation.used"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.ipreservation.used"], used))
        self.attributes["occi.ipreservation.state"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.ipreservation.state"], state))

    @property
    def address(self):
        return self.attributes["occi.ipreservation.address"].value

    @address.setter
    def address(self, value):
        self.attributes["occi.ipreservation.address"].value = value

    @property
    def used(self):
        return self.attributes["occi.ipreservation.used"].value

    @property
    def state(self):
        return self.attributes["occi.ipreservation.state"].value
Exemple #6
0
    def __init__(self,
                 source,
                 target,
                 deviceid=None,
                 mountpoint=None,
                 state=None):

        # TODO(enolfc): is this a valid link id?
        link_id = '_'.join([source.id, target.id])
        super(StorageLink, self).__init__(None, [], source, target, link_id)

        self.attributes["occi.storagelink.deviceid"] = attr.MutableAttribute(
            "occi.storagelink.deviceid", deviceid)
        self.attributes["occi.storagelink.mountpoint"] = attr.MutableAttribute(
            "occi.storagelink.mountpoint", mountpoint)
        self.attributes["occi.storagelink.state"] = attr.InmutableAttribute(
            "occi.storagelink.state", state)
Exemple #7
0
 def __init__(self, source, target, mac, address, ip_id=None,
              pool=None, state='active'):
     link_id = '_'.join([source.id, target.id, address])
     mixins = [network_link.ip_network_interface]
     if pool:
         mixins.append(OSFloatingIPPool(pool))
     super(OSNetworkInterface, self).__init__(mixins, source, target,
                                              link_id, "eth0", mac,
                                              state)
     self.ip_id = ip_id
     self.attributes["occi.networkinterface.address"] = (
         attr.MutableAttribute("occi.networkinterface.address", address))
     self.attributes["occi.networkinterface.gateway"] = (
         attr.MutableAttribute("occi.networkinterface.gateway", None))
     self.attributes["occi.networkinterface.allocation"] = (
         attr.MutableAttribute("occi.networkinterface.allocation",
                               "dynamic"))
Exemple #8
0
class Link(entity.Entity):
    """OCCI Resoure.

    The Resource type is complemented by the Link type which associates one
    Resource instance with another.
    """

    attributes = attribute.AttributeCollection({
        "occi.core.source":
        attribute.MutableAttribute(
            "occi.core.source",
            required=True,
            description="The Resource instance the link originates from",
            attr_type=attribute.AttributeType.object_type),
        "occi.core.target":
        attribute.MutableAttribute(
            "occi.core.target",
            required=True,
            description=("The unique identifier of an Object this Link "
                         "instance points to"),
            attr_type=attribute.AttributeType.object_type),
    })

    kind = kind.Kind(helpers.build_scheme("core"), 'link', 'link', attributes,
                     'link/')

    def __init__(self, title, mixins, source, target, id=None):
        super(Link, self).__init__(title, mixins, id)
        self.source = source
        self.target = target

    @property
    def source(self):
        return self.attributes["occi.core.source"].value

    @source.setter
    def source(self, value):
        self.attributes["occi.core.source"].value = value

    @property
    def target(self):
        return self.attributes["occi.core.target"].value

    @target.setter
    def target(self, value):
        self.attributes["occi.core.target"].value = value
Exemple #9
0
class Resource(entity.Entity):
    """OCCI Resource.

    The heart of the OCCI Core Model is the Resource type. Any resource exposed
    through OCCI is a Resource or a sub-type thereof. A resource can be e.g. a
    virtual machine, a job in a job submission system, a user, etc.

    The Resource type is complemented by the Link type which associates one
    Resource instance with another. The Link type contains a number of common
    attributes that Link sub-types inherit.
    """

    attributes = attribute.AttributeCollection({
        "occi.core.summary":
        attribute.MutableAttribute(
            "occi.core.summary",
            description=("A summarizing description of "
                         "the resource instance."),
            attr_type=attribute.AttributeType.string_type),
    })

    kind = kind.Kind(helpers.build_scheme('core'),
                     'resource',
                     'resource',
                     attributes,
                     'resource/',
                     parent=entity.Entity.kind)

    def __init__(self, title, mixins, id=None, summary=None):
        super(Resource, self).__init__(title, mixins, id=id)
        self.summary = summary
        self._links = []

    def __eq__(self, other):
        return all([
            self.attributes[i].value == other.attributes[i].value
            for i in self.attributes
        ])

    @property
    def links(self):
        return self._links

    def link(self, target, mixins=[]):
        l = link.Link("", mixins, self, target)
        self._links.append(l)

    def add_link(self, link):
        self._links.append(link)

    @property
    def summary(self):
        return self.attributes["occi.core.summary"].value

    @summary.setter
    def summary(self, value):
        self.attributes["occi.core.summary"].value = value
Exemple #10
0
 def __init__(self,
              title,
              summary=None,
              id=None,
              vlan=None,
              label=None,
              state=None,
              mixins=[]):
     super(NetworkResource, self).__init__(title,
                                           mixins,
                                           summary=summary,
                                           id=id)
     self.attributes["occi.network.vlan"] = attr.MutableAttribute(
         "occi.network.vlan", vlan)
     self.attributes["occi.network.label"] = attr.MutableAttribute(
         "occi.network.label", label)
     self.attributes["occi.network.state"] = attr.InmutableAttribute(
         "occi.network.state", state)
Exemple #11
0
class Entity(object):
    """OCCI Entity.

    Entity is an abstract type, which both Resource and Link inherit. Each
    sub-type of Entity is identified by a unique Kind instance
    """

    attributes = attribute.AttributeCollection({
        "occi.core.id":
        attribute.InmutableAttribute(
            "occi.core.id",
            description="A unique identifier",
            attr_type=attribute.AttributeType.string_type),
        "occi.core.title":
        attribute.MutableAttribute(
            "occi.core.title",
            description="The display name of the instance",
            attr_type=attribute.AttributeType.string_type),
    })

    kind = kind.Kind(helpers.build_scheme('core'), 'entity', 'entity',
                     attributes, 'entity/')

    actions = None

    def __init__(self, title, mixins, id=None):
        helpers.check_type(mixins, mixin.Mixin)
        self.mixins = mixins

        # NOTE(aloga): we need a copy of the attributes, otherwise we will be
        # using the class ones instead of the object ones.
        self.attributes = self.attributes.copy()

        # damn, we're shading a builtin
        if id is None:
            id = uuid.uuid4().hex

        self.attributes["occi.core.id"] = (
            attribute.InmutableAttribute.from_attr(
                self.attributes["occi.core.id"], id))
        self.title = title

    @property
    def id(self):
        return self.attributes["occi.core.id"].value

    @property
    def title(self):
        return self.attributes["occi.core.title"].value

    @title.setter
    def title(self, value):
        self.attributes["occi.core.title"].value = value

    @property
    def location(self):
        return utils.join_url(self.kind.location, self.id)
Exemple #12
0
 def __init__(self, title, summary=None, id=None, size=None, state=None):
     mixins = []
     super(StorageResource, self).__init__(title,
                                           mixins,
                                           summary=summary,
                                           id=id)
     self.attributes["occi.storage.size"] = attr.MutableAttribute(
         "occi.storage.size", size)
     self.attributes["occi.storage.state"] = attr.InmutableAttribute(
         "occi.storage.state", state)
Exemple #13
0
 def test_kind_attributes(self):
     attr = attribute.MutableAttribute("org.example", "foo",
                                       description="bar",
                                       default="baz")
     knd = kind.Kind("scheme", "term", "title",
                     attributes=attribute.AttributeCollection({
                         "org.example": attr}
                     ))
     r = self.renderer.get_renderer(knd)
     observed = r.render()
     self.assertKindAttr(knd, attr, observed)
Exemple #14
0
 def test_object_attr(self):
     attr = attribute.MutableAttribute("org.example")
     r = self.renderer.get_renderer(attr)
     observed = r.render()
     expected = {
         "org.example": {
             "type": "string",
             "required": False,
             "mutable": True,
         }
     }
     self.assertEqual(expected, json.loads(observed))
Exemple #15
0
    def __init__(self, mixins, source, target, id=None, interface=None,
                 mac=None, state=None):

        super(NetworkInterface, self).__init__(None, mixins, source,
                                               target, id)

        self.attributes["occi.networkinterface.interface"] = (
            attr.InmutableAttribute("occi.networkinterface.interface",
                                    interface))
        self.attributes["occi.networkinterface.mac"] = attr.MutableAttribute(
            "occi.networkinterface.mac", mac)
        self.attributes["occi.networkinterface.state"] = (
            attr.InmutableAttribute("occi.networkinterface.state", state))
Exemple #16
0
    def __init__(self, title=None, summary=None,
                 id=None, vlan=None, label=None, state=None,
                 address=None, gateway=None, ip_version=None, allocation=None):

        super(OSNetworkResource,
              self).__init__(title=title,
                             summary=summary, id=id, vlan=vlan,
                             label=label, state=state,
                             mixins=[network.ip_network, OSNetwork()])
        # subnet
        self.attributes["org.openstack.network.ip_version"] = (
            attr.MutableAttribute(
                "org.openstack.network.ip_version", ip_version))
        self.attributes["occi.network.address"] = (
            attr.MutableAttribute(
                "occi.network.address", address))
        self.attributes["occi.network.gateway"] = (
            attr.MutableAttribute(
                "occi.network.gateway", gateway))
        self.attributes["occi.network.allocation"] = (
            attr.MutableAttribute(
                "occi.network.allocation", allocation))
Exemple #17
0
 def test_boolean_attr(self):
     attr = attribute.MutableAttribute(
         "org.example", attr_type=attribute.AttributeType.boolean_type)
     r = self.renderer.get_renderer(attr)
     observed = r.render()
     expected = {
         "org.example": {
             "type": "boolean",
             "required": False,
             "mutable": True,
         }
     }
     self.assertEqual(expected, json.loads(observed))
Exemple #18
0
    def __init__(self, title, mixins, id=None):
        helpers.check_type(mixins, mixin.Mixin)
        self.mixins = mixins

        # NOTE(aloga): we need a copy of the attributes, otherwise we will be
        # using the class ones instead of the object ones.
        self.attributes = self.attributes.copy()

        # damn, we're shading a builtin
        if id is None:
            id = uuid.uuid4().hex

        self.attributes["occi.core.id"] = attribute.InmutableAttribute(
            "occi.core.id", id)
        self.attributes["occi.core.title"] = attribute.MutableAttribute(
            "occi.core.title", title)
Exemple #19
0
class SecurityGroupResource(resource.Resource):
    attributes = attr.AttributeCollection({
        "occi.securitygroup.rules":
        attr.MutableAttribute("occi.securitygroup.rules",
                              description="Security Rules",
                              attr_type=attr.AttributeType.list_type),
        "occi.securitygroup.state":
        attr.InmutableAttribute("occi.securitygroup.state",
                                description="Current state of the instance",
                                attr_type=attr.AttributeType.string_type)
    })
    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'securitygroup',
                     'securitygroup resource',
                     attributes,
                     'securitygroup/',
                     parent=resource.Resource.kind)

    def __init__(self,
                 title,
                 id=None,
                 rules=None,
                 summary=None,
                 state=None,
                 mixins=[]):
        super(SecurityGroupResource, self).__init__(title,
                                                    mixins,
                                                    summary=summary,
                                                    id=id)
        self.rules = rules
        self.attributes["occi.securitygroup.state"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.securitygroup.state"], state))

    @property
    def rules(self):
        return self.attributes["occi.securitygroup.rules"].value

    @rules.setter
    def rules(self, value):
        self.attributes["occi.securitygroup.rules"].value = value

    @property
    def state(self):
        return self.attributes["occi.securitygroup.state"].value
Exemple #20
0
    def __init__(self, ssh_key=None):
        attrs = [
            attribute.MutableAttribute(
                "occi.crendentials.ssh.publickey",
                ssh_key,
                required=True,
                description=("The contents of the public key file to be "
                             "injected into the Compute Resource"),
                attr_type=attribute.AttributeType.string_type),
        ]

        attrs = attribute.AttributeCollection({a.name: a for a in attrs})

        super(SSHKey, self).__init__(SSHKey.scheme,
                                     SSHKey.term,
                                     "Credentials mixin",
                                     attributes=attrs,
                                     applies=[compute.ComputeResource.kind])
Exemple #21
0
    def __init__(self, user_data=None):
        attrs = [
            attribute.MutableAttribute(
                "occi.compute.userdata",
                user_data,
                required=True,
                description=("Contextualization data (e.g., script, "
                             "executable) that the client supplies once and "
                             "only once. It cannot be updated."),
                attr_type=attribute.AttributeType.string_type),
        ]

        attrs = attribute.AttributeCollection({a.name: a for a in attrs})

        super(UserData, self).__init__(UserData.scheme,
                                       UserData.term,
                                       "Contextualization mixin",
                                       attributes=attrs,
                                       applies=[compute.ComputeResource.kind])
Exemple #22
0
    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])
Exemple #23
0
class NetworkResource(resource.Resource):
    attributes = attr.AttributeCollection({
        "occi.network.vlan":
        attr.MutableAttribute("occi.network.vlan",
                              description="802.1q VLAN identifier",
                              attr_type=attr.AttributeType.string_type),
        "occi.network.label":
        attr.MutableAttribute("occi.network.label",
                              description="Tag based VLANs",
                              attr_type=attr.AttributeType.string_type),
        "occi.network.state":
        attr.InmutableAttribute("occi.network.state",
                                description="Current state of the instance",
                                attr_type=attr.AttributeType.string_type),
        "occi.network.state.message":
        attr.InmutableAttribute(
            "occi.network.state.message",
            description=("Human-readable explanation of the current instance "
                         "state"),
            attr_type=attr.AttributeType.string_type),
    })

    actions = (up, down)
    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'network',
                     'network resource',
                     attributes,
                     'network/',
                     actions=actions,
                     parent=resource.Resource.kind)

    def __init__(self,
                 title,
                 summary=None,
                 id=None,
                 vlan=None,
                 label=None,
                 state=None,
                 message=None,
                 mixins=[]):
        super(NetworkResource, self).__init__(title,
                                              mixins,
                                              summary=summary,
                                              id=id)
        self.vlan = vlan
        self.label = label
        self.attributes["occi.network.state"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.network.state"], state))
        self.attributes["occi.network.state.message"] = (
            attr.InmutableAttribute(
                self.attributes["occi.network.state.message"], message))

    @property
    def vlan(self):
        return self.attributes["occi.network.vlan"].value

    @vlan.setter
    def vlan(self, value):
        self.attributes["occi.network.vlan"].value = value

    @property
    def label(self):
        return self.attributes["occi.network.label"].value

    @label.setter
    def label(self, value):
        self.attributes["occi.network.label"].value = value

    @property
    def state(self):
        return self.attributes["occi.network.state"].value

    @property
    def message(self):
        return self.attributes["occi.network.state.message"].value
Exemple #24
0
 def test_mutable(self):
     attr = attribute.MutableAttribute("occi.foo.bar", "bar")
     attr.value = "bazonk"
     self.assertEqual("bazonk", attr.value)
Exemple #25
0
 def test_mutable(self):
     attr = attribute.MutableAttribute("occi.foo.bar", "bar")
     attr.value = "bazonk"
     self.assertEqual("bazonk", attr.value)
     self.assertEqual(attribute.AttributeType.object_type, attr.attr_type)
Exemple #26
0
class ComputeResource(resource.Resource):
    attributes = attr.AttributeCollection({
        "occi.compute.architecture":
        attr.MutableAttribute("occi.compute.architecture",
                              description="CPU architecture of the instance",
                              attr_type=attr.AttributeType.string_type),
        "occi.compute.cores":
        attr.MutableAttribute(
            "occi.compute.cores",
            description="Number of virtual cores assigned to the instance",
            attr_type=attr.AttributeType.number_type),
        "occi.compute.hostname":
        attr.MutableAttribute(
            "occi.compute.hostname",
            description="Fully Qualified DNS hostname for the instance",
            attr_type=attr.AttributeType.string_type),
        "occi.compute.share":
        attr.MutableAttribute(
            "occi.compute.share",
            description="Relative number of CPU shares for the instance",
            attr_type=attr.AttributeType.number_type),
        "occi.compute.memory":
        attr.MutableAttribute(
            "occi.compute.memory",
            description="Maximum RAM in gigabytes allocated to the instance",
            attr_type=attr.AttributeType.number_type),
        "occi.compute.state":
        attr.InmutableAttribute("occi.compute.state",
                                description="Current state of the instance",
                                attr_type=attr.AttributeType.string_type),
        "occi.compute.state.message":
        attr.InmutableAttribute(
            "occi.compute.state.message",
            description=("Human-readable explanation of the current instance "
                         "state"),
            attr_type=attr.AttributeType.string_type),
    })

    actions = (start, stop, restart, suspend)
    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'compute',
                     'compute resource',
                     attributes,
                     'compute/',
                     actions=actions,
                     parent=resource.Resource.kind)

    def __init__(self,
                 title,
                 summary=None,
                 id=None,
                 architecture=None,
                 cores=None,
                 hostname=None,
                 share=None,
                 memory=None,
                 state=None,
                 message=None,
                 mixins=[]):

        super(ComputeResource, self).__init__(title,
                                              mixins,
                                              summary=summary,
                                              id=id)

        self.architecture = architecture
        self.cores = cores
        self.hostname = hostname
        self.share = share
        self.memory = memory
        self.attributes["occi.compute.state"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.compute.state"], state))
        self.attributes["occi.compute.state.message"] = (
            attr.InmutableAttribute(
                self.attributes["occi.compute.state.message"], message))

    @property
    def architecture(self):
        return self.attributes["occi.compute.architecture"].value

    @architecture.setter
    def architecture(self, value):
        self.attributes["occi.compute.architecture"].value = value

    @property
    def cores(self):
        return self.attributes["occi.compute.cores"].value

    @cores.setter
    def cores(self, value):
        self.attributes["occi.compute.cores"].value = value

    @property
    def hostname(self):
        return self.attributes["occi.compute.hostname"].value

    @hostname.setter
    def hostname(self, value):
        self.attributes["occi.compute.hostname"].value = value

    @property
    def share(self):
        return self.attributes["occi.compute.share"].value

    @share.setter
    def share(self, value):
        self.attributes["occi.compute.share"].value = value

    @property
    def memory(self):
        return self.attributes["occi.compute.memory"].value

    @memory.setter
    def memory(self, value):
        self.attributes["occi.compute.memory"].value = value

    @property
    def state(self):
        return self.attributes["occi.compute.state"].value

    @property
    def message(self):
        return self.attributes["occi.compute.state.message"].value
Exemple #27
0
class StorageResource(resource.Resource):
    attributes = attr.AttributeCollection({
        "occi.storage.size":
        attr.MutableAttribute(
            "occi.storage.size",
            required=True,
            description="Storage size of the instance in gigabytes",
            attr_type=attr.AttributeType.number_type),
        "occi.storage.state":
        attr.InmutableAttribute("occi.storage.state",
                                description="Current state of the instance",
                                attr_type=attr.AttributeType.string_type),
        "occi.storage.state.message":
        attr.InmutableAttribute(
            "occi.storage.state.message",
            description=("Human-readable explanation of the current instance "
                         "state"),
            attr_type=attr.AttributeType.string_type),
    })
    actions = (online, offline, backup, snapshot, resize)
    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'storage',
                     'storage resource',
                     attributes,
                     'storage/',
                     actions=actions,
                     parent=resource.Resource.kind)

    def __init__(self,
                 title,
                 summary=None,
                 id=None,
                 size=None,
                 state=None,
                 message=None):
        mixins = []
        super(StorageResource, self).__init__(title,
                                              mixins,
                                              summary=summary,
                                              id=id)
        self.size = size
        self.attributes["occi.storage.state"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.storage.state"], state))
        self.attributes["occi.storage.state.message"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.storage.state.message"], message))

    @property
    def size(self):
        return self.attributes["occi.storage.size"].value

    @size.setter
    def size(self, value):
        self.attributes["occi.storage.size"].value = value

    @property
    def state(self):
        return self.attributes["occi.storage.state"].value

    @property
    def message(self):
        return self.attributes["occi.storage.state.message"].value
Exemple #28
0
 def __init__(self, title, mixins, source, target, id=None):
     super(Link, self).__init__(title, mixins, id)
     self.attributes["occi.core.source"] = attribute.MutableAttribute(
         "occi.core.source", source)
     self.attributes["occi.core.target"] = attribute.MutableAttribute(
         "occi.core.target", target)
Exemple #29
0
class OSNetworkInterface(network_link.NetworkInterface):
    # TODO(enolfc): these are duplicated in the ipnetwork_interface mixin
    attributes = attr.AttributeCollection({
        "occi.networkinterface.address":
        attr.MutableAttribute(
            "occi.networkinterface.address",
            description="Internet Protocol (IP) network address of the link",
            attr_type=attr.AttributeType.string_type),
        "occi.networkinterface.gateway":
        attr.MutableAttribute(
            "occi.networkinterface.gateway",
            description="Internet Protocol (IP) network address",
            attr_type=attr.AttributeType.string_type),
        "occi.networkinterface.allocation":
        attr.MutableAttribute(
            "occi.networkinterface.allocation",
            description="Address allocation mechanism: dynamic, static",
            attr_type=attr.AttributeType.string_type),
    })

    def __init__(self,
                 source,
                 target,
                 mac,
                 address,
                 ip_id=None,
                 pool=None,
                 state='active'):
        link_id = '_'.join([source.id, address])
        mixins = [network_link.ip_network_interface]
        if pool:
            mixins.append(OSFloatingIPPool(pool))
        super(OSNetworkInterface, self).__init__(mixins, source, target,
                                                 link_id, "eth0", mac, state)
        self.ip_id = ip_id
        self.address = address
        self.gateway = None
        self.allocation = "dynamic"

    @property
    def address(self):
        return self.attributes["occi.networkinterface.address"].value

    @address.setter
    def address(self, value):
        self.attributes["occi.networkinterface.address"].value = value

    @property
    def gateway(self):
        return self.attributes["occi.networkinterface.gateway"].value

    @gateway.setter
    def gateway(self, value):
        self.attributes["occi.networkinterface.gateway"].value = value

    @property
    def allocation(self):
        return self.attributes["occi.networkinterface.allocation"].value

    @allocation.setter
    def allocation(self, value):
        self.attributes["occi.networkinterface.allocation"].value = value
Exemple #30
0
class OSNetworkResource(network.NetworkResource):
    # TODO(enolfc): most of these are duplicated in the ipnetwork mixin
    attributes = attr.AttributeCollection({
        "occi.network.address":
        attr.MutableAttribute(
            "occi.network.address",
            required=True,
            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),
        "org.openstack.network.ip_version":
        attr.MutableAttribute("org.openstack.network.ip_version",
                              description="Internet Protocol (IP) version",
                              attr_type=attr.AttributeType.number_type),
    })

    def __init__(self,
                 title=None,
                 summary=None,
                 id=None,
                 vlan=None,
                 label=None,
                 state=None,
                 address=None,
                 gateway=None,
                 ip_version=None,
                 allocation=None):

        super(OSNetworkResource,
              self).__init__(title=title,
                             summary=summary,
                             id=id,
                             vlan=vlan,
                             label=label,
                             state=state,
                             mixins=[network.ip_network,
                                     OSNetwork()])
        # subnet
        self.address = address
        self.gateway = gateway
        self.ip_version = ip_version
        self.allocation = allocation

    @property
    def ip_version(self):
        return self.attributes["org.openstack.network.ip_version"].value

    @ip_version.setter
    def ip_version(self, value):
        self.attributes["org.openstack.network.ip_version"].value = value

    @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