class Presentation(resources.Resource): class Meta: identifier = ScopedId('lun_id', 'host_id') lun_id = attributes.String() path = attributes.String() host_id = attributes.Integer()
class TestDefaults2(BaseStorageResource): class Meta: identifier = GlobalId("name", "name_scope") name = attributes.String() name_scope = attributes.String() read = statistics.Gauge() write = statistics.Gauge()
class LocalMount(resources.LogicalDriveOccupier): """Used for marking devices which are already in use, so that we don't offer them for use as Lustre targets.""" class Meta: identifier = ScopedId("mount_point") fstype = attributes.String() mount_point = attributes.String()
class Nid(resources.LNETInterface): class Meta: identifier = ScopedId('host_id', 'name') # Simplified NID representation for those we detect already-configured name = attributes.String() # This is only used to scope it. host_id = attributes.Integer() # Need so we uniquely identify it. lnd_network = attributes.Integer() lnd_type = attributes.String( default=lambda storage_dict: 'o2ib' if storage_dict['lnd_network'] == 'o2ib' else 'tcp')
class Nid(resources.LNETInterface): class Meta: identifier = ScopedId("host_id", "name") # Simplified NID representation for those we detect already-configured name = attributes.String() # This is only used to scope it. host_id = attributes.Integer() # Need so we uniquely identify it. lnd_network = attributes.Integer() lnd_type = attributes.String( default=lambda storage_dict: "o2ib" if storage_dict["lnd_network"] == "o2ib" else "tcp")
class Presentation(resources.Resource): lun_id = attributes.String() path = attributes.String() host_id = attributes.Integer() class Meta: identifier = ScopedId('lun_id', 'host_id') relations = [ relations.Provide(provide_to=resources.DeviceNode, attributes=['host_id', 'path']), relations.Subscribe(subscribe_to=Lun, attributes=['lun_id']) ]
class HostNetworkInterface(resources.NetworkInterface): """Used for marking devices which are already in use, so that we don't offer them for use as Lustre targets.""" class Meta: identifier = ScopedId("host_id", "name") name = attributes.String() inet4_address = attributes.String() inet4_prefix = attributes.Integer(default=0) type = attributes.String() up = attributes.Boolean()
class FakePresentation(resources.PathWeight): lun_id = attributes.String() path = attributes.String() host_id = attributes.Integer() # FIXME: allow subscribers to use different name for their attributes than the provider did class Meta: identifier = ScopedId("path") relations = [ relations.Provide(provide_to=resources.DeviceNode, attributes=["host_id", "path"]), relations.Subscribe(subscribe_to=Lun, attributes=["lun_id"]), ]
class ZfsPool(resources.LogicalDrive): class Meta: identifier = GlobalId("uuid") uuid = attributes.String() name = attributes.String() """ This has to be a class method today because at the point we call it we only has the type not the object""" @classmethod def device_type(cls): return "zfs" def get_label(self): return self.name
class HostNetworkInterface(resources.NetworkInterface): """Used for marking devices which are already in use, so that we don't offer them for use as Lustre targets.""" class Meta: identifier = ScopedId('host_id', 'name') name = attributes.String() inet4_address = attributes.String() inet4_prefix = attributes.Integer(default=0) type = attributes.String() up = attributes.Boolean() rx_bytes = statistics.Counter(units="Bytes/s") tx_bytes = statistics.Counter(units="Bytes/s")
class Lun(resources.LogicalDrive): class Meta: identifier = GlobalId('serial') relations = [ relations.Provide( provide_to=('linux', 'ScsiDevice'), attributes=['serial']), ] charts = [ { 'title': "Bandwidth", 'series': ['read_bytes_sec', 'write_bytes_sec'] }, { 'title': "Ops", 'series': ['read_ops_sec', 'write_ops_sec'] }, { 'title': "Latency distribution", 'series': ['write_latency_hist'] } ] couplet = attributes.ResourceReference() lun_id = attributes.String() serial = attributes.String() read_bytes_sec = statistics.Gauge(units="B/s", label="Read bandwidth") write_bytes_sec = statistics.Gauge(units="B/s", label="Write bandwidth") read_ops_sec = statistics.Gauge(units="op/s", label="Read operations") write_ops_sec = statistics.Gauge(units="op/s", label="Write operations") write_latency_hist = statistics.BytesHistogram( label="Write latency", bins=[(0, 16), (17, 32), (33, 64), (65, 128), (129, 256), (257, 512), (513, 1024), (1024, 2048), (2049, 4096), (4097, 8192), (8193, 16384), (16385, 32768) ]) def get_label(self): return self.lun_id
class Controller(resources.ScannableResource): class Meta: identifier = GlobalId("address") alert_conditions = [ alert_conditions.ValueCondition("status", warn_states=["FAILED"], message="Controller failure"), alert_conditions.UpperBoundCondition( "temperature", warn_bound=85, message="High temperature warning"), alert_conditions.LowerBoundCondition( "temperature", warn_bound=0, message="Low temperature warning"), alert_conditions.ValueCondition("multi_status", warn_states=["FAIL1"], message="Failure 1"), alert_conditions.ValueCondition("multi_status", warn_states=["FAIL2"], message="Failure 2"), alert_conditions.ValueCondition("status", warn_states=["FAIL1", "FAIL2"], message="Failure 1 or 2"), ] address = attributes.String() status = attributes.Enum("OK", "FAILED") multi_status = attributes.Enum("OK", "FAIL1", "FAIL2") temperature = attributes.Integer(min_val=-274)
class LvmVolume(resources.LogicalDriveSlice): # Q: Why is this identified by LV UUID and VG UUID rather than just # LV UUID? Isn't the LV UUID unique enough? # A: We're matching LVM2's behaviour. If you e.g. imagine a machine that # has some VGs and LVs, then if you want to disambiguate them you run # 'vgchange -u' to get a new VG UUID. However, there is no equivalent # command to reset LV uuid, because LVM finds two LVs with the same UUID # in VGs with different UUIDs to be unique enough. class Meta: identifier = GlobalId("uuid", "vg") icon = "lvm_lv" label = "Logical volume" vg = attributes.ResourceReference() uuid = attributes.Uuid() name = attributes.String() def get_label(self): return "%s-%s" % (self.vg.name, self.name) """ This has to be a class method today because at the point we call it we only has the type not the object""" @classmethod def device_type(cls): return "lvm_volume"
class HardDrive(resources.PhysicalDisk): class Meta: identifier = identifiers.ScopedId('serial_number') serial_number = attributes.String() capacity = attributes.Bytes() temperature = statistics.Gauge(units='C')
class Lun(resources.LogicalDrive): class Meta: identifier = identifiers.ScopedId('local_id') relations = [ relations.Provide(provide_to=('linux', 'ScsiDevice'), attributes=['serial'], ignorecase=True), ] local_id = attributes.Integer() name = attributes.String() serial = attributes.String() def get_label(self): return self.name
class Resource3(PhysicalDisk): serial_number = attributes.String() capacity = attributes.Bytes() temperature = statistics.Gauge(units="C") class Meta: identifier = ScopedId("serial_number")
class Lun(resources.LogicalDrive): class Meta: identifier = ScopedId("lun_id") charts = [ {"title": "Bandwidth", "series": ["read_bytes_sec", "write_bytes_sec"]}, {"title": "Latency distribution", "series": ["write_latency_hist"]}, ] lun_id = attributes.String() couplet = attributes.ResourceReference() read_bytes_sec = statistics.Gauge(units="B/s", label="Read bandwidth") write_bytes_sec = statistics.Gauge(units="B/s", label="Write bandwidth") write_latency_hist = statistics.BytesHistogram( label="Write latency", bins=[ (0, 16), (17, 32), (33, 64), (65, 128), (129, 256), (257, 512), (513, 1024), (1024, 2048), (2049, 4096), (4097, 8192), (8193, 16384), (16385, 32768), ], ) def get_label(self): return self.lun_id
class Couplet(resources.ScannableResource): class Meta: identifier = AutoId() address = attributes.Hostname() password = attributes.Password(crypt) internal_id = attributes.String(user_read_only=True, optional=True)
class NetworkInterface(resources.Resource): class Meta: identifier = ScopedId("name") charts = [{"title": "Bandwidth", "series": ["rx_bytes", "tx_bytes"]}] name = attributes.String() rx_bytes = statistics.Counter(units="Bytes/s") tx_bytes = statistics.Counter(units="Bytes/s")
class Lun(resources.LogicalDrive): class Meta: identifier = ScopedId("lun_id") lun_id = attributes.String() couplet = attributes.ResourceReference() def get_label(self): return self.lun_id
class ScsiLun(resources.LogicalDrive): serial = attributes.String() class Meta: identifier = GlobalId("serial") relations = [ relations.Provide(provide_to=("linux", "ScsiDevice"), attributes=["serial"]) ]
class ScsiDevice(resources.LogicalDrive): class Meta: identifier = GlobalId("serial") label = "SCSI device" serial = attributes.String() def get_label(self): return self.serial
class TestOverrides(BaseStorageResource): class Meta: identifier = GlobalId("name") label = "Alpha" def get_label(self): return "Bravo" name = attributes.String()
class Resource5(LogicalDrive): local_id = attributes.Integer() capacity = attributes.Bytes() name = attributes.String() class Meta: identifier = ScopedId("local_id") def get_label(self): return self.name
def test_string(self): str = attributes.String(max_length = 512) str.validate("") str.validate("x" * 511) toolong = "x" * 513 with self.assertRaisesRegexp(ValueError, "Value '%s' too long" % toolong): str.validate(toolong) self.assertEqual(str.cast('string'), 'string')
class VirtualMachine(BaseStorageResource): """A Linux* host provided by a plugin. This resource has a special behaviour when created: the manager server will add this (by the ``address`` attribute) as a Lustre server and attempt to configure the ``chroma-agent`` service on it. The ``host_id`` attribute is used internally by the manager server and must not be assigned to by plugins.""" # NB address is used to cue the creation of a ManagedHost, once that is set up # this address is not used. address = attributes.String() host_id = attributes.Integer(optional=True)
class PluginAgentResources(resources.Resource, HostsideResource): class Meta: identifier = GlobalId("host_id", "plugin_name") host_id = attributes.Integer() plugin_name = attributes.String() def get_label(self): host = ManagedHost._base_manager.get(pk=self.host_id) return "%s" % host
class DiskDrive(resources.Resource): class Meta: identifier = ScopedId("serial") charts = [{ "title": "Bandwidth", "series": ["read_bytes_sec", "write_bytes_sec"] }] serial = attributes.String() read_bytes_sec = statistics.Gauge(units="B/s", label="Read bandwidth") write_bytes_sec = statistics.Counter(units="B/s", label="Write bandwidth")
class TestOverrides(BaseStorageResource): class Meta: identifier = GlobalId("name") label = "Alpha" charts = [{"title": "IO", "series": ["read", "write"]}] def get_label(self): return "Bravo" name = attributes.String() read = statistics.Gauge() write = statistics.Gauge()
class LvmGroup(resources.StoragePool): class Meta: identifier = GlobalId("uuid") icon = "lvm_vg" label = "Volume group" uuid = attributes.Uuid() name = attributes.String() size = attributes.Bytes() def get_label(self): return self.name