1 # -*- coding: utf-8 -*-
3 from constants import TESTBED_ID, TESTBED_VERSION
4 from nepi.core import testbed_impl
5 from nepi.util.constants import TIME_NOW
7 from nepi.testbeds.omf.omf_api import OmfAPI
13 class TestbedController(testbed_impl.TestbedController):
15 super(TestbedController, self).__init__(TESTBED_ID, TESTBED_VERSION)
18 self._logger = logging.getLogger('nepi.testbeds.omf')
21 debug = self._attributes.get_attribute_value("enableDebug")
23 self._logger.setLevel(logging.DEBUG)
26 self._home = self._attributes.get_attribute_value("homeDirectory")
27 home = os.path.normpath(self._home)
28 if not os.path.exists(home):
29 os.makedirs(home, 0755)
31 # initialize OMF xmpp client
32 slice = self._attributes.get_attribute_value("xmppSlice")
33 host = self._attributes.get_attribute_value("xmppHost")
34 port = self._attributes.get_attribute_value("xmppPort")
35 password = self._attributes.get_attribute_value("xmppPassword")
37 self._api = OmfAPI(slice, host, port, password, debug)
39 super(TestbedController, self).do_setup()
45 def set(self, guid, name, value, time = TIME_NOW):
46 super(TestbedController, self).set(guid, name, value, time)
47 element = self._elements[guid]
50 setattr(element, name, value)
52 # We ignore these errors while recovering.
53 # Some attributes are immutable, and setting
54 # them is necessary (to recover the state), but
55 # some are not (they throw an exception).
56 if not self.recovering:
59 def get(self, guid, name, time = TIME_NOW):
60 value = super(TestbedController, self).get(guid, name, time)
61 element = self._elements.get(guid)
63 return getattr(element, name)
64 except (KeyError, AttributeError):