class EthernetPort(port.Port, object_base.VersionedObjectDictCompat): fields = dict( { 'mac': object_fields.StringField(nullable=True), 'mtu': object_fields.IntegerField(nullable=True), 'speed': object_fields.IntegerField(nullable=True), 'link_mode': object_fields.StringField(nullable=True), 'duplex': object_fields.IntegerField(nullable=True), 'autoneg': object_fields.StringField(nullable=True), 'bootp': object_fields.StringField(nullable=True) }, **port.Port.fields) @classmethod def get_by_uuid(cls, context, uuid): db_ethernet_port = cls.dbapi.ethernet_port_get(uuid) return cls._from_db_object(context, cls(), db_ethernet_port) def save_changes(self, context, updates): self.dbapi.ethernet_port_update(self.uuid, updates) @classmethod def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None, filters=None): """Return a list of EthernetPort objects. :param cls: the :class:`EthernetPort` :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :param filters: Filters to apply. :returns: a list of :class:`EthernetPort` object. """ db_ethernet_ports = cls.dbapi.ethernet_port_get_list(filters=filters, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_ethernet_ports) @classmethod def get_by_host(cls, context, host_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_ethernet_ports = cls.dbapi.ethernet_port_get_by_host( host_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_ethernet_ports) @classmethod def get_by_numa_node(cls, context, node_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_ethernet_ports = cls.dbapi.ethernet_port_get_by_numa_node( node_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_ethernet_ports) def create(self, context=None): """Create a EthernetPort record in the DB. Column-wise updates will be made based on the result of self.what_changed(). :param context: Security context. :raises: InvalidParameterValue if some property values are invalid. """ values = self.do_version_changes_for_db() db_ethernet_port = self.dbapi.ethernet_port_create(values) return self._from_db_object(self._context, self, db_ethernet_port)
class PCIDevice(base.InventoryObject, object_base.VersionedObjectDictCompat): dbapi = db_api.get_instance() fields = { 'id': object_fields.IntegerField(nullable=True), 'uuid': object_fields.UUIDField(nullable=True), 'host_id': object_fields.IntegerField(nullable=True), 'host_uuid': object_fields.UUIDField(nullable=True), 'name': object_fields.StringField(nullable=True), 'pciaddr': object_fields.StringField(nullable=True), 'pclass_id': object_fields.StringField(nullable=True), 'pvendor_id': object_fields.StringField(nullable=True), 'pdevice_id': object_fields.StringField(nullable=True), 'pclass': object_fields.StringField(nullable=True), 'pvendor': object_fields.StringField(nullable=True), 'pdevice': object_fields.StringField(nullable=True), 'psvendor': object_fields.StringField(nullable=True), 'psdevice': object_fields.StringField(nullable=True), 'numa_node': object_fields.IntegerField(nullable=True), 'sriov_totalvfs': object_fields.IntegerField(nullable=True), 'sriov_numvfs': object_fields.IntegerField(nullable=True), 'sriov_vfs_pci_address': object_fields.StringField(nullable=True), 'driver': object_fields.StringField(nullable=True), 'enabled': object_fields.BooleanField(nullable=True), 'extra_info': object_fields.StringField(nullable=True), } _foreign_fields = {'host_uuid': 'host:uuid'} @classmethod def get_by_uuid(cls, context, uuid): db_pci_device = cls.dbapi.pci_device_get(uuid) return cls._from_db_object(context, cls(), db_pci_device) def save_changes(self, context, updates): self.dbapi.pci_device_update(self.uuid, updates) @classmethod def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None): """Return a list of CPU objects. :param cls: the :class:`CPU` :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :returns: a list of :class:`CPU` object. """ db_pci_devices = cls.dbapi.pci_device_get_list(limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_pci_devices) @classmethod def get_by_host(cls, context, host_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_pci_devices = cls.dbapi.pci_device_get_by_host(host_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_pci_devices) def create(self, context=None): """Create a CPU record in the DB. Column-wise updates will be made based on the result of self.what_changed(). :param context: Security context. """ values = self.do_version_changes_for_db() db_pci_device = self.dbapi.pci_device_create(values) return self._from_db_object(self._context, self, db_pci_device)
class Port(base.InventoryObject, object_base.VersionedObjectDictCompat): dbapi = db_api.get_instance() fields = { 'id': object_fields.IntegerField(), 'uuid': object_fields.UUIDField(nullable=True), 'host_id': object_fields.IntegerField(nullable=True), 'host_uuid': object_fields.UUIDField(nullable=True), 'node_id': object_fields.IntegerField(nullable=True), 'node_uuid': object_fields.UUIDField(nullable=True), 'type': object_fields.StringField(nullable=True), 'name': object_fields.StringField(nullable=True), 'namedisplay': object_fields.StringField(nullable=True), 'pciaddr': object_fields.StringField(nullable=True), 'dev_id': object_fields.IntegerField(nullable=True), 'pclass': object_fields.StringField(nullable=True), 'pvendor': object_fields.StringField(nullable=True), 'pdevice': object_fields.StringField(nullable=True), 'psvendor': object_fields.StringField(nullable=True), 'dpdksupport': object_fields.BooleanField(nullable=True), 'psdevice': object_fields.StringField(nullable=True), 'numa_node': object_fields.IntegerField(nullable=True), 'sriov_totalvfs': object_fields.IntegerField(nullable=True), 'sriov_numvfs': object_fields.IntegerField(nullable=True), 'sriov_vfs_pci_address': object_fields.StringField(nullable=True), 'driver': object_fields.StringField(nullable=True), 'capabilities': object_fields.FlexibleDictField(nullable=True), } # interface_uuid is in systemconfig _foreign_fields = { 'host_uuid': 'host:uuid', 'node_uuid': 'node:uuid', } @classmethod def get_by_uuid(cls, context, uuid): db_port = cls.dbapi.port_get(uuid) return cls._from_db_object(context, cls(), db_port) def save_changes(self, context, updates): self.dbapi.port_update(self.uuid, updates) @classmethod def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None, filters=None): """Return a list of Port objects. :param cls: the :class:`Port` :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :param filters: Filters to apply. :returns: a list of :class:`Port` object. """ db_ports = cls.dbapi.port_get_list(filters=filters, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_ports) @classmethod def get_by_host(cls, context, host_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_ports = cls.dbapi.port_get_by_host(host_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_ports) @classmethod def get_by_numa_node(cls, context, node_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_ports = cls.dbapi.port_get_by_numa_node(node_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_ports) def create(self, context=None): """Create a EthernetPort record in the DB. Column-wise updates will be made based on the result of self.what_changed(). :param context: Security context. :raises: InvalidParameterValue if some property values are invalid. """ values = self.do_version_changes_for_db() db_port = self.dbapi.port_create(values) return self._from_db_object(self._context, self, db_port)
class SensorGroupAnalog(base.InventoryObject, object_base.VersionedObjectDictCompat): dbapi = db_api.get_instance() fields = { 'id': object_fields.IntegerField(nullable=True), 'uuid': object_fields.UUIDField(nullable=True), 'host_id': object_fields.IntegerField(nullable=True), 'sensorgroupname': object_fields.StringField(nullable=True), 'path': object_fields.StringField(nullable=True), 'sensortype': object_fields.StringField(nullable=True), 'datatype': object_fields.StringField(nullable=True), 'description': object_fields.StringField(nullable=True), 'state': object_fields.StringField(nullable=True), 'possible_states': object_fields.StringField(nullable=True), 'audit_interval_group': object_fields.IntegerField(nullable=True), 'record_ttl': object_fields.StringField(nullable=True), 'algorithm': object_fields.StringField(nullable=True), 'actions_critical_choices': object_fields.StringField(nullable=True), 'actions_major_choices': object_fields.StringField(nullable=True), 'actions_minor_choices': object_fields.StringField(nullable=True), 'actions_minor_group': object_fields.StringField(nullable=True), 'actions_major_group': object_fields.StringField(nullable=True), 'actions_critical_group': object_fields.StringField(nullable=True), 'unit_base_group': object_fields.StringField(nullable=True), 'unit_modifier_group': object_fields.StringField(nullable=True), 'unit_rate_group': object_fields.StringField(nullable=True), 't_minor_lower_group': object_fields.StringField(nullable=True), 't_minor_upper_group': object_fields.StringField(nullable=True), 't_major_lower_group': object_fields.StringField(nullable=True), 't_major_upper_group': object_fields.StringField(nullable=True), 't_critical_lower_group': object_fields.StringField(nullable=True), 't_critical_upper_group': object_fields.StringField(nullable=True), 'suppress': object_fields.StringField(nullable=True), 'capabilities': object_fields.FlexibleDictField(nullable=True) } @object_base.remotable_classmethod def get_by_uuid(cls, context, uuid): return cls.dbapi.isensorgroup_analog_get(uuid) def save_changes(self, context, updates): self.dbapi.isensorgroup_analog_update(self.uuid, updates)
class Memory(base.InventoryObject, object_base.VersionedObjectDictCompat): dbapi = db_api.get_instance() fields = { 'id': object_fields.IntegerField(nullable=True), 'uuid': object_fields.UUIDField(nullable=True), 'node_id': object_fields.IntegerField(nullable=True), 'node_uuid': object_fields.UUIDField(nullable=True), 'host_id': object_fields.IntegerField(nullable=True), 'host_uuid': object_fields.UUIDField(nullable=True), 'numa_node': object_fields.IntegerField(nullable=True), 'memtotal_mib': object_fields.IntegerField(nullable=True), 'memavail_mib': object_fields.IntegerField(nullable=True), 'platform_reserved_mib': object_fields.IntegerField(nullable=True), 'node_memtotal_mib': object_fields.IntegerField(nullable=True), 'hugepages_configured': object_fields.StringField(nullable=True), 'vswitch_hugepages_size_mib': object_fields.IntegerField(nullable=True), 'vswitch_hugepages_reqd': object_fields.IntegerField(nullable=True), 'vswitch_hugepages_nr': object_fields.IntegerField(nullable=True), 'vswitch_hugepages_avail': object_fields.IntegerField(nullable=True), 'vm_hugepages_nr_2M_pending': object_fields.IntegerField(nullable=True), 'vm_hugepages_nr_1G_pending': object_fields.IntegerField(nullable=True), 'vm_hugepages_nr_2M': object_fields.IntegerField(nullable=True), 'vm_hugepages_avail_2M': object_fields.IntegerField(nullable=True), 'vm_hugepages_nr_1G': object_fields.IntegerField(nullable=True), 'vm_hugepages_avail_1G': object_fields.IntegerField(nullable=True), 'vm_hugepages_nr_4K': object_fields.IntegerField(nullable=True), 'vm_hugepages_use_1G': object_fields.StringField(nullable=True), 'vm_hugepages_possible_2M': object_fields.IntegerField(nullable=True), 'vm_hugepages_possible_1G': object_fields.IntegerField(nullable=True), 'capabilities': object_fields.FlexibleDictField(nullable=True), } _foreign_fields = {'host_uuid': 'host:uuid', 'node_uuid': 'node:uuid', 'numa_node': 'node:numa_node'} @classmethod def get_by_uuid(cls, context, uuid): db_memory = cls.dbapi.memory_get(uuid) return cls._from_db_object(context, cls(), db_memory) def save_changes(self, context, updates): self.dbapi.memory_update(self.uuid, updates) @classmethod def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None, filters=None): """Return a list of Memory objects. :param cls: the :class:`Memory` :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :param filters: Filters to apply. :returns: a list of :class:`Memory` object. """ db_memorys = cls.dbapi.memory_get_list( filters=filters, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_memorys) @classmethod def get_by_host(cls, context, host_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_memorys = cls.dbapi.memory_get_by_host( host_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_memorys) @classmethod def get_by_host_node(cls, context, host_uuid, node_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_memorys = cls.dbapi.memory_get_by_host_node( host_uuid, node_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_memorys) @classmethod def get_by_node(cls, context, node_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_memorys = cls.dbapi.memory_get_by_node( node_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_memorys) def create(self, context=None): """Create a Memory record in the DB. Column-wise updates will be made based on the result of self.what_changed(). :param context: Security context. """ values = self.do_version_changes_for_db() db_memory = self.dbapi.memory_create(values) return self._from_db_object(self._context, self, db_memory)
class LLDPAgent(base.InventoryObject, object_base.VersionedObjectDictCompat): dbapi = db_api.get_instance() fields = { 'id': object_fields.IntegerField(nullable=True), 'uuid': object_fields.UUIDField(nullable=True), 'status': object_fields.StringField(nullable=True), 'host_id': object_fields.IntegerField(nullable=True), 'host_uuid': object_fields.StringField(nullable=True), 'port_id': object_fields.IntegerField(nullable=True), 'port_uuid': object_fields.UUIDField(nullable=True), 'port_name': object_fields.StringField(nullable=True), 'port_namedisplay': object_fields.StringField(nullable=True) } _foreign_fields = { 'host_uuid': 'host:uuid', 'port_uuid': 'port:uuid', 'port_name': 'port:name', 'port_namedisplay': 'port:namedisplay', } for tlv in k_lldp.LLDP_TLV_VALID_LIST: fields.update({tlv: object_fields.StringField(nullable=True)}) _foreign_fields.update({tlv: get_lldp_tlvs}) @classmethod def get_by_uuid(cls, context, uuid): db_lldp_agent = cls.dbapi.lldp_agent_get(uuid) return cls._from_db_object(context, cls(), db_lldp_agent) def save_changes(self, context, updates): self.dbapi.lldp_agent_update(self.uuid, updates) @classmethod def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None, filters=None): """Return a list of LLDPAgent objects. :param cls: the :class:`LLDPAgent` :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :param filters: Filters to apply. :returns: a list of :class:`LLDPAgent` object. """ db_lldp_agents = cls.dbapi.lldp_agent_get_list(filters=filters, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_lldp_agents) @classmethod def get_by_host(cls, context, host_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_lldp_agents = cls.dbapi.lldp_agent_get_by_host(host_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_lldp_agents) @classmethod def get_by_port(cls, context, port_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_lldp_agents = cls.dbapi.lldp_agent_get_by_port(port_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_lldp_agents) def create(self, context, portid, hostid, values): """Create a LLDPAgent record in the DB. Column-wise updates will be made based on the result of self.what_changed(). :param context: Security context. :param portid: port id :param hostid: host id :param values: dictionary of values """ values = self.do_version_changes_for_db() db_lldp_agent = self.dbapi.lldp_agent_create(portid, hostid, values) return self._from_db_object(self._context, self, db_lldp_agent)
class Node(base.InventoryObject, object_base.VersionedObjectDictCompat): dbapi = db_api.get_instance() fields = { 'id': object_fields.IntegerField(nullable=True), 'uuid': object_fields.UUIDField(nullable=True), 'host_id': object_fields.IntegerField(nullable=False), 'host_uuid': object_fields.StringField(nullable=True), 'numa_node': object_fields.IntegerField(nullable=False), 'capabilities': object_fields.FlexibleDictField(nullable=True), } _foreign_fields = {'host_uuid': 'host:uuid'} @classmethod def get_by_uuid(cls, context, uuid): db_node = cls.dbapi.node_get(uuid) return cls._from_db_object(context, cls(), db_node) def save_changes(self, context, updates): self.dbapi.node_update(self.uuid, updates) @classmethod def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None, filters=None): """Return a list of Memory objects. :param cls: the :class:`Memory` :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :param filters: Filters to apply. :returns: a list of :class:`Memory` object. """ db_nodes = cls.dbapi.node_get_list(filters=filters, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_nodes) @classmethod def get_by_host(cls, context, host_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_nodes = cls.dbapi.node_get_by_host(host_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_nodes)
class Host(base.InventoryObject, object_base.VersionedObjectDictCompat): VERSION = '1.0' dbapi = db_api.get_instance() fields = { 'id': object_fields.IntegerField(nullable=True), 'uuid': object_fields.UUIDField(nullable=True), 'recordtype': object_fields.StringField(nullable=True), 'hostname': object_fields.StringField(nullable=True), 'personality': object_fields.StringField(nullable=True), 'subfunctions': object_fields.StringField(nullable=True), 'subfunction_oper': object_fields.StringField(nullable=True), 'subfunction_avail': object_fields.StringField(nullable=True), 'reserved': object_fields.StringField(nullable=True), 'invprovision': object_fields.StringField(nullable=True), 'mgmt_mac': object_fields.StringField(nullable=True), 'mgmt_ip': object_fields.StringField(nullable=True), # Board management members 'bm_ip': object_fields.StringField(nullable=True), 'bm_mac': object_fields.StringField(nullable=True), 'bm_type': object_fields.StringField(nullable=True), 'bm_username': object_fields.StringField(nullable=True), 'location': object_fields.FlexibleDictField(nullable=True), 'serialid': object_fields.StringField(nullable=True), 'administrative': object_fields.StringField(nullable=True), 'operational': object_fields.StringField(nullable=True), 'availability': object_fields.StringField(nullable=True), 'host_action': object_fields.StringField(nullable=True), 'action_state': object_fields.StringField(nullable=True), 'mtce_info': object_fields.StringField(nullable=True), 'vim_progress_status': object_fields.StringField(nullable=True), 'action': object_fields.StringField(nullable=True), 'task': object_fields.StringField(nullable=True), 'uptime': object_fields.IntegerField(nullable=True), 'capabilities': object_fields.FlexibleDictField(nullable=True), 'boot_device': object_fields.StringField(nullable=True), 'rootfs_device': object_fields.StringField(nullable=True), 'install_output': object_fields.StringField(nullable=True), 'console': object_fields.StringField(nullable=True), 'tboot': object_fields.StringField(nullable=True), 'ttys_dcd': object_fields.StringField(nullable=True), 'install_state': object_fields.StringField(nullable=True), 'install_state_info': object_fields.StringField(nullable=True), 'iscsi_initiator_name': object_fields.StringField(nullable=True), } @classmethod def get_by_uuid(cls, context, uuid): db_host = cls.dbapi.host_get(uuid) return cls._from_db_object(context, cls(), db_host) @classmethod def get_by_filters_one(cls, context, filters): db_host = cls.dbapi.host_get_by_filters_one(filters) return cls._from_db_object(context, cls(), db_host) def save_changes(self, context, updates): self.dbapi.host_update(self.uuid, updates) @classmethod def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None, filters=None): """Return a list of Host objects. :param cls: the :class:`Host` :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :param filters: Filters to apply. :returns: a list of :class:`Host` object. """ db_hosts = cls.dbapi.host_get_list(filters=filters, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_hosts) def create(self, context=None): """Create a Host record in the DB. Column-wise updates will be made based on the result of self.what_changed(). :param context: Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don't use it. A context should be set when instantiating the object, e.g.: Host(context) :raises: InvalidParameterValue if some property values are invalid. """ values = self.do_version_changes_for_db() # self._validate_property_values(values.get('properties')) db_host = self.dbapi.host_create(values) return self._from_db_object(self._context, self, db_host)
class LLDPTLV(base.InventoryObject, object_base.VersionedObjectDictCompat): dbapi = db_api.get_instance() fields = { 'id': object_fields.IntegerField(nullable=True), 'agent_id': object_fields.IntegerField(nullable=True), 'agent_uuid': object_fields.UUIDField(nullable=True), 'neighbour_id': object_fields.IntegerField(nullable=True), 'neighbour_uuid': object_fields.UUIDField(nullable=True), 'type': object_fields.StringField(nullable=True), 'value': object_fields.StringField(nullable=True) } _foreign_fields = { 'agent_uuid': 'lldp_agent:uuid', 'neighbour_uuid': 'lldp_neighbour:uuid', } @classmethod def get_by_id(cls, context, id): db_lldp_tlv = cls.dbapi.lldp_tlv_get_by_id(id) return cls._from_db_object(context, cls(), db_lldp_tlv) def save_changes(self, context, updates): self.dbapi.lldp_tlv_update(self.id, updates) @classmethod def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None, filters=None): """Return a list of LLDPTLV objects. :param cls: the :class:`LLDPTLV` :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :param filters: Filters to apply. :returns: a list of :class:`LLDPTLV` object. """ db_lldp_tlvs = cls.dbapi.lldp_tlv_get_list(filters=filters, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_lldp_tlvs) @classmethod def get_by_neighbour(cls, context, neighbour_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_lldp_tlvs = cls.dbapi.lldp_tlv_get_by_neighbour(neighbour_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_lldp_tlvs) @classmethod def get_by_agent(cls, context, agent_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_lldp_tlvs = cls.dbapi.lldp_tlv_get_by_agent(agent_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_lldp_tlvs) def create(self, values, context=None, agentid=None, neighbourid=None): """Create a LLDPTLV record in the DB. Column-wise updates will be made based on the result of self.what_changed(). :param context: Security context. :param agentid: agent id :param neighbourid: neighbour id :param values: dictionary of values """ values = self.do_version_changes_for_db() db_lldp_tlv = self.dbapi.lldp_tlv_create(values, agentid, neighbourid) return self._from_db_object(self._context, self, db_lldp_tlv) def destroy(self, context=None): """Delete the LLDPTLV from the DB. :param context: Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don't use it. A context should be set when instantiating the object, e.g.: Node(context) """ self.dbapi.lldp_tlv_destroy(self.id) self.obj_reset_changes()
class Sensor(base.InventoryObject, object_base.VersionedObjectDictCompat): dbapi = db_api.get_instance() fields = { 'id': object_fields.IntegerField(nullable=True), 'uuid': object_fields.UUIDField(nullable=True), 'host_id': object_fields.IntegerField(nullable=True), 'host_uuid': object_fields.UUIDField(nullable=True), 'sensorgroup_id': object_fields.IntegerField(nullable=True), 'sensorgroup_uuid': object_fields.UUIDField(nullable=True), 'sensorname': object_fields.StringField(nullable=True), 'path': object_fields.StringField(nullable=True), 'datatype': object_fields.StringField(nullable=True), 'sensortype': object_fields.StringField(nullable=True), 'status': object_fields.StringField(nullable=True), 'state': object_fields.StringField(nullable=True), 'state_requested': object_fields.IntegerField(nullable=True), 'audit_interval': object_fields.IntegerField(nullable=True), 'algorithm': object_fields.StringField(nullable=True), 'sensor_action_requested': object_fields.StringField(nullable=True), 'actions_minor': object_fields.StringField(nullable=True), 'actions_major': object_fields.StringField(nullable=True), 'actions_critical': object_fields.StringField(nullable=True), 'unit_base': object_fields.StringField(nullable=True), 'unit_modifier': object_fields.StringField(nullable=True), 'unit_rate': object_fields.StringField(nullable=True), 't_minor_lower': object_fields.StringField(nullable=True), 't_minor_upper': object_fields.StringField(nullable=True), 't_major_lower': object_fields.StringField(nullable=True), 't_major_upper': object_fields.StringField(nullable=True), 't_critical_lower': object_fields.StringField(nullable=True), 't_critical_upper': object_fields.StringField(nullable=True), 'suppress': object_fields.StringField(nullable=True), 'capabilities': object_fields.FlexibleDictField(nullable=True) } _foreign_fields = { 'host_uuid': 'host:uuid', 'sensorgroup_uuid': 'sensorgroup:uuid', } _optional_fields = [ 'unit_base', 'unit_modifier', 'unit_rate', 't_minor_lower', 't_minor_upper', 't_major_lower', 't_major_upper', 't_critical_lower', 't_critical_upper', ] @object_base.remotable_classmethod def get_by_uuid(cls, context, uuid): return cls.dbapi.isensor_get(uuid) def save_changes(self, context, updates): self.dbapi.isensor_update(self.uuid, updates)
class CPU(base.InventoryObject, object_base.VersionedObjectDictCompat): dbapi = db_api.get_instance() fields = { 'id': object_fields.IntegerField(), 'uuid': object_fields.StringField(nullable=True), 'host_id': object_fields.IntegerField(), 'host_uuid': object_fields.StringField(nullable=True), 'node_id': object_fields.IntegerField(nullable=True), 'node_uuid': object_fields.StringField(nullable=True), 'numa_node': object_fields.IntegerField(nullable=True), 'cpu': object_fields.IntegerField(), 'core': object_fields.IntegerField(nullable=True), 'thread': object_fields.IntegerField(nullable=True), 'cpu_family': object_fields.StringField(nullable=True), 'cpu_model': object_fields.StringField(nullable=True), 'capabilities': object_fields.FlexibleDictField(nullable=True), # part of config # 'allocated_function': object_fields.StringField(nullable=True), } _foreign_fields = {'host_uuid': 'host:uuid', 'node_uuid': 'node:uuid', 'numa_node': 'node:numa_node'} @classmethod def get_by_uuid(cls, context, uuid): db_cpu = cls.dbapi.cpu_get(uuid) return cls._from_db_object(context, cls(), db_cpu) def save_changes(self, context, updates): self.dbapi.cpu_update(self.uuid, updates) @classmethod def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None, filters=None): """Return a list of CPU objects. :param cls: the :class:`CPU` :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :param filters: Filters to apply. :returns: a list of :class:`CPU` object. """ db_cpus = cls.dbapi.cpu_get_list( filters=filters, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_cpus) @classmethod def get_by_host(cls, context, host_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_cpus = cls.dbapi.cpu_get_by_host( host_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_cpus) @classmethod def get_by_node(cls, context, node_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_cpus = cls.dbapi.cpu_get_by_node( node_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_cpus) @classmethod def get_by_host_node(cls, context, host_uuid, node_uuid, limit=None, marker=None, sort_key=None, sort_dir=None): db_cpus = cls.dbapi.cpu_get_by_host_node( host_uuid, node_uuid, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir) return cls._from_db_object_list(context, db_cpus) def create(self, context=None): """Create a CPU record in the DB. Column-wise updates will be made based on the result of self.what_changed(). :param context: Security context. """ values = self.do_version_changes_for_db() db_cpu = self.dbapi.cpu_create(values) return self._from_db_object(self._context, self, db_cpu)