HasNoDefaultValue = 0x08
def __init__(self, name, help, type, value = None, range = None,
- allowed = None, flags = NoFlags, validation_function = None,
+ allowed = None, flags = None, validation_function = None,
category = None):
if not type in Attribute.types:
raise AttributeError("invalid type %s " % type)
self._type = type
self._help = help
self._value = value
- self._flags = flags
+ self._flags = flags if flags != None else Attribute.NoFlags
# range: max and min possible values
self._range = range
# list of possible values
def attributes(self):
return self._attributes.values()
- @property
- def attributes_list(self):
- return self._attributes.keys()
+ def get_attribute_list(self, filter_flags = None):
+ attributes = self._attributes
+ if filter_flags != None:
+ def filter_attrs(attr):
+ (attr_id, attr_data) = attr
+ return not ((attr_data.flags & filter_flags) == filter_flags)
+ attributes = dict(filter(filter_attrs, attributes.iteritems()))
+ return attributes.keys()
def set_attribute_value(self, name, value):
self._attributes[name].value = value
testbed_id, factory_id, name = connector_type_id
# the key is always a candidate
+ #print " 1 - ", connector_type_id
yield connector_type_id
# Try wildcard combinations
if (testbed_id, None, name) != connector_type_id:
+ #print " 2 - ", (testbed_id, None, name)
yield (testbed_id, None, name)
if (None, factory_id, name) != connector_type_id:
+ #print " 3 - ", (None, factory_id, name)
yield (None, factory_id, name)
if (None, None, name) != connector_type_id:
+ #print " 4 - ", (None, None, name)
yield (None, None, name)
def add_from_connection(self, testbed_id, factory_id, name, can_cross,
"""
raise NotImplementedError
- def get_attribute_list(self, guid):
+ def get_attribute_list(self, guid, filter_flags = None):
raise NotImplementedError
def get_factory_id(self, guid):
for testbed_guid, testbed_config in self._deployment_config.iteritems():
testbed_guid = str(testbed_guid)
conf.add_section(testbed_guid)
- for attr in testbed_config.attributes_list:
+ for attr in testbed_config.get_attribute_list():
if attr not in TRANSIENT:
conf.set(testbed_guid, attr,
testbed_config.get_attribute_value(attr))
testbed_guid = str(testbed_guid)
conf.add_section(testbed_guid)
- for attr in testbed_config.attributes_list:
+ for attr in testbed_config.get_attribute_list():
if attr not in TRANSIENT:
getter = getattr(conf, TYPEMAP.get(
testbed_config.get_attribute_type(attr),
_testbed_id = cross_testbed.testbed_id,
_testbed_version = cross_testbed.testbed_version)
cross_data[cross_testbed_guid][cross_guid] = elem_cross_data
- attributes_list = cross_testbed.get_attribute_list(cross_guid)
- for attr_name in attributes_list:
+ attribute_list = cross_testbed.get_attribute_list(cross_guid,
+ filter_flags = Attribute.DesignOnly)
+ for attr_name in attribute_list:
attr_value = cross_testbed.get(cross_guid, attr_name)
elem_cross_data[attr_name] = attr_value
return cross_data
return addresses[index][attribute_index]
- def get_attribute_list(self, guid):
+ def get_attribute_list(self, guid, filter_flags = None):
factory = self._get_factory(guid)
attribute_list = list()
- return factory.box_attributes.attributes_list
+ return factory.box_attributes.get_attribute_list(filter_flags)
def get_factory_id(self, guid):
factory = self._get_factory(guid)
# TODO: take on account schedule time for the task
factory_id = self._create[guid]
factory = self._factories[factory_id]
- if factory.box_attributes.is_attribute_design_only(name):
+ if factory.box_attributes.is_attribute_design_only(name) or \
+ factory.box_attributes.is_attribute_invisible(name):
return
element = self._elements.get(guid)
if element:
# TODO: take on account schedule time for the task
factory_id = self._create[guid]
factory = self._factories[factory_id]
- if factory.box_attributes.is_attribute_design_only(name):
+ if factory.box_attributes.is_attribute_design_only(name) or \
+ factory.box_attributes.is_attribute_invisible(name):
return value
element = self._elements.get(guid)
try:
return self._testbed.status(guid)
@Marshalling.handles(GET_ATTRIBUTE_LIST)
- @Marshalling.args(int)
+ @Marshalling.args(int, int)
@Marshalling.retval( Marshalling.pickled_data )
- def get_attribute_list(self, guid):
- return self._testbed.get_attribute_list(guid)
+ def get_attribute_list(self, guid, filter_flags = None):
+ return self._testbed.get_attribute_list(guid, filter_flags)
@Marshalling.handles(GET_FACTORY_ID)
@Marshalling.args(int)