示例#1
0
文件: network.py 项目: GOSC-CNIC/gosc
class NetworkInterface(core.Link):
    attributes = {
        "occi.networkinterface.interface": core.ImmutableAttribute(
            name="occi.networkinterface.interface",
            description="Identifier that relates the link to the link's device interface.",
            attr_type=core.AttributeType.STRING),
        "occi.networkinterface.mac": core.MutableAttribute(
            name="occi.networkinterface.mac",
            description="MAC address associated with the link's device interface.",
            attr_type=core.AttributeType.STRING),
        "occi.networkinterface.state": core.ImmutableAttribute(
            name="occi.networkinterface.state",
            description="Current state of the instance",
            attr_type=core.AttributeType.STRING),
        "occi.networkinterface.state.message": core.ImmutableAttribute(
            name="occi.networkinterface.state.message",
            description="Human-readable explanation of the current instance state",
            attr_type=core.AttributeType.STRING),
    }

    kind = core.Kind(scheme=core.build_scheme('infrastructure'), term='networkinterface',
                     title='network link resource', attributes=attributes, location='networklink/',
                     parent=core.Link.kind)

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

        super(NetworkInterface, self).__init__(_id=_id, title=None, mixins=mixins, source=source, target=target)

        self.attributes["occi.networkinterface.interface"] = core.ImmutableAttribute.from_attr(
            self.attributes["occi.networkinterface.interface"], interface)
        self.mac = mac
        self.attributes["occi.networkinterface.state"] = core.ImmutableAttribute.from_attr(
            self.attributes["occi.networkinterface.state"], state)
        self.attributes["occi.networkinterface.state.message"] = core.ImmutableAttribute.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
示例#2
0
文件: network.py 项目: GOSC-CNIC/gosc
class Network(core.Resource):
    attributes = {
        "occi.network.vlan": core.MutableAttribute(
            name="occi.network.vlan", description="802.1q VLAN identifier",
            attr_type=core.AttributeType.string_type),
        "occi.network.label": core.MutableAttribute(
            name="occi.network.label", description="Tag based VLANs",
            attr_type=core.AttributeType.string_type),
        "occi.network.state": core.ImmutableAttribute(
            name="occi.network.state", description="Current state of the instance",
            attr_type=core.AttributeType.string_type),
        "occi.network.state.message": core.ImmutableAttribute(
            name="occi.network.state.message",
            description="Human-readable explanation of the current instance state",
            attr_type=core.AttributeType.string_type),
    }

    actions = NetworkActions.actions
    kind = core.Kind(scheme=core.build_scheme('infrastructure'), term='network',
                     title='network resource', attributes=attributes, location='network/',
                     actions=actions, parent=core.Resource.kind)

    def __init__(self, title, summary=None, _id=None, vlan=None, label=None,
                 state=None, message=None, mixins=None):
        super(Network, self).__init__(_id=_id, title=title, mixins=mixins, summary=summary)
        self.vlan = vlan
        self.label = label
        self.attributes["occi.network.state"] = core.ImmutableAttribute.from_attr(
            self.attributes["occi.network.state"], state)
        self.attributes["occi.network.state.message"] = core.ImmutableAttribute(
            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
示例#3
0
文件: storage.py 项目: GOSC-CNIC/gosc
class Storage(core.Resource):
    attributes = {
        "occi.storage.size":
        core.MutableAttribute(
            name="occi.storage.size",
            required=True,
            description="Storage size of the instance in gigabytes",
            attr_type=core.AttributeType.NUMBER),
        "occi.storage.state":
        core.ImmutableAttribute(name="occi.storage.state",
                                description="Current state of the instance",
                                attr_type=core.AttributeType.STRING),
        "occi.storage.state.message":
        core.ImmutableAttribute(
            name="occi.storage.state.message",
            description=
            "Human-readable explanation of the current instance state",
            attr_type=core.AttributeType.STRING),
    }
    actions = StorageActions.actions
    kind = core.Kind(scheme=core.build_scheme('infrastructure'),
                     term='storage',
                     title='storage resource',
                     attributes=attributes,
                     location='storage/',
                     actions=actions,
                     parent=core.Resource.kind)

    def __init__(self,
                 title='Storage Resource',
                 summary=None,
                 _id=None,
                 size=None,
                 state=None,
                 message=None):
        mixins = []
        super(Storage, self).__init__(_id=_id,
                                      title=title,
                                      mixins=mixins,
                                      summary=summary)
        self.size = size
        self.attributes[
            "occi.storage.state"] = core.ImmutableAttribute.from_attr(
                self.attributes["occi.storage.state"], state)
        self.attributes[
            "occi.storage.state.message"] = core.ImmutableAttribute.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
示例#4
0
文件: compute.py 项目: GOSC-CNIC/gosc
class Compute(core.Resource):
    attributes = {
        "occi.compute.architecture": core.MutableAttribute(
            name="occi.compute.architecture",
            description="CPU architecture of the instance",
            attr_type=core.AttributeType.STRING),
        "occi.compute.cores": core.MutableAttribute(
            name="occi.compute.cores",
            description="Number of virtual CPU cores assigned to the instance",
            attr_type=core.AttributeType.NUMBER),
        "occi.compute.hostname": core.MutableAttribute(
            name="occi.compute.hostname",
            description="Fully Qualified DNS hostname for the instance",
            attr_type=core.AttributeType.STRING),
        "occi.compute.share": core.MutableAttribute(
            name="occi.compute.share",
            description="Relative number of CPU shares for the instance",
            attr_type=core.AttributeType.NUMBER),
        "occi.compute.memory": core.MutableAttribute(
            name="occi.compute.memory",
            description="Maximum RAM in gigabytes allocated to the instance",
            attr_type=core.AttributeType.NUMBER),
        "occi.compute.state": core.ImmutableAttribute(
            name="occi.compute.state", description="Current state of the instance",
            attr_type=core.AttributeType.STRING),
        "occi.compute.state.message": core.ImmutableAttribute(
            name="occi.compute.state.message",
            description="Human-readable explanation of the current instance state",
            attr_type=core.AttributeType.STRING),
    }
    actions = ComputeActions.actions
    kind = core.Kind(scheme=core.build_scheme('infrastructure'), term='compute', title='compute resource',
                     attributes=attributes, location='compute/', actions=actions,
                     parent=core.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=None):
        super(Compute, self).__init__(_id=_id, title=title, mixins=mixins, summary=summary)
        self.architecture = architecture
        self.cores = cores
        self.hostname = hostname
        self.share = share
        self.memory = memory
        self.attributes["occi.compute.state"] = core.ImmutableAttribute.from_attr(
            self.attributes["occi.compute.state"], state)
        self.attributes["occi.compute.state.message"] = core.ImmutableAttribute.from_attr(
            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
示例#5
0
文件: storage.py 项目: GOSC-CNIC/gosc
class StorageLink(core.Link):
    attributes = {
        "occi.storagelink.deviceid":
        core.MutableAttribute(
            name="occi.storagelink.deviceid",
            description=
            "Device identifier as defined by the OCCI service provider",
            attr_type=core.AttributeType.STRING),
        "occi.storagelink.mountpoint":
        core.MutableAttribute(
            name="occi.storagelink.mountpoint",
            description="Point to where the storage is mounted in the guest OS",
            attr_type=core.AttributeType.STRING),
        "occi.storagelink.state":
        core.ImmutableAttribute(name="occi.storagelink.state",
                                description="Current state of the instance",
                                attr_type=core.AttributeType.STRING),
        "occi.storagelink.state.message":
        core.ImmutableAttribute(
            name="occi.storagelink.state.message",
            description=
            "Human-readable explanation of the current instance state",
            attr_type=core.AttributeType.string_type),
    }
    kind = core.Kind(scheme=core.build_scheme('infrastructure'),
                     term='storagelink',
                     title='storage link resource',
                     attributes=attributes,
                     location='storagelink/',
                     parent=core.Link.kind)

    def __init__(self,
                 source,
                 target,
                 device_id=None,
                 mount_point=None,
                 state=None,
                 message=None):

        link_id = '_'.join([source.id, target.id])
        super(StorageLink, self).__init__(None, [], source, target, link_id)

        self.deviceid = device_id
        self.mountpoint = mount_point
        self.attributes[
            "occi.storagelink.state"] = core.ImmutableAttribute.from_attr(
                self.attributes["occi.storagelink.state"], state)
        self.attributes[
            "occi.storagelink.state.message"] = core.ImmutableAttribute.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