ec.set(node, "hostname", "localhost")
simu = ec.register_resource("LinuxNS3Simulation")
+ ec.set(simu, "enableDump", True)
+ ec.set(simu, "StopTime", STOP_TIME)
ec.register_connection(simu, node)
return simu
ec.set (ccnd, "debug", 7)
ec.set (ccnd, "capacity", 50000)
ec.set (ccnd, "StartTime", "1s")
- ec.set (ccnd, "StopTime", STOP_TIME)
ec.register_connection(ccnd, host)
# Collector to retrieve ccnd log
ec.set (ccnr, "repoFile1", repofile)
ec.set (ccnr, "stackSize", 1<<20)
ec.set (ccnr, "StartTime", "2s")
- ec.set (ccnr, "StopTime", STOP_TIME)
ec.register_connection(ccnr, host)
def add_dce_ccncat(ec, nid):
ec.set (ccncat, "contentName", content_name)
ec.set (ccncat, "stackSize", 1<<20)
ec.set (ccncat, "StartTime", "8s")
- ec.set (ccncat, "StopTime", STOP_TIME)
ec.register_connection(ccncat, host)
def add_dce_fib_entry(ec, nid1, nid2):
ec.set (ccndc, "uri", "ccnx:/")
ec.set (ccndc, "host", ip2)
ec.set (ccndc, "stackSize", 1<<20)
- ec.set (ccndc, "StartTime", "2s")
- ec.set (ccndc, "StopTime", STOP_TIME)
+ ec.set (ccndc, "StartTime", "4s")
ec.register_connection(ccndc, host1)
def add_dce_net_iface(ec, nid1, nid2):
# TODO: DUMP RESULTS TO FILE
# TODO: DUMP GRAPH DELAYS!
- f = open("/tmp/metric", "w+")
+ f = open("/tmp/metric", "a+")
f.write("%.2f\n" % metric)
f.close()
print " METRIC", metric
#### Create NEPI Experiment Description with LINEAR topology
ec = ExperimentController("dce_ccn",
topo_type = TopologyType.LINEAR,
- node_count = 4,
+ node_count = 2,
assign_st = True,
assign_ips = True,
add_node_callback = add_dce_node,
simu = ec.register_resource("LinuxNS3Simulation")
ec.set(simu, "verbose", True)
ec.set(simu, "enableDump", True)
-ec.set (simu, "stopTime", "22s")
+ec.set (simu, "StopTime", "22s")
ec.register_connection(simu, node)
x = 30
--- /dev/null
+new BUNNY broadcast enabled loop
+setup BUNNY input /home/inria_lguevgeo/.nepi/nepi-usr/src/big_buck_bunny_240p_mpeg4_lq.ts
+setup BUNNY output #rtp{access=udp,mux=ts,sdp=rtsp://0.0.0.0:8554/BUNNY}
+new test_sched schedule enabled
+setup test_sched append control BUNNY play
--- /dev/null
+new BUNNY vod enabled
+setup BUNNY input /home/inria_lguevgeo/.nepi/nepi-usr/src/big_buck_bunny_240p_mpeg4_lq.ts
+
--- /dev/null
+#!/usr/bin/env python
+#
+# 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/>.
+#
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.resource import ResourceAction, ResourceState
+
+import os
+import time
+import argparse
+
+# Set experiment for broadcast or vod mode
+
+parser = argparse.ArgumentParser(description='NEPI VoD/Broadcast experiment')
+parser.add_argument('-m', '--mode', help='Set vlc mode, possible values <vod> or <broadcast>', required=True)
+args = parser.parse_args()
+
+mode = args.mode
+
+# Create the entity Experiment Controller
+
+exp_id = "vod_exp"
+ec = ExperimentController(exp_id)
+
+# Define SFA credentials
+
+slicename = 'ple.inria.lguevgeo'
+sfauser = 'ple.inria.lucia_guevgeozian_odizzio'
+sfaPrivateKey = '/user/lguevgeo/home/.sfi/lucia_guevgeozian_odizzio.pkey'
+
+# Functions for nodes and ifaces registration
+
+def create_planetlab_node(ec, host):
+ node = ec.register_resource("PlanetlabSfaNode")
+ ec.set(node, "hostname", host)
+ ec.set(node, "username", "inria_lguevgeo")
+ ec.set(node, "sfauser", sfauser)
+ ec.set(node, "sfaPrivateKey", sfaPrivateKey)
+ ec.set(node, 'cleanExperiment', True)
+ return node
+
+def create_omf_node(ec, host):
+ node = ec.register_resource("WilabtSfaNode")
+ ec.set(node, "host", host)
+ ec.set(node, "slicename", slicename)
+ ec.set(node, "sfauser", sfauser)
+ ec.set(node, "sfaPrivateKey", sfaPrivateKey)
+ ec.set(node, "gatewayUser", "nepi")
+ ec.set(node, "gateway", "bastion.test.iminds.be")
+ ec.set(node, "disk_image", 'NepiVlcOMF6Baseline')
+ ec.set(node, 'xmppServer', "xmpp.ilabt.iminds.be")
+ ec.set(node, 'xmppUser', "nepi")
+ ec.set(node, 'xmppPort', "5222")
+ ec.set(node, 'xmppPassword', "1234")
+ return node
+
+def create_omf_iface(ec, ip, node):
+ iface = ec.register_resource("OMFWifiInterface")
+ ec.set(iface, 'name', 'wlan0')
+ ec.set(iface, 'mode', "adhoc")
+ ec.set(iface, 'hw_mode', "g")
+ ec.set(iface, 'essid', "vlc")
+ ec.set(iface, 'ip', ip)
+ ec.register_connection(iface, node)
+ return iface
+
+# Register Internet VLC server
+
+video_server = create_planetlab_node(ec, 'planetlab3.xeno.cl.cam.ac.uk')
+
+# Register wifi media center and client nodes
+
+wifi_center = create_omf_node(ec, 'zotacB1')
+client1 = create_omf_node(ec, 'zotacB3')
+client2 = create_omf_node(ec, 'zotacB5')
+client3 = create_omf_node(ec, 'zotacC1')
+client4 = create_omf_node(ec, 'zotacC3')
+client5 = create_omf_node(ec, 'zotacC4')
+
+omf_nodes = [wifi_center, client1, client2, client3, client4, client5]
+
+# Register ifaces in wireless nodes
+
+iface_center = create_omf_iface(ec, "192.168.0.1/24", wifi_center)
+iface_client1 = create_omf_iface(ec, "192.168.0.2/24", client1)
+iface_client2 = create_omf_iface(ec, "192.168.0.3/24", client2)
+iface_client3 = create_omf_iface(ec, "192.168.0.4/24", client3)
+iface_client4 = create_omf_iface(ec, "192.168.0.5/24", client4)
+iface_client5 = create_omf_iface(ec, "192.168.0.6/24", client5)
+
+omf_ifaces = [iface_center, iface_client1, iface_client2, iface_client3, iface_client4, iface_client5]
+
+# Register channel
+
+chan = ec.register_resource("OMFChannel")
+ec.set(chan, 'channel', "6")
+
+# Register connection ifaces - channel
+
+ec.register_connection(iface_center, chan)
+ec.register_connection(iface_client1, chan)
+ec.register_connection(iface_client2, chan)
+ec.register_connection(iface_client3, chan)
+ec.register_connection(iface_client4, chan)
+ec.register_connection(iface_client5, chan)
+
+resources = [video_server] + omf_nodes + omf_ifaces + [chan]
+
+# Deploy physical resources and wait until they become provisioned
+
+ec.deploy(resources)
+
+ec.wait_deployed(resources)
+
+time.sleep(3)
+
+# Functions for applications registration in the nodes
+
+def create_vlc_server(ec, video_server, mode):
+ vlc_server = ec.register_resource("LinuxApplication")
+ ec.set(vlc_server, "depends", "vlc")
+ ec.set(vlc_server, "sources", "examples/omf/demo_openlab/big_buck_bunny_240p_mpeg4_lq.ts")
+ # Depending on the mode selected to run the experiment,
+ # different configuation files and command to run are
+ # uploaded to the server
+ if mode == 'vod':
+ ec.set(vlc_server, "files", "examples/omf/demo_openlab/conf_VoD.vlm")
+ ec.set(vlc_server, "command", "sudo -S dbus-uuidgen --ensure ; cvlc --vlm-conf ${SHARE}/conf_VoD.vlm --rtsp-host 128.232.103.203:5554 2>/tmp/logpl.txt")
+ elif mode == 'broadcast':
+ ec.set(vlc_server, "files", "examples/omf/demo_openlab/conf_Broadcast.vlm")
+ ec.set(vlc_server, "command", "sudo -S dbus-uuidgen --ensure ; cvlc --vlm-conf ${SHARE}/conf_Broadcast.vlm --rtsp-host 128.232.103.203:5554 2>/tmp/logpl.txt")
+ ec.register_connection(video_server, vlc_server)
+ return vlc_server
+
+def create_omf_app(ec, command, node):
+ app = ec.register_resource("OMFApplication")
+ ec.set(app, 'command', command)
+ ec.register_connection(app, node)
+ return app
+
+
+# Run the VLC server in the Planetlab node
+
+vlc_server = create_vlc_server(ec, video_server, mode)
+
+# Upload configuration to the wifi media center and run VLC
+
+if mode == 'vod':
+ update_file_wificenter = "echo -e 'new BUNNY vod enabled\\n"\
+ "setup BUNNY input rtsp://128.232.103.203:5554/BUNNY' > /root/wificenter.vlm"
+ command_wificenter = "/root/vlc/vlc-1.1.13/cvlc --vlm-conf /root/wificenter.vlm --rtsp-host 192.168.0.1:5554"
+elif mode == 'broadcast':
+ update_file_wificenter = "echo -e 'new BUNNY broadcast enabled loop\\n"\
+ "setup BUNNY input rtsp://128.232.103.203:8554/BUNNY\\n"\
+ "setup BUNNY output #rtp{access=udp,mux=ts,sdp=rtsp://0.0.0.0:8554/BUNNY}\\n\\n"\
+ "new test_sched schedule enabled\\n"\
+ "setup test_sched append control BUNNY play' > /root/wificenter.vlm"
+ command_wificenter = "/root/vlc/vlc-1.1.13/cvlc --vlm-conf /root/wificenter.vlm --rtsp-host 192.168.0.1:8554"
+
+upload_conf = create_omf_app(ec, update_file_wificenter , wifi_center)
+vlc_wificenter = create_omf_app(ec, command_wificenter , wifi_center)
+
+ec.register_condition(upload_conf, ResourceAction.START, vlc_server, ResourceState.STARTED , "2s")
+ec.register_condition(vlc_wificenter, ResourceAction.START, upload_conf, ResourceState.STARTED , "2s")
+
+# measurements in video server (PL node)
+measure_videoserver = ec.register_resource("LinuxApplication")
+ec.set(measure_videoserver, "depends", "tcpdump")
+ec.set(measure_videoserver, "sudo", True)
+command = "tcpdump -i eth0 not arp -n -w /tmp/capplserver_%s.pcap" % ("$(date +'%Y%m%d%H%M%S')")
+ec.set(measure_videoserver, "command", command)
+ec.register_connection(measure_videoserver, video_server)
+
+# Deploy servers
+ec.deploy([vlc_server, upload_conf, vlc_wificenter, measure_videoserver])
+
+ec.wait_started([vlc_server, upload_conf, vlc_wificenter, measure_videoserver])
+
+time.sleep(3)
+
+def deploy_experiment(ec, clients, wifi_center):
+
+ # measurements in transmitter eth0
+ command_measure_wificentereth0 = "/usr/sbin/tcpdump -i eth0 not arp -n -w /tmp/capwificen_eth0_%s_%s.pcap" % (len(clients), "$(date +'%Y%m%d%H%M%S')")
+ measure_wificentereth0 = create_omf_app(ec, command_measure_wificentereth0, wifi_center)
+ ec.register_condition(measure_wificentereth0, ResourceAction.STOP, measure_wificentereth0, ResourceState.STARTED , "65s")
+
+ # measurements in transmitter wlan0
+ command_measure_wificenterwlan0 = "/usr/sbin/tcpdump -i wlan0 not arp -n -w /tmp/capwificen_wlan0_%s_%s.pcap" % (len(clients), "$(date +'%Y%m%d%H%M%S')")
+ measure_wificenterwlan0 = create_omf_app(ec, command_measure_wificenterwlan0, wifi_center)
+ ec.register_condition(measure_wificenterwlan0, ResourceAction.STOP, measure_wificenterwlan0, ResourceState.STARTED , "65s")
+
+ # kill tcpdumps in wificenter
+ command_kill_measure_wificentereth0 = "killall /usr/sbin/tcpdump"
+ kill_measure_wificentereth0 = create_omf_app(ec, command_kill_measure_wificentereth0, wifi_center)
+ ec.register_condition(kill_measure_wificentereth0, ResourceAction.START, measure_wificentereth0, ResourceState.STARTED , "65s")
+ ec.register_condition(kill_measure_wificentereth0, ResourceAction.STOP, kill_measure_wificentereth0, ResourceState.STARTED , "2s")
+
+
+ apps = [measure_wificentereth0, measure_wificenterwlan0, kill_measure_wificentereth0]
+ delay = '2s'
+ for client in clients:
+ client_host = ec.get(client, 'host').split('.')[0]
+ # measurements in clients
+ command_measure_client = "/usr/sbin/tcpdump -i wlan0 not arp -n -w /tmp/capcli_%s_%s_%s.pcap" % (client_host, len(clients), "$(date +'%Y%m%d%H%M%S')")
+ # run vlc client
+ if mode == 'broadcast':
+ command_client = "/root/vlc/vlc-1.1.13/cvlc rtsp://192.168.0.1:8554/BUNNY --sout=file/ts:%s_%s_%s.ts 2>/tmp/logcli.txt" % (client_host, len(clients), "$(date +'%Y%m%d%H%M%S')")
+ elif mode == 'vod':
+ command_client = "/root/vlc/vlc-1.1.13/cvlc rtsp://192.168.0.1:5554/BUNNY --sout=file/ts:%s_%s_%s.ts 2>/tmp/logcli.txt" % (client_host, len(clients), "$(date +'%Y%m%d%H%M%S')")
+
+ # kill vlc client and tcpdump
+ command_client_killvlc = "killall vlc vlc_app"
+ command_client_killtcp = "killall /usr/sbin/tcpdump"
+
+ run_client = create_omf_app(ec, command_client, client)
+ measure_client = create_omf_app(ec, command_measure_client, client)
+ kill_clientvlc = create_omf_app(ec, command_client_killvlc, client)
+ kill_clienttcp = create_omf_app(ec, command_client_killtcp, client)
+ ec.register_condition(run_client, ResourceAction.START, measure_client, ResourceState.STARTED , delay)
+ ec.register_condition([run_client, measure_client], ResourceAction.STOP, run_client, ResourceState.STARTED , "60s")
+ ec.register_condition(kill_clientvlc, ResourceAction.START, run_client, ResourceState.STARTED , "60s")
+ ec.register_condition(kill_clienttcp, ResourceAction.START, measure_client, ResourceState.STARTED , "60s")
+ ec.register_condition(kill_clientvlc, ResourceAction.STOP, kill_clientvlc, ResourceState.STARTED , "2s")
+ ec.register_condition(kill_clienttcp, ResourceAction.STOP, kill_clienttcp, ResourceState.STARTED , "2s")
+ apps.append(run_client)
+ apps.append(measure_client)
+ apps.append(kill_clientvlc)
+ apps.append(kill_clienttcp)
+
+ return apps
+
+#################
+## 1 client run #
+#################
+
+apps1 = deploy_experiment(ec, [client1], wifi_center)
+
+ec.deploy(apps1)
+ec.wait_finished(apps1)
+
+################
+# 3 client run #
+################
+
+#apps3 = deploy_experiment(ec, [client1, client2, client3], wifi_center)
+#
+#ec.deploy(apps3)
+#ec.wait_finished(apps3)
+
+################
+# 5 client run #
+################
+#
+#apps5 = deploy_experiment(ec, [client1, client2, client3, client4, client5], wifi_center)
+
+#ec.deploy(apps5)
+#ec.wait_finished(apps5)
+
+ec.shutdown()
+
+# End
" ecryptfs-utils-devel libxml2-devel automake gawk "
" gcc gcc-c++ git pcre-devel make ")
elif self.simulation.node.use_deb:
- return ( " autoconf libssl-dev libexpat-dev libpcap-dev "
+ return ( " autoconf libssl-dev libexpat1-dev libpcap-dev "
" libecryptfs0 libxml2-utils automake gawk gcc g++ "
" git-core pkg-config libpcre3-dev make ")
return ""
-
@property
def _sources(self):
- return "http://www.ccnx.org/releases/ccnx-0.8.1.tar.gz"
+ #return "http://www.ccnx.org/releases/ccnx-0.8.1.tar.gz"
+ return "http://www.ccnx.org/releases/ccnx-0.8.2.tar.gz"
@property
def _build(self):
"Peer host public IP used in network connection for this FIB entry. ",
flags = Flags.Design)
+ home = Attribute("home", "Sets HOME environmental variable. ",
+ default = "/root",
+ flags = Flags.Design)
+
cls._register_attribute(uri)
cls._register_attribute(protocol)
cls._register_attribute(host)
cls._register_attribute(port)
cls._register_attribute(ip)
+ cls._register_attribute(home)
def _instantiate_object(self):
if not self.get("binary"):
if not self.get("arguments"):
self.set("arguments", self._arguments)
+ if not self.get("environment"):
+ self.set("environment", self._environment)
+
super(LinuxNS3DceFIBEntry, self)._instantiate_object()
+ @property
+ def _environment(self):
+ envs = dict({
+ "home": "HOME",
+ })
+
+ env = ";".join(map(lambda k: "%s=%s" % (envs.get(k), str(self.get(k))),
+ [k for k in envs.keys() if self.get(k)]))
+
+ return env
+
@property
def _arguments(self):
args = ["-v", "add"]
type = Types.Bool,
flags = Flags.Design)
- stoptime = Attribute("stopTime",
+ stoptime = Attribute("StopTime",
"Time at which the simulation will stop",
flags = Flags.Design)
if self.get("populateRoutingTables") == True:
self.invoke(IPV4_GLOBAL_ROUTING_HELPER_UUID, "PopulateRoutingTables")
+ time = self.get("StopTime")
+ if time:
+ self._client.stop(time=time)
+
self._client.start()
self.set_started()
"""
if self.state == ResourceState.STARTED:
- time = None
- if self.get("stopTime"):
- time = self.get("stopTime")
-
- self._client.stop(time=time)
+ if not self.get("StopTime"):
+ self._client.stop()
self.set_stopped()
def do_release(self):
if not self._node:
from nepi.resources.ns3.ns3node import NS3BaseNode
nodes = self.get_connected(NS3BaseNode.get_rtype())
- if nodes: self._nodes[0]
+ if nodes: self._node = nodes[0]
return self._node
### DEBUG
self.logger.debug("FACTORY %s( %s )" % (type_name, str(kwargs)))
+ ### DUMP
self.debuger.dump_factory(uuid, type_name, kwargs)
- ########
factory = self.ns3.ObjectFactory()
factory.SetTypeId(type_name)
### DEBUG
self.logger.debug("RET FACTORY ( uuid %s ) %s = %s( %s )" % (
str(uuid), str(obj), type_name, str(kwargs)))
- ########
return uuid
### DEBUG
self.logger.debug("CREATE %s( %s )" % (clazzname, str(args)))
+ ### DUMP
self.debuger.dump_create(uuid, clazzname, args)
- ########
clazz = getattr(self.ns3, clazzname)
### DEBUG
self.logger.debug("RET CREATE ( uuid %s ) %s = %s( %s )" % (str(uuid),
str(obj), clazzname, str(args)))
- ########
return uuid
elif operation == "isAppRunning":
result = self._is_app_running(uuid)
else:
- newuuid = self.make_uuid()
-
- ### DEBUG
- self.debuger.dump_invoke(newuuid, uuid, operation, args, kwargs)
- ########
if operation == "addStaticRoute":
result = self._add_static_route(uuid, *args)
+
+ ### DUMP
+ self.debuger.dump_invoke(result, uuid, operation, args, kwargs)
elif operation == "retrieveObject":
result = self._retrieve_object(uuid, *args, **kwargs)
+
+ ### DUMP
+ self.debuger.dump_invoke(result, uuid, operation, args, kwargs)
else:
+ newuuid = self.make_uuid()
+
+ ### DUMP
+ self.debuger.dump_invoke(newuuid, uuid, operation, args, kwargs)
+
if uuid.startswith(SINGLETON):
obj = self._singleton(uuid)
else:
### DEBUG
self.logger.debug("SET %s %s %s" % (uuid, name, str(value)))
+ ### DUMP
self.debuger.dump_set(uuid, name, value)
- ########
obj = self.get_object(uuid)
type_name = obj.GetInstanceTypeId().GetName()
### DEBUG
self.logger.debug("RET SET %s = %s -> set(%s, %s)" % (str(value), uuid, name,
str(value)))
- ########
return value
### DEBUG
self.logger.debug("GET %s %s" % (uuid, name))
+ ### DUMP
self.debuger.dump_get(uuid, name)
- ########
obj = self.get_object(uuid)
type_name = obj.GetInstanceTypeId().GetName()
### DEBUG
self.logger.debug("RET GET %s = %s -> get(%s)" % (str(result), uuid, name))
- ########
return result
def start(self):
- ### DEBUG
+ ### DUMP
self.debuger.dump_start()
- ########
# Launch the simulator thread and Start the
# simulator in that thread
### DEBUG
self.logger.debug("START")
- ########
def stop(self, time = None):
- ### DEBUG
+ ### DUMP
self.debuger.dump_stop(time=time)
- ########
if time is None:
self.ns3.Simulator.Stop()
### DEBUG
self.logger.debug("STOP time=%s" % str(time))
- ########
def shutdown(self):
- ### DEBUG
+ ### DUMP
self.debuger.dump_shutdown()
- ########
while not self.ns3.Simulator.IsFinished():
#self.logger.debug("Waiting for simulation to finish")
### DEBUG
self.logger.debug("SHUTDOWN")
- ########
def _simulator_run(self, condition):
# Run simulation
host = Attribute("host", "Name of the physical machine",
flags = Flags.Design)
- #disk_image = Attribute("disk_image", "Specify a specific disk image for a node",
- # flags = Flags.Design)
+ disk_image = Attribute("disk_image", "Specify a specific disk image for a node",
+ flags = Flags.Design)
cls._register_attribute(username)
cls._register_attribute(identity)
cls._register_attribute(gateway_user)
cls._register_attribute(gateway)
cls._register_attribute(host)
- #cls._register_attribute(disk_image)
+ cls._register_attribute(disk_image)
def __init__(self, ec, guid):
super(WilabtSfaNode, self).__init__(ec, guid)
Based on the attributes defined by the user, discover the suitable
node for provision.
"""
- if self._skip_provision():
- super(WilabtSfaNode, self).do_discover()
- return
-
nodes = self.sfaapi.get_resources_hrn()
host = self._get_host()
Add node to user's slice and verifing that the node is functioning
correctly. Check ssh, omf rc running, hostname, file system.
"""
- if self._skip_provision():
- super(WilabtSfaNode, self).do_provision()
- return
-
provision_ok = False
ssh_ok = False
proc_ok = False
while not provision_ok:
node = self._node_to_provision
- if self._slicenode:
- self._delete_from_slice()
- self.debug("Waiting 300 sec for re-adding to slice")
- time.sleep(300) # Timout for the testbed to allow a new reservation
+ #if self._slicenode:
+ # self._delete_from_slice()
+ # self.debug("Waiting 480 sec for re-adding to slice")
+ # time.sleep(480) # Timout for the testbed to allow a new reservation
self._add_node_to_slice(node)
t = 0
while not self._check_if_in_slice([node]) and t < timeout \
"""
self.info(" Adding node to slice ")
slicename = self.get("slicename")
- #disk_image = self.get("disk_image")
- #if disk_image is not None:
- # properties = {'disk_image': disk_image}
- #else: properties = None
- properties = None
+ disk_image = self.get("disk_image")
+ if disk_image is not None:
+ properties = {'disk_image': disk_image}
+ else: properties = None
+ #properties = None
self.sfaapi.add_resource_to_slice_batch(slicename, host_hrn, properties=properties)
def _delete_from_slice(self):
import ipaddr
import networkx
+import math
import random
class TopologyType:
# The ladder is a special case because is not symmetric.
if self.topo_type == TopologyType.LADDER:
total_nodes = self.order/2
- leaf1 = str(total_nodes - 1)
- leaf2 = str(nodes - 1)
+ leaf1 = str(total_nodes)
+ leaf2 = str(total_nodes - 1)
leaves = [leaf1, leaf2]
source = leaves.pop(random.randint(0, len(leaves) - 1))
else:
import hashlib
import re
import os
+import time
from nepi.util.logger import Logger
self._slice_resources_batch.append(resource_hrn)
resources_hrn_new = list()
if self._count == len(self._total):
+ check_all_inslice = self._check_all_inslice(self._slice_resources_batch, slicename)
+ if check_all_inslice == True:
+ return True
for resource_hrn in self._slice_resources_batch:
resource_parts = resource_hrn.split('.')
resource_hrn = '.'.join(resource_parts[:2]) + '.' + '\\.'.join(resource_parts[2:])
resources_hrn_new.append(resource_hrn)
with self.lock_slice:
- self._sfi_exec_method('delete', slicename)
+ if check_all_inslice != 0:
+ self._sfi_exec_method('delete', slicename)
+ time.sleep(480)
+
# Re implementing urn from hrn because the library sfa-common doesn't work for wilabt
resources_urn = self._get_urn(resources_hrn_new)
rspec = self.rspec_proc.build_sfa_rspec(slicename, resources_urn, properties, leases)
else:
self._log.debug(" Waiting for more nodes to add the batch to the slice ")
+ def _check_all_inslice(self, resources_hrn, slicename):
+ slice_res = self.get_slice_resources(slicename)['resource']
+ if slice_res:
+ if len(slice_res[0]['services']) != 0:
+ slice_res_hrn = self.get_resources_hrn(slice_res).values()
+ if self._compare_lists(slice_res_hrn, resources_hrn):
+ return True
+ else: return len(slice_res_hrn)
+ return 0
+
+ def _compare_lists(self, list1, list2):
+ if len(list1) != len(list2):
+ return False
+ for item in list1:
+ if item not in list2:
+ return False
+ return True
+
def _get_urn(self, resources_hrn):
"""
Get urn from hrn.
#ec.set(node, "cleanHome", True)
simu = ec.register_resource("LinuxNS3Simulation")
- ec.set(simu, "verbose", True)
- ec.set(simu, "buildMode", "debug")
- ec.set(simu, "nsLog", "DceApplication")
+ #ec.set(simu, "verbose", True)
+ #ec.set(simu, "buildMode", "debug")
+ #ec.set(simu, "nsLog", "DceApplication")
ec.register_connection(simu, node)
nsnode1 = add_ns3_node(ec, simu)