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")
def test_integer_nolimits(self): i = attributes.Integer() i.validate(-1000) i.validate(1024 * 1024 * 1024) i.validate(0) self.assertEqual(i.cast('1'), 1)
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 Presentation(resources.Resource): class Meta: identifier = ScopedId('lun_id', 'host_id') lun_id = attributes.String() path = attributes.String() host_id = attributes.Integer()
def test_integer_limits(self): i = attributes.Integer(min_val=10, max_val=20) i.validate(15) with self.assertRaisesRegexp(ValueError, "Value 5 too low"): i.validate(5) with self.assertRaisesRegexp(ValueError, "Value 22 too high"): i.validate(22) self.assertEqual(i.cast('1'), 1)
class Partition(resources.LogicalDriveSlice): class Meta: identifier = GlobalId("container", "number") number = attributes.Integer() container = attributes.ResourceReference() def get_label(self): return "%s-%s" % (self.container.get_label(), self.number)
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 Resource4(StoragePool): local_id = attributes.Integer() raid_type = attributes.Enum("raid0", "raid1", "raid5", "raid6") capacity = attributes.Bytes() class Meta: identifier = ScopedId("local_id") def get_label(self): return self.local_id
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
class RaidPool(resources.StoragePool): class Meta: identifier = identifiers.ScopedId('local_id') local_id = attributes.Integer() raid_type = attributes.Enum('raid0', 'raid1', 'raid5', 'raid6') capacity = attributes.Bytes() def get_label(self): return self.local_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 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 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 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 = 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 DeviceNode(BaseStorageResource): host_id = attributes.Integer() path = attributes.PosixPath() logical_drive = attributes.ResourceReference(optional=True) class Meta: label = "Device node" def get_label(self): path = self.path strip_strings = [ "/dev/", "/dev/mapper/", "/dev/disk/by-id/", "/dev/disk/by-path/" ] strip_strings.sort(lambda a, b: cmp(len(b), len(a))) for s in strip_strings: if path.startswith(s): path = path[len(s):] return "%s:%s" % (self.host_id, path)
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 PathWeight(BaseStorageResource): weight = attributes.Integer()
class LNETModules(BaseStorageResource): host_id = attributes.Integer() class Meta: label = "LNET State"
class NetworkInterface(BaseStorageResource): host_id = attributes.Integer() class Meta: label = "Network node"
class Couplet(resources.ScannableResource): class Meta: identifier = AutoId() controller_id = attributes.Integer()