"flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
"validation_function": validation.is_number,
}),
-
+ "timeframe": dict({
+ "name": "timeframe",
+ "help": "Past time period in which to check information about the node. Values are year,month, week, latest",
+ "type": Attribute.ENUM,
+ "value": "week",
+ "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
+ "allowed": ["latest",
+ "week",
+ "month",
+ "year"],
+ "validation_function": validation.is_enum,
+ }),
+
"up": dict({
"name": "up",
"help": "Link up",
"max_load",
"min_cpu",
"max_cpu",
+ "timeframe",
# NEPI-in-NEPI attributes
ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP,
"pl_log_level": dict({
"name": "plLogLevel",
"help": "Verbosity of logging of planetlab events.",
- "value": "ERROR",
+ "value": "INFO",
"type": Attribute.ENUM,
"allowed": ["DEBUG",
"INFO",
self.maxLoad = None
self.min_num_external_ifaces = None
self.max_num_external_ifaces = None
- self.timeframe = 'm'
+ self._timeframe = 'w'
# Applications and routes add requirements to connected nodes
self.required_packages = set()
# Logging
self._logger = logging.getLogger('nepi.testbeds.planetlab')
+
+ def set_timeframe(self, timeframe):
+ if timeframe == "latest":
+ self._timeframe = ""
+ elif timeframe == "month":
+ self._timeframe = "m"
+ elif timeframe == "year":
+ self._timeframe = "y"
+ else:
+ self._timeframe = "w"
+
+ def get_timeframe(self):
+ if self._timeframe == "":
+ return "latest"
+ if self._timeframe == "m":
+ return "month"
+ if self._timeframe == "y":
+ return "year"
+ return "week"
+
+ timeframe = property(get_timeframe, set_timeframe)
def _nepi_testbed_environment_setup_get(self):
command = cStringIO.StringIO()
for envval in envvals:
command.write(' ; export %s=%s' % (envkey, envval))
return command.getvalue()
+
def _nepi_testbed_environment_setup_set(self, value):
pass
+
_nepi_testbed_environment_setup = property(
_nepi_testbed_environment_setup_get,
_nepi_testbed_environment_setup_set)
self._logger.info("Finding candidates for %s", self.make_filter_description())
fields = ('node_id',)
- replacements = {'timeframe':self.timeframe}
+ replacements = {'timeframe':self._timeframe}
# get initial candidates (no tag filters)
basefilters = self.build_filters({}, self.BASEFILTERS)
if attr in applicable:
tagfilter = rootfilters.copy()
tagfilter['tagname'] = tagname % replacements
- tagfilter[expr % replacements] = getattr(self,attr)
+ tagfilter[expr % replacements] = str(getattr(self,attr))
tagfilter['node_id'] = list(candidates)
-
+
candidates &= set(map(operator.itemgetter('node_id'),
self._sliceapi.GetNodeTags(filters=tagfilter, fields=fields)))
def rate_nodes(self, nodes):
rates = collections.defaultdict(int)
tags = collections.defaultdict(dict)
- replacements = {'timeframe':self.timeframe}
+ replacements = {'timeframe':self._timeframe}
tagnames = [ tagname % replacements
for tagname, weight, default in self.RATE_FACTORS ]
orig_attrs['max_num_external_ifaces'] = self.max_num_external_ifaces
self.min_num_external_ifaces = None
self.max_num_external_ifaces = None
- self.timeframe = 'm'
+ if not self._timeframe: self._timeframe = 'w'
- replacements = {'timeframe':self.timeframe}
+ replacements = {'timeframe':self._timeframe}
for attr, tag in self.BASEFILTERS.iteritems():
if tag in info: