From: Lucia Guevgeozian Odizzio Date: Wed, 10 Sep 2014 10:01:04 +0000 (+0200) Subject: vod experiment files X-Git-Tag: nepi-3.2.0~89 X-Git-Url: http://git.onelab.eu/?p=nepi.git;a=commitdiff_plain;h=2baa343634b0a1ead1ee1eaad371c2a85cc80dbe vod experiment files --- diff --git a/examples/omf/vod_exp/big_buck_bunny_240p_mpeg4_lq.ts b/examples/omf/vod_exp/big_buck_bunny_240p_mpeg4_lq.ts new file mode 100755 index 00000000..d947b4b9 Binary files /dev/null and b/examples/omf/vod_exp/big_buck_bunny_240p_mpeg4_lq.ts differ diff --git a/examples/omf/vod_exp/conf_Broadcast.vlm b/examples/omf/vod_exp/conf_Broadcast.vlm new file mode 100644 index 00000000..2a5ed8a7 --- /dev/null +++ b/examples/omf/vod_exp/conf_Broadcast.vlm @@ -0,0 +1,5 @@ +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 diff --git a/examples/omf/vod_exp/conf_VoD.vlm b/examples/omf/vod_exp/conf_VoD.vlm new file mode 100644 index 00000000..417795cd --- /dev/null +++ b/examples/omf/vod_exp/conf_VoD.vlm @@ -0,0 +1,3 @@ +new BUNNY vod enabled +setup BUNNY input /home/inria_lguevgeo/.nepi/nepi-usr/src/big_buck_bunny_240p_mpeg4_lq.ts + diff --git a/examples/omf/vod_exp/vod_experiment.py b/examples/omf/vod_exp/vod_experiment.py new file mode 100755 index 00000000..b3459e8e --- /dev/null +++ b/examples/omf/vod_exp/vod_experiment.py @@ -0,0 +1,277 @@ +#!/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 . +# + +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 or ', 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 diff --git a/src/nepi/resources/omf/wilabt_node.py b/src/nepi/resources/omf/wilabt_node.py index eecbe45a..0918c3f8 100644 --- a/src/nepi/resources/omf/wilabt_node.py +++ b/src/nepi/resources/omf/wilabt_node.py @@ -71,8 +71,8 @@ class WilabtSfaNode(OMFNode): 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) @@ -83,7 +83,7 @@ class WilabtSfaNode(OMFNode): 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) @@ -130,10 +130,6 @@ class WilabtSfaNode(OMFNode): 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() @@ -159,10 +155,6 @@ class WilabtSfaNode(OMFNode): 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 @@ -170,10 +162,10 @@ class WilabtSfaNode(OMFNode): 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 \ @@ -368,11 +360,11 @@ class WilabtSfaNode(OMFNode): """ 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): diff --git a/src/nepi/util/sfaapi.py b/src/nepi/util/sfaapi.py index fafb99d0..9c3b5d34 100644 --- a/src/nepi/util/sfaapi.py +++ b/src/nepi/util/sfaapi.py @@ -21,6 +21,7 @@ import threading import hashlib import re import os +import time from nepi.util.logger import Logger @@ -254,12 +255,18 @@ class SFAAPI(object): 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) @@ -293,6 +300,24 @@ class SFAAPI(object): 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.