diff --git a/monroe/deprecated/.gitkeep b/monroe/deprecated/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/monroe/deprecated/Monroe-Tap-Agent/DEBIAN/conffiles b/monroe/deprecated/Monroe-Tap-Agent/DEBIAN/conffiles deleted file mode 100644 index e69de29..0000000 diff --git a/monroe/deprecated/Monroe-Tap-Agent/DEBIAN/control b/monroe/deprecated/Monroe-Tap-Agent/DEBIAN/control deleted file mode 100644 index ffacf9e..0000000 --- a/monroe/deprecated/Monroe-Tap-Agent/DEBIAN/control +++ /dev/null @@ -1,12 +0,0 @@ -Package: monroe-tap-agent -Version: 0.1.0 -Section: devel -Priority: optional -Architecture: amd64 -Depends: python-flask (>=0.12.1-1) -Installed-Size: 73 -Maintainer: Mohammad Rajiullah -Vcs-Browser: https://github.com/MONROE-PROJECT/Utilities -Vcs-Git: https://github.com/MONROE-PROJECT/Utilities.git -Description: Installs a TAP agent to control and exectue experiments on a monroe node. - diff --git a/monroe/deprecated/Monroe-Tap-Agent/DEBIAN/postinst b/monroe/deprecated/Monroe-Tap-Agent/DEBIAN/postinst deleted file mode 100755 index 3a881eb..0000000 --- a/monroe/deprecated/Monroe-Tap-Agent/DEBIAN/postinst +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -systemctl enable monroe-tap-agent || true -systemctl start monroe-tap-agent || true diff --git a/monroe/deprecated/Monroe-Tap-Agent/DEBIAN/prerm b/monroe/deprecated/Monroe-Tap-Agent/DEBIAN/prerm deleted file mode 100755 index 3dff89e..0000000 --- a/monroe/deprecated/Monroe-Tap-Agent/DEBIAN/prerm +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -systemctl stop monroe-tap-agent -systemctl disable monroe-tap-agent diff --git a/monroe/deprecated/Monroe-Tap-Agent/lib/systemd/system/monroe-tap-agent.service b/monroe/deprecated/Monroe-Tap-Agent/lib/systemd/system/monroe-tap-agent.service deleted file mode 100644 index a332d2e..0000000 --- a/monroe/deprecated/Monroe-Tap-Agent/lib/systemd/system/monroe-tap-agent.service +++ /dev/null @@ -1,15 +0,0 @@ -[Install] -WantedBy=multi-user.target - -[Unit] -Description=Monroe TAP Agent -After=network.target docker.service - -[Service] -ExecStart=/opt/monroe/tap-agent/monroe-tap-agent.py - -Type=simple -Restart=on-failure - -StandardError=null -StandardOutput=null diff --git a/monroe/deprecated/Monroe-Tap-Agent/opt/monroe/tap-agent/monroe-tap-agent.py b/monroe/deprecated/Monroe-Tap-Agent/opt/monroe/tap-agent/monroe-tap-agent.py deleted file mode 100755 index 05e1344..0000000 --- a/monroe/deprecated/Monroe-Tap-Agent/opt/monroe/tap-agent/monroe-tap-agent.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env python - -''' - -Copyright (C) 2019 Fraunhofer FOKUS - -''' - -''' Adapted by Mohammad Rajiullah from Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) ''' - -# Install packages - -# apt install python-flask - -''' Port Info - -REST API Listener at port 8080 (but can be configured) -''' - - - - -from flask import Flask, request, jsonify -from flask_restful import Api, Resource, reqparse -import json -import uuid -import time -from subprocess import check_output, CalledProcessError - -AGENT_PORT = 8080 - -app = Flask(__name__) -api = Api(app) - - -''' Monroe Experiment ''' -class Monroe(Resource): - def __init__(self): - pass - - ''' - GET request is handled - @return object that contains only RTT average; but can be further extended if required - ''' - def get(self): - print 'Monroe Experiment: A GET request is received' - exp_name = "kau-virtualnode-dev-" + str(uuid.uuid4()) - print request.args.get('config') - config_file = open("/experiments/user/"+exp_name+".conf", "w") - - - config_file.write("%s" % request.args.get('config')) - config_file.close() - - ##Monroe name space - try: - cmd=['/usr/bin/monroe-experiments'] - output=check_output(cmd) - except CalledProcessError as e: - resp=jsonify({'status': 503,'reasons': "Monroe name space is not available: " +exp_name }) - resp.status_code = 503 - return resp - - ##Deploy - try: - cmd=['/usr/bin/container-deploy.sh',exp_name] - output=check_output(cmd) - except CalledProcessError as e: - #return jsonify({'results': "Deploy failed: " +exp_name }) - resp=jsonify({'status': 503,'reasons': "Deploy failed: " +exp_name }) - resp.status_code = 503 - return resp - - ##Start - try: - cmd=['/usr/bin/container-start.sh',exp_name] - output=check_output(cmd) - except CalledProcessError as e: - resp=jsonify({'status': 503,'reasons': "Start failed: " +exp_name }) - resp.status_code = 503 - return resp - - time.sleep( int(request.args.get('duration')) ) - - ##Stop - try: - cmd=['/usr/bin/container-stop.sh',exp_name] - output=check_output(cmd) - except CalledProcessError as e: - resp=jsonify({'status': 503, 'reasons': "Stop failed: " +exp_name }) - resp.status_code = 503 - return resp - - - # - result = self.get_result(exp_name) - message = { - 'status': 200, - 'results': "http://monroe-system.eu/user/"+exp_name - } - resp = jsonify(message) - return resp - - - ''' - Produces a set of exp results as a json object - ''' - def get_result(self, exp_name): - #ping_parser = pingparsing.MonroeParsing() - #transmitter = pingparsing.MonroeTransmitter() - #transmitter.destination_host = host - #transmitter.count = count - #result = transmitter.ping() - #parse_result = ping_parser.parse(result).as_dict() - - #return parse_result - pass - - -# Register the paths -api.add_resource(Monroe, "/api/monroe") - -# Agent listens on port AGENT_PORT -if __name__ == "__main__": - app.run(host='0.0.0.0', port=AGENT_PORT, debug=True, threaded=True) diff --git a/monroe/deprecated/monroe_plugin/MonroeExp/MonroeExperiment.py b/monroe/deprecated/monroe_plugin/MonroeExp/MonroeExperiment.py deleted file mode 100755 index e15e10a..0000000 --- a/monroe/deprecated/monroe_plugin/MonroeExp/MonroeExperiment.py +++ /dev/null @@ -1,167 +0,0 @@ -''' -Copyright (C) 2019 Fraunhofer FOKUS -''' - -''' Adapted by Mohammad Rajiullah from Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) ''' - -# MONROE Experiment - -import sys -import tap -import clr -clr.AddReference("System.Collections") -from System.Collections.Generic import List -from tap import * - -import Keysight.Tap -import math -from Keysight.Tap import Log, AvailableValuesAttribute, EnabledIfAttribute -from System import Array, Double, Byte, Int32, String, Boolean #Import types to reference for generic methods -import System -import requests -import json - -from System.ComponentModel import BrowsableAttribute # BrowsableAttribute can be used to hide things from the user. - -#This is how attributes are used: -@Attribute(Keysight.Tap.DisplayAttribute, "MONROE Experiment", "Conduct a monroe test", "Monroe Test New") -@Attribute(Keysight.Tap.AllowAnyChildAttribute) - -def is_json(myjson): - try: - json_object = json.loads(myjson) - except ValueError, e: - return False - return True - - -class MonroeTest(TestStep): - def __init__(self): - super(MonroeTest, self).__init__() # The base class initializer must be invoked. - - - #prop1 = self.AddProperty("config", "{\"script\":\"monroe/ping\",\"start\":2,\"storage\":99999999,\"interfacename\":\"eth0\",\"server\":\"8.8.8.8\",\"interface_without_metadata\":[\"eth0\"]}" , String) - #prop1.AddAttribute(Keysight.Tap.DisplayAttribute, "configuration", "configuration") - - prop1 = self.AddProperty("script","monroe/ping",String) - prop1.AddAttribute(Keysight.Tap.DisplayAttribute, "Container to run", "script") - - prop2 = self.AddProperty("start", 2, Int32) - prop2.AddAttribute(Keysight.Tap.DisplayAttribute, "start", "start") - - prop3 = self.AddProperty("storage", 99999999, Int32) - prop3.AddAttribute(Keysight.Tap.DisplayAttribute, "storage", "storage") - - prop4 = self.AddProperty("interfacename", "eth0", String) - prop4.AddAttribute(Keysight.Tap.DisplayAttribute, "interfacename", "interfacename") - - #prop5 = self.AddProperty("server", "8.8.8.8", String) - #prop5.AddAttribute(Keysight.Tap.DisplayAttribute, "server", "server") - - prop6 = self.AddProperty("interface_without_metadata", "eth0", String) - prop6.AddAttribute(Keysight.Tap.DisplayAttribute, "interface_without_metadata", "interface_without_metadata") - - prop5 = self.AddProperty("option","{\"server\":\"8.8.8.8\"}", String) - prop5.AddAttribute(Keysight.Tap.DisplayAttribute, "Other options passed to the experiment (json string)", "option") - - prop7 = self.AddProperty("duration", 30, Int32) - prop7.AddAttribute(Keysight.Tap.DisplayAttribute, "Duration of the experiment (s)", "duration") - - self.AddProperty("instrument", None, MonroeInstrument) - - - def Run(self): - - configDict={} - configDict["script"]=self.script - configDict["start"]=str(self.start) - configDict["storage"]=str(self.storage) - configDict["interfacename"]=self.interfacename - configDict["interface_without_metadata"]= [self.interface_without_metadata] - - if self.option != "": - if not is_json(self.option): - print "String given in option is not a valid json" - exit() - else: - json_object = json.loads(self.option) - for item in json_object: - configDict[item]=json_object[item] - - self.config=json.dumps(configDict) - - - #self.config=json.dumps({ - # "script": self.script, - # "start": str(self.duration), - # "storage": str(self.storage), - # "interfacename": self.interfacename, - # "server": self.server, - # "interface_without_metadata": [self.interface_without_metadata] -# -# }) - - print ("The experiment configuration is {}".format(self.config)) - - self.instrument.setup(self.config, self.duration) - super(MonroeTest, self).Run() - # Send the experiment request - self.instrument.send_request(self.UpgradeVerdict) - -class MonroeInstrument(Instrument): - def __init__(self): - super(MonroeInstrument, self).__init__() - - prop = self.AddProperty("IPAddress", None, String) - prop.AddAttribute(Keysight.Tap.DisplayAttribute, "IP Address to connect", "IP address") - # Add Port - self.AddProperty("Port", None, Int32) - - self.RegisterMethod("setup", None) - self.RegisterMethod("send_request", None) - - def setup(self,config,duration): - self.config=config - self.duration=duration - - def send_request(self, verdict): - url = ''.join(['http://', self.IPAddress, ':', str(self.Port), "/api/monroe"]) - print(url) - params = { - "config": self.config, - "duration": self.duration - } - - response = requests.get(url, params=params) - if response.status_code == requests.codes.ok: - resp_data = response.json() - if 'results' in resp_data: - verdict(Keysight.Tap.Verdict.Pass) - res_str = ' '.join(["The results are available at", resp_data['results']]) - else: - verdict(Keysight.Tap.Verdict.Error) - res_str = 'The results location is not available.' - - print (res_str) - else: - resp_data = response.json() - if 'reasons' in resp_data: - verdict(Keysight.Tap.Verdict.Error) - res_str = ' '.join(["FAILED: ", resp_data['reasons']]) - else: - verdict(Keysight.Tap.Verdict.Error) - res_str = 'Failing reasons are not available.' - - print (res_str) - - - def Open(self): - self.Info("Monroe Instrument opened") - - def Close(self): - self.Info("Monroe Instrument closed") - - - - - diff --git a/monroe/deprecated/monroe_plugin/MonroeExp/__init__.py b/monroe/deprecated/monroe_plugin/MonroeExp/__init__.py deleted file mode 100755 index 946d2a7..0000000 --- a/monroe/deprecated/monroe_plugin/MonroeExp/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ - -''' -Copyright (C) 2019 Fraunhofer FOKUS -''' - -''' Created by Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) on 15.02.2019 ''' - -from .MonroeExperiment import * - diff --git a/monroe/deprecated/tap_examples/ping_plugin/.gitkeep b/monroe/deprecated/tap_examples/ping_plugin/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/monroe/deprecated/tap_examples/ping_plugin/PingTest.py b/monroe/deprecated/tap_examples/ping_plugin/PingTest.py deleted file mode 100644 index 0d20033..0000000 --- a/monroe/deprecated/tap_examples/ping_plugin/PingTest.py +++ /dev/null @@ -1,92 +0,0 @@ - -''' -Copyright (C) 2019 Fraunhofer FOKUS -''' - -''' Created by Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) on 15.02.2019 ''' - -# Ping Test - - -import sys -import tap -import clr -clr.AddReference("System.Collections") -from System.Collections.Generic import List -from tap import * - -import Keysight.Tap -import math -from Keysight.Tap import Log, AvailableValuesAttribute, EnabledIfAttribute -from System import Array, Double, Byte, Int32, String, Boolean #Import types to reference for generic methods -import System -import requests - -from System.ComponentModel import BrowsableAttribute # BrowsableAttribute can be used to hide things from the user. - -#This is how attributes are used: -@Attribute(Keysight.Tap.DisplayAttribute, "FOKUS Ping Test", "Conduct a ping test", "Ping Test New") -@Attribute(Keysight.Tap.AllowAnyChildAttribute) -class PingTest(TestStep): - def __init__(self): - super(PingTest, self).__init__() # The base class initializer must be invoked. - - prop1 = self.AddProperty("host", None, String) - prop1.AddAttribute(Keysight.Tap.DisplayAttribute, "Host to ping to", "Host") - - prop2 = self.AddProperty("no_of_reqs", 5, Int32) - prop2.AddAttribute(Keysight.Tap.DisplayAttribute, "No of requests", "No of requests") - - self.AddProperty("instrument", None, PingInstrument) - - def Run(self): - self.instrument.setup(self.host, self.no_of_reqs) - super(PingTest, self).Run() - # Send the ping request - self.instrument.send_request(self.UpgradeVerdict) - -class PingInstrument(Instrument): - def __init__(self): - super(PingInstrument, self).__init__() - - prop = self.AddProperty("IPAddress", None, String) - prop.AddAttribute(Keysight.Tap.DisplayAttribute, "IP Address to connect", "IP address") - # Add Port - self.AddProperty("Port", None, Int32) - - self.RegisterMethod("setup", None) - self.RegisterMethod("send_request", None) - - def setup(self, host, no_of_reqs): - self.host = host - self.no_of_reqs = no_of_reqs - - def send_request(self, verdict): - url = ''.join(['http://', self.IPAddress, ':', str(self.Port), "/api/ping"]) - print(url) - params = { - "host": self.host, - "pingReqNum": self.no_of_reqs - } - response = requests.get(url, params=params) - if response.status_code == requests.codes.ok: - resp_data = response.json() - if 'rtt_avg' in resp_data: - verdict(Keysight.Tap.Verdict.Pass) - res_str = ' '.join(["The RTT average is", str(resp_data['rtt_avg']), "ms"]) - else: - verdict(Keysight.Tap.Verdict.Error) - res_str = 'The RTT average could not be calculated' - - print (res_str) - - def Open(self): - self.Info("Ping Instrument opened") - - def Close(self): - self.Info("Ping Instrument closed") - - - - - \ No newline at end of file diff --git a/monroe/deprecated/tap_examples/ping_plugin/__init__.py b/monroe/deprecated/tap_examples/ping_plugin/__init__.py deleted file mode 100644 index 18ac80f..0000000 --- a/monroe/deprecated/tap_examples/ping_plugin/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ - -''' -Copyright (C) 2019 Fraunhofer FOKUS -''' - -''' Created by Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) on 15.02.2019 ''' - -from .PingTest import * - diff --git a/monroe/deprecated/tap_examples/tap_agent/tap_agent.py b/monroe/deprecated/tap_examples/tap_agent/tap_agent.py deleted file mode 100644 index 2eff778..0000000 --- a/monroe/deprecated/tap_examples/tap_agent/tap_agent.py +++ /dev/null @@ -1,139 +0,0 @@ -''' - -Copyright (C) 2019 Fraunhofer FOKUS - -''' - -# Install packages - -# apt install python-pip - -# pip install flask -# pip install flask_restful -# pip install pingparsing -# pip install iperf3 - -# debian specific -# apt-get install libiperf0 - -''' Port Info - -REST API Listener at port 5000 (but can be configured) -Iperf server listens at port 5201 -''' - - -''' Created by Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) on 10.1.2019 ''' - - -from flask import Flask, request, jsonify -from flask_restful import Api, Resource, reqparse -import json -import pingparsing -import iperf3 - - -AGENT_PORT = 5000 - -app = Flask(__name__) -api = Api(app) - - -''' Ping Experiment ''' -class Ping(Resource): - def __init__(self): - pass - - ''' - GET request is handled - @return object that contains only RTT average; but can be further extended if required - ''' - def get(self): - print 'Ping Experiment: A GET request is received' - host = request.args.get('host') - req_count = request.args.get('pingReqNum') - result = self.get_ping_result(host, req_count) - - return jsonify({'rtt_avg': result['rtt_avg']}) - - ''' - Produces a set of ping results as a json object - ''' - def get_ping_result(self, host, count = 5): - ping_parser = pingparsing.PingParsing() - transmitter = pingparsing.PingTransmitter() - transmitter.destination_host = host - transmitter.count = count - result = transmitter.ping() - parse_result = ping_parser.parse(result).as_dict() - - return parse_result - - -''' Iperf Experiment ''' -class Iperf(Resource): - def __init__(self): - pass - - def get (self): - pass - - - def post(self): - srv_ip = None - cli_ip = None - set_as = None - - if 'srv_ip' in request.form: - srv_ip = request.form['srv_ip'] - - if 'cli_ip' in request.form: - cli_ip = request.form['cli_ip'] - - if 'set_as' in request.form: - set_as = request.form['set_as'] - - if set_as == "client": - response = self.client(srv_ip) - return jsonify({'throughput': response}) - elif set_as == "server": - response = self.server() - return response - else: - print ('Unknown args') - return -1 - - # Iperf client - def client(self, srv_ip): - if srv_ip == None: - print ("Invalid parameter") - return -1 - - print ("The Iperf client is running...") - client = iperf3.Client() - client.duration = 1 - client.server_hostname = srv_ip - client.port = 5201 - result = client.run() - - if result.error: - print(result.error) - return -1 - else: - print("The throughput is " + str(result.sent_Mbps) + " Mbps") - return result.sent_Mbps - - - # Iperf server - def server(self): - print ("The Iperf server is running...") - server = iperf3.Server() - result = server.run() - -# Register the paths -api.add_resource(Ping, "/api/ping") -api.add_resource(Iperf, "/api/iperf") - -# Agent listens on port AGENT_PORT -if __name__ == "__main__": - app.run(host='0.0.0.0', port=AGENT_PORT, debug=True, threaded=True) diff --git a/monroe/deprecated/tap_plugin_python/README.md b/monroe/deprecated/tap_plugin_python/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/monroe/deprecated/tap_plugin_python/__init__.py b/monroe/deprecated/tap_plugin_python/__init__.py deleted file mode 100644 index 8ccaa32..0000000 --- a/monroe/deprecated/tap_plugin_python/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ - -''' -Copyright (C) 2019 Fraunhofer FOKUS -''' - -''' Created by Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) on 04.03.2019 ''' - -__author__ = 'rsh' -__version__ = '0.0.1' - -from .ob_allocate_step import * -from .monroe_step import * -from .ob_destroy_step import * - diff --git a/monroe/deprecated/tap_plugin_python/imports.py b/monroe/deprecated/tap_plugin_python/imports.py deleted file mode 100644 index 1afaea3..0000000 --- a/monroe/deprecated/tap_plugin_python/imports.py +++ /dev/null @@ -1,32 +0,0 @@ - -''' -Copyright (C) 2019 Fraunhofer FOKUS -''' - -''' Created by Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) on 04.03.2019 ''' - -__author__ = 'rsh' -__version__ = '0.0.1' - -import sys -import tap -import clr -clr.AddReference("System.Collections") -from System.Collections.Generic import List -from tap import * - -import Keysight.Tap -import math -from Keysight.Tap import Log, AvailableValuesAttribute, EnabledIfAttribute, FilePathAttribute, AvailableValuesAttribute -from System import Array, Double, Byte, Int32, String, Boolean, Enum #Import types to reference for generic methods -import System -import requests - -from System.ComponentModel import BrowsableAttribute # BrowsableAttribute can be used to hide things from the user. - -import enum -import sys - -class RESPONSE_STATUS(enum.Enum): - OK = 1 - ERROR = 2 diff --git a/monroe/deprecated/tap_plugin_python/instrument.py b/monroe/deprecated/tap_plugin_python/instrument.py deleted file mode 100644 index 029fecd..0000000 --- a/monroe/deprecated/tap_plugin_python/instrument.py +++ /dev/null @@ -1,581 +0,0 @@ - -''' -Copyright (C) 2019 Fraunhofer FOKUS -''' - -''' Created by Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) on 04.03.2019 ''' - -__author__ = 'rsh' -__version__ = '0.0.1' - -from .imports import * -import json -import time -import grequests # async http calls - - -''' Berlin Platform TAP Instrument class - Base class is Instrument from TAP -''' - -@Attribute(Keysight.Tap.DisplayAttribute, "Instrument", "Interface to OpenBaton and OpenStack", "Berlin Platform") -class Instrument(Instrument): - def __init__(self): - super(Instrument, self).__init__() - - # Openbaton IP Address - ob_ip = self.AddProperty("openbaton_ip", "127.0.0.1", String) - ob_ip.AddAttribute(Keysight.Tap.DisplayAttribute, "IP Address", "OpenBaton IP Address", Group="Open Baton", Order=1.1) - - # Openbaton Port - ob_port = self.AddProperty("openbaton_port", 8080, Int32) - ob_port.AddAttribute(Keysight.Tap.DisplayAttribute, "Port", "OpenBaton Port", Group="Open Baton", Order=1.2) - - # OpenStack IP Address - os_ip = self.AddProperty("openstack_ip", "127.0.0.1", String) - os_ip.AddAttribute(Keysight.Tap.DisplayAttribute, "IP Address", "OpenStack IP Address", Group="Open Stack", Order=2.1) - - # OpenStack Port - os_port = self.AddProperty("openstack_port", 5000, Int32) - os_port.AddAttribute(Keysight.Tap.DisplayAttribute, "Port", "OpenStack Port", Group="Open Stack", Order=2.2) - - # Zabbix Server - allow_zabbix_srv = self.AddProperty("allow_zabbix_srv", False, Boolean) - allow_zabbix_srv.AddAttribute(Keysight.Tap.DisplayAttribute, "Enable Zabbix Server", "Enable Zabbix Server", Group="Monitoring Server", Order=3.1) - - zs_ip = self.AddProperty("zabbix_srv_ip", "127.0.0.1", String) - zs_ip.AddAttribute(Keysight.Tap.DisplayAttribute, "Server IP", "Zabbix Server IP", Group="Monitoring Server", Order=3.2) - zs_ip.AddAttribute(Keysight.Tap.EnabledIfAttribute, "allow_zabbix_srv", HideIfDisabled=True) - - ''' Get the openbaton token ''' - def get_openbaton_token(self): - self.openbaton_token_response = {} - - headers = { - 'Accept': 'application/json', - } - - data = { - 'username': 'xxx', - 'password': 'xxx', - 'grant_type': 'password' - } - - url = ''.join(['http://', self.openbaton_ip, ':', str(self.openbaton_port), '/oauth/token']) - - auth = ('openbatonOSClient', 'secret') - - response = requests.post(url, headers=headers, data=data, auth=auth) - - if response.status_code == requests.codes.ok: # 200 - resp_json = response.json() - self.Info("The openbaton token is {0}", resp_json['value']) # Displays the token - self.openbaton_token_response = { - "status": RESPONSE_STATUS.OK, - "result": { - "token": resp_json['value'] - } - } - else: - self.openbaton_token_response = { - "status": RESPONSE_STATUS.ERROR, - } - - return self.openbaton_token_response - - '''' Load VIM instance in openbaton ''' - def create_vim_instance(self, token, project_id): - self.openbaton_vim_instance_response = {} - self.project_id = project_id - - headers = { - "Content-Type": "application/json", - "Authorization": ' '.join(["Bearer", token]), - "project-id": project_id - } - - data = json.dumps({ - "name": "5genesis-vim-tap", - "authUrl": ''.join(['http://', self.openstack_ip, ':', str(self.openstack_port), '/v3']), - "tenant": "xxx", - "username": "xxx", - "password": "xxx", - "keyPair":"5genesis", - "securityGroups": [ - "default" - ], - "type":"openstack", - "location": { - "name":"Berlin", - "latitude":"52.525876", - "longitude":"13.314400" - } - }) - - url = ''.join(['http://', self.openbaton_ip, ':', str(self.openbaton_port), '/api/v1/datacenters']) - - response = requests.post(url, headers=headers, data=data) - - if response.status_code == requests.codes.ok or response.status_code == 201: - resp_data = response.json() - - self.openbaton_vim_instance_response = { - "status": RESPONSE_STATUS.OK, - "result": { - "vim_inst_id": resp_data['id'], - "vim_name": resp_data['name'] - } - } - else: - self.openbaton_vim_instance_response = { - "status": RESPONSE_STATUS.ERROR - } - - return self.openbaton_vim_instance_response - - ''' Load vnf-packages (*.tar) to openbaton - Multiple async requests are sent if there are multiple vnf-packages - ''' - def upload_vnf_package(self, token, project_id, files): - self.openbaton_vnf_pkg_response = {} - - def exception_handler(request, exception): - print ("Request failed") - - headers = { - "Authorization": ' '.join(["Bearer", token]), - "project-id": project_id - } - - files_list = [] - - for file in files: - files_list.append( - { - "file": (''.join([file]), open(''.join([file]), 'rb')), - } - ) - - url = ''.join(['http://', self.openbaton_ip, ':', str(self.openbaton_port), '/api/v1/vnf-packages']) - - requests_list = [] - for file in files_list: - requests_list.append(grequests.post(url, headers=headers, files=file)) - - responses = grequests.map(requests_list, exception_handler=exception_handler) - - resp_data = [r.json() for r in responses if r.status_code == requests.codes.ok] - - vnfd_ids = [r['id'] for r in resp_data if r is not None] - vnf_pkg_ids = [r['vnfPackageLocation'] for r in resp_data if r is not None] - vnf_pkg_names = [r['name'] for r in resp_data if r is not None] - print('The vnfd ids {}'.format(vnfd_ids)) - print('The vnf-pkg ids {}'.format(vnf_pkg_ids)) - - vnf_pkg_names = vnf_pkg_names[::-1] # reversing the list to avoid conflict with the specified Availability Zones in TAP GUI. - print('The vnf-pkg names {}'.format(vnf_pkg_names)) - - self.openbaton_vnf_pkg_response = { - "status": RESPONSE_STATUS.OK, - "result": { - "vnfd_ids": vnfd_ids, - "vnf_pkg_ids": vnf_pkg_ids, - "vnf_pkg_names": vnf_pkg_names - } - } - - return self.openbaton_vnf_pkg_response - - ''' Create NSD in openbaton ''' - def create_nsd(self, token, project_id, vnfd_ids): - self.openbaton_nsd_response = {} - - headers = { - 'Content-Type': 'application/json', - "Authorization": ' '.join(["Bearer", token]), - "project-id": project_id - } - vnfds = [{"id": v} for v in vnfd_ids if v is not None] - data = json.dumps({ - "name": "monroe", - "vendor": "fokus", - "version": "1.0", - "vld": [], - "vnfd": vnfds - }) - url = ''.join(['http://', self.openbaton_ip, ':', str(self.openbaton_port), '/api/v1/ns-descriptors']) - - response = requests.post(url, headers=headers, data=data) - - if response.status_code == requests.codes.ok or response.status_code == 201: - resp_data = response.json() - self.Info('The NSD Id is {0}', resp_data['id']) - self.openbaton_nsd_response = { - "status": RESPONSE_STATUS.OK, - "result": { - "nsd_id": resp_data['id'] - } - } - else: - self.openbaton_nsd_response = { - "status": RESPONSE_STATUS.ERROR - } - - return self.openbaton_nsd_response - - ''' Launch NSD in openbaton ''' - def launch_nsd(self, token, nsd_id, project_id, client, server, vnf_pkg_names): - self.openbaton_nsd_launch_response = {} - - headers = { - 'Content-Type': 'application/json', - 'Authorization': ' '.join(['Bearer', token]), - 'project-id': project_id, - } - - client = [''.join([client['vim_name'], ":", client['zone']])] - if server is not None: - server = [''.join([server['vim_name'], ":", server['zone']])] - - print("The client is {}".format(client)) - print("The server is {}".format(server)) - - # adds -1 to the vnf pkg name to follow naming convention in openbaton. - def convert_vnf_pkg_names(vnf_pkg_name): - return ''.join([vnf_pkg_name, '-1']) - - updated_vnf_pkg_names = map(convert_vnf_pkg_names, vnf_pkg_names) - - vduVimInstances = {} - vduVimInstances[updated_vnf_pkg_names[0]] = client - if server is not None: - vduVimInstances[updated_vnf_pkg_names[1]] = server - - if self.allow_zabbix_srv: - data = json.dumps({ - "keys": [], - "configurations": {}, - "vduVimInstances": vduVimInstances, - "monitoringIp" : self.zabbix_srv_ip # zabbix server ip - }) - else: - data = json.dumps({ - "keys": [], - "configurations": {}, - "vduVimInstances": vduVimInstances - }) - - url = ''.join(['http://', self.openbaton_ip, ':', str(self.openbaton_port), '/api/v1/ns-records/', nsd_id]) - - response = requests.post(url, headers=headers, data=data) - resp_data = response.json() - - #nsr_status = resp_data['status'] - nsr_id = resp_data['id'] # id of newly created nsr instance - - server_status = True if server is not None else False - - get_nsr_data = self.check_nsr_status(headers, nsr_id, server_status) - if get_nsr_data['status']: - self.openbaton_nsd_launch_response = { - "status": RESPONSE_STATUS.OK, - "result": { - "nsr_id": get_nsr_data['nsr_id'] - } - } - elif get_nsr_data['status'] is False: - self.openbaton_nsd_launch_response = { - "status": RESPONSE_STATUS.ERROR - } - - return self.openbaton_nsd_launch_response - - - ''' Check the status of NSR from NULL => ACTIVE - Continuous requests are sent in intervals to track the state of NSR in openbaton - ''' - def check_nsr_status(self, headers, nsr_id, server_status): - self.openbaton_nsr_response = {} - - url = ''.join(['http://', self.openbaton_ip, ':', str(self.openbaton_port), '/api/v1/ns-records/', nsr_id]) - attempt = 1 - while True: - response = requests.get(url, headers=headers) - response_data = response.json() - - if 'status' in response_data: - self.Info('Checking the status of NSR: {0}, Attempt No.: {1}', response_data['status'], attempt) - status = response_data['status'] - if status and status == 'ACTIVE': - for k, _ in enumerate(response_data['vnfr']): - if self.openbaton_vnf_pkg_response['result']['vnf_pkg_names'][0] == response_data['vnfr'][k]['name']: - client_ip = response_data['vnfr'][k]['vdu'][0]['vnfc_instance'][0]['ips'][0]['ip'] - client_floating_ip = response_data['vnfr'][k]['vdu'][0]['vnfc_instance'][0]['floatingIps'][0]['ip'] - self.Info('The Client ip is {0}', client_ip) - self.Info('The Client floating ip {0}', client_floating_ip) - - if server_status: - if self.openbaton_vnf_pkg_response['result']['vnf_pkg_names'][1] == response_data['vnfr'][k]['name']: - server_ip = response_data['vnfr'][k]['vdu'][0]['vnfc_instance'][0]['ips'][0]['ip'] - server_floating_ip = response_data['vnfr'][k]['vdu'][0]['vnfc_instance'][0]['floatingIps'][0]['ip'] - self.Info('The Server ip {0}', server_ip) - self.Info('The Server floating ip is {0}', server_floating_ip) - else: - self.Debug('Server/Responder is not deployed by OpenBaton.') - server_ip = None - server_floating_ip = None - - self.Info('Status of NSR is {0}', status) - self.openbaton_nsr_response = { - "client_ip": client_ip, - "server_ip": server_ip, - "client_floating_ip": client_floating_ip, - "server_floating_ip": server_floating_ip, - "status": True, - "nsr_id": nsr_id, - } - break - elif status == 'ERROR': - self.openbaton_nsr_response = { - "status": False - } - break - else: - time.sleep(2) - attempt = attempt + 1 - else: - self.Error('NSR status is not available.') - self.openbaton_nsr_response = { - "status": False - } - break - - return self.openbaton_nsr_response - - - ''' Send request to Monroe Client ''' - def send_request(self, configs): - monroe_expt_response = {} - url = None - - if configs['enable_manual_config']: - url = ''.join(['http://', str(configs['monroe_vm_ip']), ':', str(configs['agent_port']), "/api/monroe"]) - self.Debug("{0}", url) - - params = { - "config": configs['config'], - "duration": configs['duration'] - } - params['config'] = json.dumps(params['config']) - - elif 'status' in self.openbaton_nsr_response and self.openbaton_nsr_response['status']: - if self.openbaton_nsr_response['client_floating_ip'] is not None: - url = ''.join(['http://', self.openbaton_nsr_response['client_floating_ip'], ':', str(configs['agent_port']), "/api/monroe"]) - self.Debug("{0}", url) - - params = { - "config": configs['config'], - "duration": configs['duration'] - } - - if 'server_ip' in self.openbaton_nsr_response and self.openbaton_nsr_response['server_ip'] is not None: - params['config']['server'] = self.openbaton_nsr_response['server_ip'] - - params['config'] = json.dumps(params['config']) - else: - monroe_expt_response = { - 'status': RESPONSE_STATUS.ERROR, - 'result': { - 'str': 'Client Floating IP is not available.' - } - } - else: - monroe_expt_response = { - 'status': RESPONSE_STATUS.ERROR, - 'result': { - 'str': 'OpenBaton NSR status not available or has Error.' - } - } - - if url is not None: - self.Info('The final experiment configuration is {0}'.format(params)) - - response = requests.get(url, params=params) - if response.status_code == requests.codes.ok: - resp_data = response.json() - if 'results' in resp_data: - monroe_expt_response = { - 'status': RESPONSE_STATUS.OK, - 'result': { - 'str': ' '.join(["The results are available at", resp_data['results']]) - } - } - else: - monroe_expt_response = { - 'status': RESPONSE_STATUS.ERROR, - 'result': { - 'str': 'The results location is not available.' - } - } - else: - resp_data = response.json() - if 'reasons' in resp_data: - monroe_expt_response = { - 'status': RESPONSE_STATUS.ERROR, - 'result': { - 'str': ' '.join(["FAILED: ", resp_data['reasons']]) - } - } - else: - monroe_expt_response = { - 'status': RESPONSE_STATUS.ERROR, - 'result': { - 'str': 'Failing reasons are not available.' - } - } - else: - self.Debug('The url is not set.') - monroe_expt_response = { - 'status': RESPONSE_STATUS.ERROR, - 'result': { - 'str': 'The request url is not set.' - } - } - - return monroe_expt_response - - ''' Delete the NSR ''' - def delete_nsr(self): - headers = { - 'Content-Type': 'application/json', - 'Authorization': ' '.join(['Bearer', self.openbaton_token_response['result']['token']]), - 'project-id': self.project_id, - } - - url = ''.join(['http://', self.openbaton_ip, ':', str(self.openbaton_port), '/api/v1/ns-records/', - self.openbaton_nsd_launch_response['result']['nsr_id']]) - - response = requests.delete(url, headers=headers) - print("Delete NSR {}".format(response)) - - if response.status_code == requests.codes.ok or response.status_code == 204: - self.Info('NSR deleted. No payload in response.') - return { - "status": RESPONSE_STATUS.OK - } - else: - return { - "status": RESPONSE_STATUS.ERROR - } - - ''' Delete the NSD ''' - def delete_nsd(self): - headers = { - "Authorization": ' '.join(["Bearer", self.openbaton_token_response['result']['token']]), - "project-id": self.project_id, - } - - url = ''.join(['http://', self.openbaton_ip, ':', str(self.openbaton_port), - '/api/v1/ns-descriptors/', self.openbaton_nsd_response['result']['nsd_id']]) - - response = requests.delete(url, headers=headers) - print("Delete NSD {}".format(response)) - - if response.status_code == requests.codes.ok or response.status_code == 204: - self.Info('NSD deleted. No payload in response.') - return { - "status": RESPONSE_STATUS.OK - } - else: - return { - "status": RESPONSE_STATUS.ERROR - } - - - ''' Delete the VNF packages : To be updated: not in use for now''' - ''' - def delete_vnf_packages(self, token, project_id, vnf_packages_ids): - headers = { - "Authorization": ' '.join(["Bearer", self.openbaton_token_response['result']['token']]), - "project-id": self.project_id, - } - - urls = [] - for id in vnf_packages_ids: - urls.append(''.join(['http://', self.openbaton_ip, ':', str(self.openbaton_port), '/api/v1/vnf-packages/', id])) - - requests = [] - for url in urls: - print (url) - requests.append(grequests.delete(url, headers=headers)) - - responses = grequests.map(requests) - print ("Delete VNF-Packages", responses) - - for response in responses: - if response.status_code == 200: - print (response.json()) - elif response.status_code == 204: - print ('VNF-Packages deleted. No payload in response.') ''' - - ''' Delete multiple vnf packages ''' - def delete_multi_vnf_packages(self,): - headers = { - "Content-Type": "application/json", - "Authorization": ' '.join(["Bearer", self.openbaton_token_response['result']['token']]), - "project-id": self.project_id, - } - - data = json.dumps(self.openbaton_vnf_pkg_response['result']['vnf_pkg_ids']) - - url = ''.join(['http://', self.openbaton_ip, ':', str(self.openbaton_port), '/api/v1/vnf-packages/multipledelete']) - - response = requests.post(url, headers=headers, data=data) - print("Delete multi VNF-packages {}".format(response)) - - if response.status_code == requests.codes.ok or response.status_code == 204: - self.Info("VNF-Packages deleted. No payload in response") - return { - "status": RESPONSE_STATUS.OK - } - else: - return { - "status": RESPONSE_STATUS.ERROR - } - - - ''' Delete Vim Instance ''' - def delete_vim_instance(self): - headers = { - "Authorization": ' '.join(["Bearer", self.openbaton_token_response['result']['token']]), - "project-id": self.project_id, - } - - url = ''.join(['http://', self.openbaton_ip, ':', str(self.openbaton_port), - '/api/v1/datacenters/', self.openbaton_vim_instance_response['result']['vim_inst_id']]) - - response = requests.delete(url, headers=headers) - print("Delete VIM instance {}".format(response)) - - if response.status_code == requests.codes.ok or response.status_code == 204: - self.Info('VIM instance deleted. No payload in response.') - return { - "status": RESPONSE_STATUS.OK - } - else: - return { - "status": RESPONSE_STATUS.ERROR - } - - ''' Opens the instrument - Overriden function - ''' - def Open(self): - self.Info("Instrument opened") - - ''' Close the instrument - Overriden function - ''' - def Close(self): - self.Info("Instrument closed") - diff --git a/monroe/deprecated/tap_plugin_python/monroe_step.py b/monroe/deprecated/tap_plugin_python/monroe_step.py deleted file mode 100644 index 2c1d43a..0000000 --- a/monroe/deprecated/tap_plugin_python/monroe_step.py +++ /dev/null @@ -1,152 +0,0 @@ -''' -Copyright (C) 2019 Fraunhofer FOKUS -''' - -''' Adapted by Mohammad Rajiullah from Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) ''' - -# MONROE Experiment -from .imports import * -from .instrument import * - -@Attribute(Keysight.Tap.DisplayAttribute, "Monroe Experiment", "Monroe Experiment", "Monroe Virtual Node") -@Attribute(Keysight.Tap.AllowAnyChildAttribute) -class MonroeExperiment(TestStep): - def __init__(self): - super(MonroeExperiment, self).__init__() - - prop1 = self.AddProperty("script","monroe/ping", String) - prop1.AddAttribute(Keysight.Tap.DisplayAttribute, "Container to run", "Script", Group="Monroe Configuration", Order=2.1) - - prop2 = self.AddProperty("start", 2, Int32) - prop2.AddAttribute(Keysight.Tap.DisplayAttribute, "Start", "Start", Group="Monroe Configuration", Order=2.2) - - prop3 = self.AddProperty("storage", 99999999, Int32) - prop3.AddAttribute(Keysight.Tap.DisplayAttribute, "Storage", "Storage", Group="Monroe Configuration", Order=2.3) - - prop4 = self.AddProperty("interfacename", "eth0", String) - prop4.AddAttribute(Keysight.Tap.DisplayAttribute, "Interface Name", "Interface Name", Group="Monroe Configuration", Order=2.4) - - prop6 = self.AddProperty("interface_without_metadata", "eth0", String) - prop6.AddAttribute(Keysight.Tap.DisplayAttribute, "Interface without metadata", "Interface without metadata", Group="Monroe Configuration", Order=2.5) - - prop5 = self.AddProperty("option","{\"server\":\"8.8.8.8\"}", String) - prop5.AddAttribute(Keysight.Tap.DisplayAttribute, "Optional parameters", "Options passed to the experiment (json string)", Group="Monroe Configuration", Order=2.6) - - prop7 = self.AddProperty("duration", 30, Int32) - prop7.AddAttribute(Keysight.Tap.DisplayAttribute, "Duration of the experiment (s)", "Duration of the experiment", Group="Monroe Configuration", Order=2.7) - prop7.AddAttribute(Keysight.Tap.UnitAttribute, "s") - - prop8 = self.AddProperty("agent_port", 8080, Int32) - prop8.AddAttribute(Keysight.Tap.DisplayAttribute, "Agent Port", "Agent Port", Group="TAP Agent", Order=4) - - prop9 = self.AddProperty("enable_manual_config", False, Boolean) - prop9.AddAttribute(Keysight.Tap.DisplayAttribute, "Enable manual VM configuration", "Enable manual VM configuration", Group="Monroe VM Configuration", Order=3.1) - - prop10 = self.AddProperty("monroe_vm_ip", "127.0.0.1", String) - prop10.AddAttribute(Keysight.Tap.DisplayAttribute, "Monroe VM IP Address", "Monroe VM IP Address", Group="Monroe VM Configuration", Order=3.2) - prop10.AddAttribute(Keysight.Tap.EnabledIfAttribute, "enable_manual_config", HideIfDisabled=True) - - self.AddProperty("Instrument", None, Instrument).AddAttribute(Keysight.Tap.DisplayAttribute, "Instrument", "Instrument", Group="Instrument", Order=1) - - - def PrePlanRun(self,): - super(MonroeExperiment, self).PrePlanRun() - self.Info('MonroeExperiment: Preliminary check started.') - - status = False # error status - - if not self.script: - self.Error('Script field is not present.') - status = True - - if not self.start: - self.Error('Start field is not present.') - status = True - - if not self.storage: - self.Error('Storage field is not present.') - status = True - - if not self.interfacename: - self.Error('Interface name is not present.') - status = True - - if not self.interface_without_metadata: - self.Error('Interface without metadata field is not present.') - status = True - - if not self.option: - self.Error('Option field is not present.') - status = True - - if self.option and not self.is_json(self.option): - self.Error('Option field string not in JSON format.') - status = True - - if not self.duration: - self.Error('Duration field is not present.') - status = True - - if self.enable_manual_config and not self.monroe_vm_ip: - self.Error('Monroe VM IP is not present.') - status = True - elif not self.enable_manual_config: - self.Warning('Manual Monroe VM IP Address configuration is not enabled. OpenBaton is expected to be in use.') - - if not self.agent_port: - self.Error('Agent port is not present.') - status = True - - if status: - self.UpgradeVerdict(Keysight.Tap.Verdict.Error) - sys.exit("Error has occurred. Exiting the program.") - else: - self.Info('MonroeExperiment: Preliminary check completed.') - - - def Run(self): - configDict = {} - configDict["script"] = self.script - configDict["start"] = str(self.start) - configDict["storage"] = str(self.storage) - configDict["interfacename"] = self.interfacename - configDict["interface_without_metadata"] = [self.interface_without_metadata] - - json_object = json.loads(self.option) - for item in json_object: - configDict[item]=json_object[item] - - - self.config = configDict - - #self.Info("The experiment configuration is {0}", self.config) - - super(MonroeExperiment, self).Run() - request_monroe_config = { - "config": self.config, - "duration": self.duration, - "agent_port": self.agent_port, - "enable_manual_config": self.enable_manual_config, - "monroe_vm_ip": self.monroe_vm_ip - } - - # Send the experiment request - response = self.Instrument.send_request(request_monroe_config) - - if response['status'] == RESPONSE_STATUS.OK: - self.Info('Monroe experiment is successful.') - self.Info("{0}", response['result']['str']) - self.UpgradeVerdict(Keysight.Tap.Verdict.Pass) - else: - self.Error('Monroe experiment is unsuccessful.') - self.Error("{0}", response['result']['str']) - self.UpgradeVerdict(Keysight.Tap.Verdict.Error) - - - def is_json(self, myjson): - try: - json_object = json.loads(myjson) - except ValueError, e: - return False - - return True \ No newline at end of file diff --git a/monroe/deprecated/tap_plugin_python/ob_allocate_step.py b/monroe/deprecated/tap_plugin_python/ob_allocate_step.py deleted file mode 100644 index 5818c68..0000000 --- a/monroe/deprecated/tap_plugin_python/ob_allocate_step.py +++ /dev/null @@ -1,138 +0,0 @@ - -''' -Copyright (C) 2019 Fraunhofer FOKUS -''' - -''' Created by Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) on 04.03.2019 ''' - -__author__ = 'rsh' -__version__ = '0.0.1' - -from .imports import * -from .instrument import * -from array import array - -@Attribute(Keysight.Tap.DisplayAttribute, "OpenBaton Resources Allocate", Description="Allocate Resources", Group="Berlin Platform") -@Attribute(Keysight.Tap.AllowAnyChildAttribute) -class OpenBatonAllocateResource(TestStep): - def __init__(self): - super(OpenBatonAllocateResource, self).__init__() - - # Project ID - project_id = self.AddProperty("project_id", "ec3e72a0-3897-49d6-a5ed-3cc60376f19a", String) - project_id.AddAttribute(Keysight.Tap.DisplayAttribute, "Project ID", Description="Project ID", Group="OpenBaton Project ID", Order=2, Collapsed=False) - - # Load Server-Client Boolean Property - load_srv_cli_bool = self.AddProperty("load_srv_cli", True, Boolean) - load_srv_cli_bool.AddAttribute(Keysight.Tap.DisplayAttribute, "Load Client and Server", "Load Client and Server", Group="Load Client & Server", Order=3) - - # Create a Availability Zones dot net Array property and make it hidden - availability_zones = ["AZ1", "AZ2"] - availability_zones_dot_net = Array[str](availability_zones) - self.AddProperty("az_hidden", availability_zones_dot_net, Array).AddAttribute(BrowsableAttribute, False) # Hide the property - # Availability Zone - availability_zone1 = self.AddProperty("client_zone", availability_zones[0], String) - availability_zone1.AddAttribute(Keysight.Tap.DisplayAttribute, "Client", "Client Availability Zone", Group="Availability Zone", Order=4.1) - availability_zone1.AddAttribute(Keysight.Tap.AvailableValuesAttribute, "az_hidden") - - availability_zone2 = self.AddProperty("server_zone", availability_zones[0], String) - availability_zone2.AddAttribute(Keysight.Tap.DisplayAttribute, "Server", "Server Availability Zone", Group="Availability Zone", Order=4.2) - availability_zone2.AddAttribute(Keysight.Tap.EnabledIfAttribute, "load_srv_cli", HideIfDisabled=True) - availability_zone2.AddAttribute(Keysight.Tap.AvailableValuesAttribute, "az_hidden") - - # Load VNF Packages - load_vnf_pkg_client = self.AddProperty("client_vnf_pkg_path", None, String); - load_vnf_pkg_client.AddAttribute(FilePathAttribute, FilePathAttribute.BehaviorChoice.Open, "tar") - load_vnf_pkg_client.AddAttribute(Keysight.Tap.DisplayAttribute, "VNF Package Client", "VNF Package Client", Group="OpenBaton VNF Packages", Order=5.1) - - load_vnf_pkg_server = self.AddProperty("server_vnf_pkg_path", None, String); - load_vnf_pkg_server.AddAttribute(FilePathAttribute, FilePathAttribute.BehaviorChoice.Open, "tar") - load_vnf_pkg_server.AddAttribute(Keysight.Tap.DisplayAttribute, "VNF Package Server", "VNF Package Server", Group="OpenBaton VNF Packages", Order=5.2) - load_vnf_pkg_server.AddAttribute(Keysight.Tap.EnabledIfAttribute, "load_srv_cli", HideIfDisabled=True) - - # Add the Instrument - self.AddProperty("Instrument", None, Instrument).AddAttribute(Keysight.Tap.DisplayAttribute, "Instrument", "Instrument", Group="Instrument", Order=1) - - def PrePlanRun(self,): - super(OpenBatonAllocateResource, self).PrePlanRun() - - status = False - self.Info('OpenBatonAllocateResource: Preliminary check started.') - - if not self.project_id: - self.Error('Project Id not present or of not string type') - status = True - - if self.load_srv_cli: - if not (self.client_zone and self.server_zone): - self.Error('Availability zones are not present.') - status = True - - if not (self.client_vnf_pkg_path and self.server_vnf_pkg_path): - self.Error('VNF Package paths are not available.') - status = True - else: - if not self.client_zone: - self.Error('Availability zone is not present.') - status = True - - if not self.client_vnf_pkg_path: - self.Error('VNF Package path is not available.') - status = True - - if status: - self.UpgradeVerdict(Keysight.Tap.Verdict.Error) - sys.exit("Error has occurred. Exiting the program.") - else: - self.Info('OpenBatonAllocateResource: Preliminary check completed.') - - def Run(self): - super(OpenBatonAllocateResource, self).Run() - - response_token = self.Instrument.get_openbaton_token() - if response_token['status'] == RESPONSE_STATUS.OK: - # Create VIM instance - response_vim_instance = self.Instrument.create_vim_instance(response_token['result']['token'], self.project_id) - if response_vim_instance['status'] == RESPONSE_STATUS.OK: - # Create VNF-packages - if self.load_srv_cli: - files = [self.server_vnf_pkg_path, self.client_vnf_pkg_path] - else: - files = [self.client_vnf_pkg_path] - response_vnf_pkg = self.Instrument.upload_vnf_package(response_token['result']['token'], self.project_id, files) - - if response_vnf_pkg['status'] == RESPONSE_STATUS.OK: - # Create NSD #nsd_id - response_nsd = self.Instrument.create_nsd(response_token['result']['token'], self.project_id, response_vnf_pkg['result']['vnfd_ids']) - - if response_nsd['status'] == RESPONSE_STATUS.OK: - # Launching NSD (=> creating VMs based on the package) - client = {"vim_name": response_vim_instance['result']['vim_name'], "zone": self.client_zone} - if self.load_srv_cli: - server = {"vim_name": response_vim_instance['result']['vim_name'], "zone": self.server_zone} - else: - server = None - - response_launch_nsd = self.Instrument.launch_nsd(response_token['result']['token'], - response_nsd['result']['nsd_id'], - self.project_id, - client, server, - response_vnf_pkg['result']['vnf_pkg_names']) - if response_launch_nsd['status'] == RESPONSE_STATUS.OK: - self.Info('OpenBaton Resources Allocation completed successfully.') - self.UpgradeVerdict(Keysight.Tap.Verdict.Pass) - else: - self.Error('Error occurred while launching NSD') - self.UpgradeVerdict(Keysight.Tap.Verdict.Error) - else: - self.Error('Error occurred while creating NSD') - self.UpgradeVerdict(Keysight.Tap.Verdict.Error) - else: - self.Error('Error occurred while creating VNF Packages') - self.UpgradeVerdict(Keysight.Tap.Verdict.Error) - else: - self.Error('Error occurred while creating VIM Instance') - self.UpgradeVerdict(Keysight.Tap.Verdict.Error) - else: - self.Error('Token not found from OpenBaton. Cannot proceed.') - self.UpgradeVerdict(Keysight.Tap.Verdict.Error) \ No newline at end of file diff --git a/monroe/deprecated/tap_plugin_python/ob_destroy_step.py b/monroe/deprecated/tap_plugin_python/ob_destroy_step.py deleted file mode 100644 index 307d986..0000000 --- a/monroe/deprecated/tap_plugin_python/ob_destroy_step.py +++ /dev/null @@ -1,51 +0,0 @@ - -''' -Copyright (C) 2019 Fraunhofer FOKUS -''' - -''' Created by Ranjan Shrestha (ranjan.shrestha@fokus.fraunhofer.de) on 04.03.2019 ''' - -__author__ = 'rsh' -__version__ = '0.0.1' - -from .imports import * -from .instrument import * - -@Attribute(Keysight.Tap.DisplayAttribute, "OpenBaton Resources Destroy", Description="Destroy Resources", Group="Berlin Platform") -@Attribute(Keysight.Tap.AllowAnyChildAttribute) -class OpenBatonDestroyResource(TestStep): - def __init__(self): - super(OpenBatonDestroyResource, self).__init__() - - # Add the Instrument - self.AddProperty("Instrument", None, Instrument).AddAttribute(Keysight.Tap.DisplayAttribute, "Instrument", "Instrument", Group="Instrument", Order=1) - - - def Run(self): - super(OpenBatonDestroyResource, self).Run() - # Delete NSR - response_delete_nsr = self.Instrument.delete_nsr() - if response_delete_nsr['status'] == RESPONSE_STATUS.OK: - time.sleep(1) - # Delete NSD - response_delete_nsd = self.Instrument.delete_nsd() - if response_delete_nsd['status'] == RESPONSE_STATUS.OK: - time.sleep(1) - # Delete VNF Packages - response_delete_vnf_pkgs = self.Instrument.delete_multi_vnf_packages() - if response_delete_vnf_pkgs['status'] == RESPONSE_STATUS.OK: - time.sleep(1) - # Delete VIM Instance - response_delete_vim_instance = self.Instrument.delete_vim_instance() - if response_delete_vim_instance['status'] == RESPONSE_STATUS.OK: - self.Info('OpenBaton Resources Destroy completed successfully.') - self.UpgradeVerdict(Keysight.Tap.Verdict.Pass) - else: - self.Error('Cannot delete VIM Instance.') - self.UpgradeVerdict(Keysight.Tap.Verdict.Error) - else: - self.Error('Cannot delete VNF Packages.') - else: - self.Error('Cannot delete NSD.') - else: - self.Error('Cannot delete NSR.') \ No newline at end of file diff --git a/monroe/tap-agent/.gitignore b/monroe/tap-agent/.gitignore deleted file mode 100644 index 8b907e3..0000000 --- a/monroe/tap-agent/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -*.deb -*.pyc diff --git a/monroe/tap-agent/DEBIAN/conffiles b/monroe/tap-agent/DEBIAN/conffiles deleted file mode 100644 index e69de29..0000000 diff --git a/monroe/tap-agent/DEBIAN/control b/monroe/tap-agent/DEBIAN/control deleted file mode 100644 index 385c484..0000000 --- a/monroe/tap-agent/DEBIAN/control +++ /dev/null @@ -1,10 +0,0 @@ -Package: monroe-tap-agent -Version: 0.1.2 -Section: devel -Priority: optional -Architecture: amd64 -Depends: python3-flask (>=0.12.1-1), monroe-experiment-core (>=0.2.0), python3-flask-api (>=0.6.4), openssl (>=1.1) -Installed-Size: 73 -Maintainer: Jonas Karlsson -Description: Installs a TAP agent to control and exectue experiments on a monroe node. - diff --git a/monroe/tap-agent/DEBIAN/postinst b/monroe/tap-agent/DEBIAN/postinst deleted file mode 100755 index 3d2b5ef..0000000 --- a/monroe/tap-agent/DEBIAN/postinst +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# Gereate a new cert since Debian 9 does not work with adhoc mode (too old "werkzeug") -openssl req -x509 -newkey rsa:4096 -nodes -out /opt/monroe/tap-agent/cert.pem -keyout /opt/monroe/tap-agent/key.pem -days 3650 -subj "/O=Monroe Project/CN=localhost" -#Change the default to point to the newly created files -sed -i "s#TAP_AGENT_CERT=.*#TAP_AGENT_CERT=/opt/monroe/tap-agent/cert.pem#g" /opt/monroe/tap-agent/monroe-tap-agent -sed -i "s#TAP_AGENT_KEY=.*#TAP_AGENT_KEY=/opt/monroe/tap-agent/key.pem#g" /opt/monroe/tap-agent/monroe-tap-agent - -systemctl enable monroe-tap-agent -systemctl start monroe-tap-agent diff --git a/monroe/tap-agent/DEBIAN/prerm b/monroe/tap-agent/DEBIAN/prerm deleted file mode 100755 index 3dff89e..0000000 --- a/monroe/tap-agent/DEBIAN/prerm +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -systemctl stop monroe-tap-agent -systemctl disable monroe-tap-agent diff --git a/monroe/tap-agent/Dockerfile b/monroe/tap-agent/Dockerfile deleted file mode 100644 index b0ec98c..0000000 --- a/monroe/tap-agent/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -# Author: Jonas Karlsson -# Date: April 2019 -# License: - -FROM debian:stretch -MAINTAINER jonas.Karlsson@kau.se - -#APT OPTS -ENV APT_OPTS -y --allow-downgrades --allow-remove-essential --allow-change-held-packages --no-install-recommends --no-install-suggests --allow-unauthenticated - -RUN sed -i -e 's/main/main non-free/g' /etc/apt/sources.list -RUN export DEBIAN_FRONTEND=noninteractive && apt-get update -RUN apt-get ${APT_OPTS} install \ - python3-pip \ - fakeroot - -#If we have written something in python3.6 syntax, ie fstrings -RUN pip3 install f2format - -# Used to add extra commands neded be executed before build -RUN echo 'mkdir -p /source/' >> /prebuild.sh -RUN echo 'cp -a /source-ro/* /source' >> /prebuild.sh -RUN echo 'for f in ${IGNORE_FILES}; do rm -f /source/$f ; done' >> prebuild.sh -RUN echo 'usr/local/bin/f2format -n /source/' >> /prebuild.sh -RUN chmod +x /prebuild.sh - -RUN echo '/prebuild.sh' >> /build.sh -RUN echo '/usr/bin/fakeroot /usr/bin/dpkg-deb --build /source /output/' >> /build.sh -RUN chmod +x /build.sh - diff --git a/monroe/tap-agent/README.md b/monroe/tap-agent/README.md deleted file mode 100644 index 2aa8333..0000000 --- a/monroe/tap-agent/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# TAP Agent - -This experimental scheduler (with a somewhat misleading name) expose a push based rest API for scheduling and retriving experiment results on a monroe node. -The scheduler/agent listen by default on port 8080 on all interfaces with a self-signed certificate. -To deploy, start, stop and get the experiment results a valid api key is needed, default ```$3cr3t_Pa$$w0rd!``` - -## Howto Build (need to have docker,bash and internet connection) -1. clone and cd into repo directory -2. ```./build.sh``` - -## Howto install -1. Install Debian Stretch and monroe-experiment-core > 0.2.0 (https://github.com/MONROE-PROJECT/monroe-experiment-core) -2. ```apt install ./monroe-tap-agent*.deb``` - -## Endpoints : - -1. /api/v1.0/experiment//start', methods=['POST'] -2. /api/v1.0/experiment//stop', methods=['POST'] -3. /api/v1.0/experiment/, methods=['GET'] -4. /api/v1.0/experiment', methods=['GET'] -5. /api/v1.0/experiment/', methods=['POST'] -6. /api/v1.0/experiment/', methods=['PUT'] -7. /api/v1.0/experiment/', methods=['DELETE'] -8. /api/v1.0/experiment//results', methods=['GET'] - -### Actions -1. Will deploy and start a experiment, eg: - * ```curl --insecure -H 'x-api-key: $3cr3t_Pa$$w0rd!' -d '{ "script": "jonakarl/nodetest"}' -H "Content-Type: application/json" -X POST https://:8080/api/v1.0/experiment/test1/start``` -2. Will stop (ie delete a experiment) and retrive the results (as a zip file), eg: - * ```curl --insecure -H 'x-api-key: $3cr3t_Pa$$w0rd!' -X POST https://:8080/api/v1.0/experiment/test1/stop -o test1.zip``` -3. Will retrive status of a given experiment, eg: - * ```curl https://:8080/api/v1.0/experiment/test1``` - * HTTP_200_OK --- experiment is still running - * HTTP_428_PRECONDITION_REQUIRED --- experiment is deployed but not running (either stopped or has not started yet) - * HTTP_404_NOT_FOUND --- experiment is not deplyed (ie does not exist) -4. Will return currently running and deployed experiments, eg: - * ```curl https://:8080/api/v1.0/experiment``` -5. Deploys a experiment, eg: - * ```curl --insecure -H 'x-api-key: $3cr3t_Pa$$w0rd!' -d '{ "script": "jonakarl/nodetest"}' -H "Content-Type: application/json" -X POST https://:8080/api/v1.0/experiment/test1``` -6. Starts a experiment, eg: - * ```curl --insecure -H 'x-api-key: $3cr3t_Pa$$w0rd!' -X PUT https://:8080/api/v1.0/experiment/test1``` -7. Will stop aka delete a experiment, eg: - * ```curl --insecure -H 'x-api-key: $3cr3t_Pa$$w0rd!' -X DELETE https://:8080/api/v1.0/experiment/test1``` -8. Will sync and retrive the current results of a experiment (as a zip file), eg: - * ```curl --insecure -H 'x-api-key: $3cr3t_Pa$$w0rd!' https://:8080/api/v1.0/experiment/test1/results -o test1.zip``` diff --git a/monroe/tap-agent/Vagrantfile b/monroe/tap-agent/Vagrantfile deleted file mode 100644 index e3868cd..0000000 --- a/monroe/tap-agent/Vagrantfile +++ /dev/null @@ -1,79 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# Builds monroe-experiment-core from the repository. -# Builds the monroe-tap-agent files either from this folder or from the repository. -# -# IMPORTANT: Both options are DISABLED by default, uncomment one of the lines below -# (after [TAP AGENT]) to select which version to install - -$build_from_local = <