from constants import TESTBED_ID
from nepi.core import testbed_impl
+from nepi.util.constants import TIME_NOW
import os
import time
if self.authUser:
self._plapi = plcapi.PLCAPI(
username = self.authUser,
- password = self.authString)
+ password = self.authString,
+ hostname = self.plcHost,
+ urlpattern = self.plcUrl
+ )
else:
# anonymous access - may not be enough for much
self._plapi = plcapi.PLCAPI()
get_attribute_value("authPass")
self.sliceSSHKey = self._attributes.\
get_attribute_value("sliceSSHKey")
+ self.plcHost = self._attributes.\
+ get_attribute_value("plcHost")
+ self.plcUrl = self._attributes.\
+ get_attribute_value("plcUrl")
+ super(TestbedController, self).do_setup()
def do_preconfigure(self):
# Perform resource discovery if we don't have
# cleanup
del self._to_provision
-
- def set(self, time, guid, name, value):
- super(TestbedController, self).set(time, guid, name, value)
+ def set(self, guid, name, value, time = TIME_NOW):
+ super(TestbedController, self).set(guid, name, value, time)
# TODO: take on account schedule time for the task
element = self._elements[guid]
if element:
# invoke attribute refresh hook
element.refresh()
- def get(self, time, guid, name):
+ def get(self, guid, name, time = TIME_NOW):
+ value = super(TestbedController, self).get(guid, name, time)
# 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):
+ return value
element = self._elements.get(guid)
- if element:
- try:
- if hasattr(element, name):
- # Runtime attribute
- return getattr(element, name)
- else:
- # Try design-time attributes
- return self.box_get(time, guid, name)
- except KeyError, AttributeError:
- return None
-
- def get_route(self, guid, index, attribute):
- # TODO: fetch real data from planetlab
try:
- return self.box_get_route(guid, int(index), attribute)
+ return getattr(element, name)
except KeyError, AttributeError:
- return None
+ return value
def get_address(self, guid, index, attribute='Address'):
index = int(index)
return iface.broadcast
# if all else fails, query box
- try:
- return self.box_get_address(guid, index, attribute)
- except KeyError, AttributeError:
- return None
-
+ return super(TestbedController, self).get_address(guid, index, attribute)
def action(self, time, guid, action):
raise NotImplementedError
def _make_tun_iface(self, parameters):
return self._make_generic(parameters, self._interfaces.TunIface)
+ def _make_tap_iface(self, parameters):
+ return self._make_generic(parameters, self._interfaces.TapIface)
+
def _make_netpipe(self, parameters):
return self._make_generic(parameters, self._interfaces.NetPipe)
def _make_nepi_dependency(self, parameters):
return self._make_generic(parameters, self._app.NepiDependency)
+ def _make_ns3_dependency(self, parameters):
+ return self._make_generic(parameters, self._app.NS3Dependency)