-"""
- NEPI, a framework to manage network experiments
- Copyright (C) 2013 INRIA
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-"""
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
import functools
import logging
from nepi.util.parallel import ParallelRun
from nepi.util.timefuncs import strfnow, strfdiff, strfvalid
from nepi.execution.resource import ResourceFactory, ResourceAction, \
- ResourceState
+ ResourceState, ResourceState2str
from nepi.execution.scheduler import HeapScheduler, Task, TaskStatus
from nepi.execution.trace import TraceAttr
return self.ecstate in [ECState.FAILED, ECState.TERMINATED]
def wait_finished(self, guids):
- while not all([self.state(guid) == ResourceState.FINISHED \
+ # Take into account if only one guids is given in parameter
+ while not all([self.state(guid) in [ResourceState.FINISHED,
+ ResourceState.STOPPED,
+ ResourceState.FAILED] \
for guid in guids]) and not self.finished:
# We keep the sleep as large as possible to
# decrese the number of RM state requests
rm = self.get_resource(guid)
return rm.get_attributes()
- def get_filters(self, guid):
- rm = self.get_resource(guid)
- return rm.get_filters()
-
def register_connection(self, guid1, guid2):
rm1 = self.get_resource(guid1)
rm2 = self.get_resource(guid2)
rm = self.get_resource(guid)
return rm.trace(name, attr, block, offset)
- def discover(self, guid, filters):
+ def discover(self, guid):
rm = self.get_resource(guid)
- return rm.discover(filters)
+ return rm.discover()
- def provision(self, guid, filters):
+ def provision(self, guid):
rm = self.get_resource(guid)
- return rm.provision(filters)
+ return rm.provision()
def get(self, guid, name):
rm = self.get_resource(guid)
rm = self.get_resource(guid)
return rm.set(name, value)
- def state(self, guid):
+ def state(self, guid, hr = False):
+ """ Returns the state of a resource
+
+ :param guid: Resource guid
+ :type guid: integer
+
+ :param hr: Human readable. Forces return of a
+ status string instead of a number
+ :type hr: boolean
+
+ """
rm = self.get_resource(guid)
+ if hr:
+ return ResourceState2str.get(rm.state)
+
return rm.state
def stop(self, guid):