attributes.
"""
-
critical = Attribute("critical",
"Defines whether the resource is critical. "
"A failure on a critical resource will interrupt "
type = Types.Bool,
default = True,
flags = Flags.Design)
+ hard_release = Attribute("hardRelease",
+ "Forces removal of all result files and directories associated "
+ "to the RM upon resource release. After release the RM will "
+ "be removed from the EC and the results will not longer be "
+ "accessible",
+ type = Types.Bool,
+ default = False,
+ flags = Flags.Design)
cls._register_attribute(critical)
+ cls._register_attribute(hard_release)
@classmethod
def _register_traces(cls):
"""
return cls._backend
+ @classmethod
+ def get_global(cls, name):
+ """ Returns the value of a global attribute
+ Global attribute meaning an attribute for
+ all the resources from a rtype
+
+ :param name: Name of the attribute
+ :type name: str
+ :rtype: str
+ """
+ global_attr = cls._attributes[name]
+ return global_attr.value
+
+ @classmethod
+ def set_global(cls, name, value):
+ """ Set value for a global attribute
+
+ :param name: Name of the attribute
+ :type name: str
+ :param name: Value of the attribute
+ :type name: str
+ """
+ global_attr = cls._attributes[name]
+ global_attr.value = value
+ return value
+
def __init__(self, ec, guid):
super(ResourceManager, self).__init__(self.get_rtype())
:rtype: str
"""
- return " %s guid: %d - %s " % (self._rtype, self.guid, msg)
+ return " %s guid %d - %s " % (self._rtype, self.guid, msg)
def register_connection(self, guid):
""" Registers a connection to the RM identified by guid
:rtype: str
"""
attr = self._attrs[name]
+ if attr.has_flag(Flags.Global):
+ self.warning( "Attribute %s is global. Use get_global instead." % name)
+
return attr.value
def has_changed(self, name):
attr = self._attrs[name]
return attr.has_flag(flag)
+ def has_attribute(self, name):
+ """ Returns true if the RM has an attribute with name
+
+ :param name: name of the attribute
+ :type name: string
+ """
+ return name in self._attrs
+
def enable_trace(self, name):
""" Explicitly enable trace generation
connected = []
rclass = ResourceFactory.get_resource_type(rtype)
for guid in self.connections:
-
rm = self.ec.get_resource(guid)
if not rtype or isinstance(rm, rclass):
connected.append(rm)