Пример #1
0
class SecurityGroupLink(link.Link):
    attributes = attr.AttributeCollection({
        "occi.securitygrouplink.state":
        attr.InmutableAttribute("occi.securitygrouplink.state",
                                description="Current state of the instance",
                                attr_type=attr.AttributeType.string_type)
    })
    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'securitygrouplink',
                     'security group link resource',
                     attributes,
                     'securitygrouplink/',
                     parent=link.Link.kind)

    def __init__(self, source, target, state=None):
        link_id = '_'.join([source.id, target.id])
        super(SecurityGroupLink, self).__init__(None, [], source, target,
                                                link_id)

        self.attributes["occi.securitygrouplink.state"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.securitygrouplink.state"], state))

    @property
    def state(self):
        return self.attributes["occi.securitygrouplink.state"].value
Пример #2
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", "occi.core.target"])

    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.attributes["occi.core.source"] = attribute.MutableAttribute(
            "occi.core.source", source)
        self.attributes["occi.core.target"] = attribute.MutableAttribute(
            "occi.core.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
Пример #3
0
class StorageResource(resource.Resource):
    attributes = attr.AttributeCollection(
        ["occi.storage.size", "occi.storage.state"])
    actions = (online, offline, backup, snapshot, resize)
    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'storage',
                     'storage resource',
                     attributes,
                     'storage/',
                     actions=actions,
                     related=[resource.Resource.kind])

    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)

    @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
Пример #4
0
Файл: base.py Проект: A1ve5/ooi
 def test_mixed_collection(self):
     res = resource.Resource("foo", [], uuid.uuid4().hex)
     knd = kind.Kind("scheme", "term", "title")
     c = collection.Collection(kinds=[knd], resources=[res])
     r = self.renderer.get_renderer(c)
     observed = r.render()
     self.assertMixedCollection(knd, res, observed)
Пример #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
Пример #6
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
Пример #7
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)
Пример #8
0
Файл: base.py Проект: A1ve5/ooi
 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)
Пример #9
0
class NetworkResource(resource.Resource):
    attributes = attr.AttributeCollection(
        ["occi.network.vlan", "occi.network.label", "occi.network.state"])
    actions = (up, down)
    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'network',
                     'network resource',
                     attributes,
                     '/network/',
                     actions=actions,
                     related=[resource.Resource.kind])

    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)

    @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
Пример #10
0
class StorageLink(link.Link):
    attributes = attr.AttributeCollection([
        "occi.storagelink.deviceid", "occi.storagelink.mountpoint",
        "occi.storagelink.state"
    ])
    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'storagelink',
                     'storage link resource',
                     attributes,
                     '/storagelink/',
                     related=[link.Link.kind])

    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)

    @property
    def deviceid(self):
        return self.attributes["occi.storagelink.deviceid"].value

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

    @property
    def mountpoint(self):
        return self.attributes["occi.storagelink.mountpoint"].value

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

    @property
    def state(self):
        return self.attributes["occi.storagelink.state"].value
Пример #11
0
class NetworkInterface(link.Link):
    attributes = attr.AttributeCollection([
        "occi.networkinterface.interface", "occi.networkinterface.mac",
        "occi.networkinterface.state"
    ])
    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'networkinterface',
                     'network link resource',
                     attributes,
                     'networklink/',
                     related=[link.Link.kind])

    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))

    @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
Пример #12
0
Файл: link.py Проект: A1ve5/ooi
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
Пример #13
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
Пример #14
0
class ComputeResource(resource.Resource):
    attributes = attr.AttributeCollection([
        "occi.compute.architecture", "occi.compute.cores",
        "occi.compute.hostname", "occi.compute.speed", "occi.compute.memory",
        "occi.compute.state"
    ])
    actions = (start, stop, restart, suspend)
    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'compute',
                     'compute resource',
                     attributes,
                     'compute/',
                     actions=actions,
                     related=[resource.Resource.kind])

    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)

    @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 speed(self):
        return self.attributes["occi.compute.speed"].value

    @speed.setter
    def speed(self, value):
        self.attributes["occi.compute.speed"].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
Пример #15
0
Файл: base.py Проект: A1ve5/ooi
 def test_kind(self):
     knd = kind.Kind("scheme", "term", "title")
     self.get_render_and_assert(knd)
Пример #16
0
class NetworkInterface(link.Link):
    attributes = attr.AttributeCollection({
        "occi.networkinterface.interface":
        attr.InmutableAttribute(
            "occi.networkinterface.interface",
            description=("Identifier that relates the link to the link's "
                         "device interface."),
            attr_type=attr.AttributeType.string_type),
        "occi.networkinterface.mac":
        attr.MutableAttribute(
            "occi.networkinterface.mac",
            description=("MAC address associated with the link's device "
                         "interface."),
            attr_type=attr.AttributeType.string_type),
        "occi.networkinterface.state":
        attr.InmutableAttribute("occi.networkinterface.state",
                                description="Current state of the instance",
                                attr_type=attr.AttributeType.string_type),
        "occi.networkinterface.state.message":
        attr.InmutableAttribute(
            "occi.networkinterface.state.message",
            description=("Human-readable explanation of the current instance "
                         "state"),
            attr_type=attr.AttributeType.string_type),
    })

    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'networkinterface',
                     'network link resource',
                     attributes,
                     'networklink/',
                     parent=link.Link.kind)

    def __init__(self,
                 mixins,
                 source,
                 target,
                 id=None,
                 interface=None,
                 mac=None,
                 state=None,
                 message=None):

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

        self.attributes["occi.networkinterface.interface"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.networkinterface.interface"], interface))
        self.mac = mac
        self.attributes["occi.networkinterface.state"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.networkinterface.state"], state))
        self.attributes["occi.networkinterface.state.message"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.networkinterface.state.message"],
                message))

    @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

    @property
    def message(self):
        return self.attributes["occi.networkinterface.state.message"].value
Пример #17
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
Пример #18
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
Пример #19
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
Пример #20
0
class StorageLink(link.Link):
    attributes = attr.AttributeCollection({
        "occi.storagelink.deviceid":
        attr.MutableAttribute(
            "occi.storagelink.deviceid",
            description=("Device identifier as defined by the OCCI service "
                         "provider"),
            attr_type=attr.AttributeType.string_type),
        "occi.storagelink.mountpoint":
        attr.MutableAttribute(
            "occi.storagelink.mountpoint",
            description=("Point to where the storage is mounted "
                         "in the guest OS"),
            attr_type=attr.AttributeType.string_type),
        "occi.storagelink.state":
        attr.InmutableAttribute("occi.storagelink.state",
                                description="Current state of the instance",
                                attr_type=attr.AttributeType.string_type),
        "occi.storagelink.state.message":
        attr.InmutableAttribute(
            "occi.storagelink.state.message",
            description=("Human-readable explanation of the current instance "
                         "state"),
            attr_type=attr.AttributeType.string_type),
    })
    kind = kind.Kind(helpers.build_scheme('infrastructure'),
                     'storagelink',
                     'storage link resource',
                     attributes,
                     'storagelink/',
                     parent=link.Link.kind)

    def __init__(self,
                 source,
                 target,
                 deviceid=None,
                 mountpoint=None,
                 state=None,
                 message=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.deviceid = deviceid
        self.mountpoint = mountpoint
        self.attributes["occi.storagelink.state"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.storagelink.state"], state))
        self.attributes["occi.storagelink.state.message"] = (
            attr.InmutableAttribute.from_attr(
                self.attributes["occi.storagelink.state.message"], message))

    @property
    def deviceid(self):
        return self.attributes["occi.storagelink.deviceid"].value

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

    @property
    def mountpoint(self):
        return self.attributes["occi.storagelink.mountpoint"].value

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

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

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