Refactoring: Made complete codebase PEP8 compatible.
Only PEP8 rule E501 (line too long) is not yet reflected
by this change.
The patch also adds automated code style checks to the
CI test stage using flake8.
It will let the tests fail if there is a code style
violation.
Change-Id: I90956dd424a46691546ef720351757d3c43451a7
Signed-off-by: peusterm <manuel.peuster@uni-paderborn.de>
diff --git a/src/emuvim/cli/__init__.py b/src/emuvim/cli/__init__.py
index dba0b3c..d888119 100755
--- a/src/emuvim/cli/__init__.py
+++ b/src/emuvim/cli/__init__.py
@@ -1,27 +1,25 @@
-"""
-Copyright (c) 2015 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
diff --git a/src/emuvim/cli/prometheus.py b/src/emuvim/cli/prometheus.py
index 58969d1..82fa5bd 100755
--- a/src/emuvim/cli/prometheus.py
+++ b/src/emuvim/cli/prometheus.py
@@ -1,38 +1,35 @@
-"""
-Copyright (c) 2015 SONATA-NFV
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
-
-
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import requests
# set this to localhost for now
# this is correct for son-emu started outside of a container or as a container with net=host
-#TODO if prometheus sdk DB is started outside of emulator, place these globals in an external SDK config file?
+# TODO if prometheus sdk DB is started outside of emulator, place these
+# globals in an external SDK config file?
prometheus_ip = 'localhost'
# when sdk is started with docker-compose, we could use
# prometheus_ip = 'prometheus'
@@ -49,8 +46,8 @@
# logging.info('return:{0}'.format(ret))
try:
ret = ret['data']['result'][0]['value']
- except:
+ except BaseException:
ret = None
else:
ret = None
- return ret
\ No newline at end of file
+ return ret
diff --git a/src/emuvim/cli/rest/__init__.py b/src/emuvim/cli/rest/__init__.py
index dba0b3c..d888119 100755
--- a/src/emuvim/cli/rest/__init__.py
+++ b/src/emuvim/cli/rest/__init__.py
@@ -1,27 +1,25 @@
-"""
-Copyright (c) 2015 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
diff --git a/src/emuvim/cli/rest/compute.py b/src/emuvim/cli/rest/compute.py
index fdfc11b..5abaa28 100755
--- a/src/emuvim/cli/rest/compute.py
+++ b/src/emuvim/cli/rest/compute.py
@@ -1,35 +1,32 @@
-"""
-Copyright (c) 2015 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from requests import get, put, delete
from tabulate import tabulate
import pprint
import argparse
-import json
from subprocess import Popen
pp = pprint.PrettyPrinter(indent=4)
@@ -70,7 +67,8 @@
def list(self, args):
- list = get('%s/restapi/compute/%s' % (args.get("endpoint"), args.get('datacenter'))).json()
+ list = get('%s/restapi/compute/%s' %
+ (args.get("endpoint"), args.get('datacenter'))).json()
table = []
for c in list:
@@ -78,15 +76,17 @@
if len(c) > 1:
name = c[0]
status = c[1]
- #eth0ip = status.get("docker_network", "-")
- netw_list = [netw_dict['intf_name'] for netw_dict in status.get("network")]
- dc_if_list = [netw_dict['dc_portname'] for netw_dict in status.get("network")]
+ # eth0ip = status.get("docker_network", "-")
+ netw_list = [netw_dict['intf_name']
+ for netw_dict in status.get("network")]
+ dc_if_list = [netw_dict['dc_portname']
+ for netw_dict in status.get("network")]
table.append([status.get("datacenter"),
name,
status.get("image"),
','.join(netw_list),
','.join(dc_if_list)])
- #status.get("state").get("Status")]
+ # status.get("state").get("Status")]
headers = ["Datacenter",
"Container",
@@ -110,8 +110,9 @@
Popen(['xterm', '-xrm', 'XTerm.vt100.allowTitleOps: false', '-T', vnf_name,
'-e', "docker exec -it mn.{0} /bin/bash".format(vnf_name)])
+
parser = argparse.ArgumentParser(description="""son-emu-cli compute
-
+
Examples:
- son-emu-cli compute start -d dc2 -n client -i sonatanfv/sonata-iperf3-vnf
- son-emu-cli list
diff --git a/src/emuvim/cli/rest/datacenter.py b/src/emuvim/cli/rest/datacenter.py
index 651c55c..f4f92c3 100755
--- a/src/emuvim/cli/rest/datacenter.py
+++ b/src/emuvim/cli/rest/datacenter.py
@@ -1,30 +1,28 @@
-"""
-Copyright (c) 2015 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
from requests import get
from tabulate import tabulate
import pprint
@@ -32,6 +30,7 @@
pp = pprint.PrettyPrinter(indent=4)
+
class RestApiClient():
def __init__(self):
@@ -44,40 +43,41 @@
else:
print("Command not implemented.")
- def list(self,args):
+ def list(self, args):
list = get('%s/restapi/datacenter' % args.get('endpoint')).json()
table = []
for d in list:
# for each dc add a line to the output table
if len(d) > 0:
table.append([d.get("label"),
- d.get("internalname"),
- d.get("switch"),
- d.get("n_running_containers"),
- len(d.get("metadata"))])
+ d.get("internalname"),
+ d.get("switch"),
+ d.get("n_running_containers"),
+ len(d.get("metadata"))])
headers = ["Label",
- "Internal Name",
- "Switch",
- "# Containers",
- "# Metadata Items"]
- print (tabulate(table, headers=headers, tablefmt="grid"))
+ "Internal Name",
+ "Switch",
+ "# Containers",
+ "# Metadata Items"]
+ print(tabulate(table, headers=headers, tablefmt="grid"))
- def status(self,args):
- list = get('%s/restapi/datacenter/%s' % ( args.get("endpoint"), args.get("datacenter"))).json()
+ def status(self, args):
+ list = get('%s/restapi/datacenter/%s' %
+ (args.get("endpoint"), args.get("datacenter"))).json()
table = []
table.append([list.get('label'),
- list.get('internalname'),
- list.get('switch'),
- list.get('n_running_containers'),
- len(list.get('metadata'))])
+ list.get('internalname'),
+ list.get('switch'),
+ list.get('n_running_containers'),
+ len(list.get('metadata'))])
headers = ["Label",
- "Internal Name",
- "Switch",
- "# Containers",
- "# Metadata Items"]
+ "Internal Name",
+ "Switch",
+ "# Containers",
+ "# Metadata Items"]
- print (tabulate(table, headers=headers, tablefmt="grid"))
+ print(tabulate(table, headers=headers, tablefmt="grid"))
parser = argparse.ArgumentParser(description='son-emu-cli datacenter')
@@ -98,4 +98,3 @@
args = vars(parser.parse_args(argv))
c = RestApiClient()
c.execute_command(args)
-
diff --git a/src/emuvim/cli/rest/monitor.py b/src/emuvim/cli/rest/monitor.py
index 8be1e7f..3787887 100755
--- a/src/emuvim/cli/rest/monitor.py
+++ b/src/emuvim/cli/rest/monitor.py
@@ -1,38 +1,36 @@
-"""
-Copyright (c) 2015 SONATA-NFV
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
-
-from requests import get, put, delete
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
+from requests import get, put
import pprint
import argparse
from emuvim.cli import prometheus
pp = pprint.PrettyPrinter(indent=4)
+
class RestApiClient():
def __init__(self):
@@ -49,8 +47,8 @@
params = self._create_dict(
vnf_name=self._parse_vnf_name(args.get("vnf_name")),
- vnf_interface = self._parse_vnf_interface(args.get("vnf_name")),
- metric = args.get("metric"))
+ vnf_interface=self._parse_vnf_interface(args.get("vnf_name")),
+ metric=args.get("metric"))
url = "{0}/restapi/monitor/interface".format(args.get("endpoint"))
response = put(url, params=params)
@@ -92,14 +90,12 @@
# This functions makes it more user-friendly to create the correct prometheus query
# <uuid> is replaced by the correct uuid of the deployed vnf container
vnf_name = self._parse_vnf_name(args.get("vnf_name"))
- vnf_interface = self._parse_vnf_interface(args.get("vnf_name"))
- dc_label = args.get("datacenter")
query = args.get("query")
vnf_status = get("%s/restapi/compute/%s/%s" %
- (args.get("endpoint"),
- args.get("datacenter"),
- vnf_name)).json()
+ (args.get("endpoint"),
+ args.get("datacenter"),
+ vnf_name)).json()
uuid = vnf_status['id']
query = query.replace('<uuid>', uuid)
@@ -113,7 +109,7 @@
def _parse_vnf_interface(self, vnf_name_str):
try:
vnf_interface = vnf_name_str.split(':')[1]
- except:
+ except BaseException:
vnf_interface = None
return vnf_interface
@@ -121,10 +117,12 @@
def _create_dict(self, **kwargs):
return kwargs
+
parser = argparse.ArgumentParser(description='son-emu-cli monitor')
parser.add_argument(
"command",
- choices=['setup_metric', 'stop_metric', 'setup_flow', 'stop_flow','prometheus'],
+ choices=['setup_metric', 'stop_metric',
+ 'setup_flow', 'stop_flow', 'prometheus'],
help="setup/stop a metric/flow to be monitored or query Prometheus")
parser.add_argument(
"--vnf_name", "-vnf", dest="vnf_name",
@@ -146,7 +144,8 @@
default="http://127.0.0.1:5001",
help="REST API endpoint of son-emu (default:http://127.0.0.1:5001)")
+
def main(argv):
args = vars(parser.parse_args(argv))
c = RestApiClient()
- c.execute_command(args)
\ No newline at end of file
+ c.execute_command(args)
diff --git a/src/emuvim/cli/rest/network.py b/src/emuvim/cli/rest/network.py
index 82fe99f..7566f44 100755
--- a/src/emuvim/cli/rest/network.py
+++ b/src/emuvim/cli/rest/network.py
@@ -1,31 +1,29 @@
-"""
-Copyright (c) 2015 SONATA-NFV
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
-from requests import get,put, delete
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
+from requests import put, delete
import argparse
@@ -44,9 +42,10 @@
def add(self, args):
params = self._create_dict(
vnf_src_name=self._parse_vnf_name(args.get("source")),
- vnf_dst_name = self._parse_vnf_name(args.get("destination")),
+ vnf_dst_name=self._parse_vnf_name(args.get("destination")),
vnf_src_interface=self._parse_vnf_interface(args.get("source")),
- vnf_dst_interface=self._parse_vnf_interface(args.get("destination")),
+ vnf_dst_interface=self._parse_vnf_interface(
+ args.get("destination")),
weight=args.get("weight"),
match=args.get("match"),
bidirectional=args.get("bidirectional"),
@@ -59,10 +58,11 @@
def remove(self, args):
params = self._create_dict(
- vnf_src_name = self._parse_vnf_name(args.get("source")),
- vnf_dst_name = self._parse_vnf_name(args.get("destination")),
+ vnf_src_name=self._parse_vnf_name(args.get("source")),
+ vnf_dst_name=self._parse_vnf_name(args.get("destination")),
vnf_src_interface=self._parse_vnf_interface(args.get("source")),
- vnf_dst_interface=self._parse_vnf_interface(args.get("destination")),
+ vnf_dst_interface=self._parse_vnf_interface(
+ args.get("destination")),
weight=args.get("weight"),
match=args.get("match"),
bidirectional=args.get("bidirectional"),
@@ -80,7 +80,7 @@
def _parse_vnf_interface(self, vnf_name_str):
try:
vnf_interface = vnf_name_str.split(':')[1]
- except:
+ except BaseException:
vnf_interface = None
return vnf_interface
@@ -89,11 +89,13 @@
return kwargs
def _nice_print(self, text):
- # some modules seem to return unicode strings where newlines, other special characters are escaped
+ # some modules seem to return unicode strings where newlines, other
+ # special characters are escaped
text = str(text).replace('\\n', '\n')
text = str(text).replace('\\"', '"')
return text
+
parser = argparse.ArgumentParser(description='son-emu-cli network')
parser.add_argument(
"command",
@@ -128,6 +130,7 @@
default="http://127.0.0.1:5001",
help="REST API endpoint of son-emu (default:http://127.0.0.1:5001)")
+
def main(argv):
args = vars(parser.parse_args(argv))
c = RestApiClient()
diff --git a/src/emuvim/cli/son_emu_cli.py b/src/emuvim/cli/son_emu_cli.py
index 0223818..801c60b 100755
--- a/src/emuvim/cli/son_emu_cli.py
+++ b/src/emuvim/cli/son_emu_cli.py
@@ -1,48 +1,36 @@
#!/usr/bin/python
-"""
-Copyright (c) 2015 SONATA-NFV and Paderborn University
-ALL RIGHTS RESERVED.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
-nor the names of its contributors may be used to endorse or promote
-products derived from this software without specific prior written
-permission.
-
-This work has been performed in the framework of the SONATA project,
-funded by the European Commission under Grant number 671517 through
-the Horizon 2020 and 5G-PPP programmes. The authors would like to
-acknowledge the contributions of their colleagues of the SONATA
-partner consortium (www.sonata-nfv.eu).
-"""
-"""
- Simple CLI client to interact with a running emulator.
-
- The CLI offers different tools, e.g., compute, network, ...
- Each of these tools is implemented as an independent Python
- module.
-
- cli compute start dc1 my_name flavor_a
- cli network create dc1 11.0.0.0/24
-"""
-
+# Copyright (c) 2015 SONATA-NFV and Paderborn University
+# ALL RIGHTS RESERVED.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Neither the name of the SONATA-NFV, Paderborn University
+# nor the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# This work has been performed in the framework of the SONATA project,
+# funded by the European Commission under Grant number 671517 through
+# the Horizon 2020 and 5G-PPP programmes. The authors would like to
+# acknowledge the contributions of their colleagues of the SONATA
+# partner consortium (www.sonata-nfv.eu).
import sys
from emuvim.cli.rest import compute as restcom
from emuvim.cli.rest import datacenter as restdc
from emuvim.cli.rest import monitor as restmon
from emuvim.cli.rest import network as restnetw
+
def help():
print("Missing arguments.\n")
print("Usage: son-emu-cli compute|datacenter|network|monitor <arguments>\n")
@@ -53,6 +41,7 @@
print("\tson-emu-cli monitor --help")
exit(0)
+
def main():
if len(sys.argv) < 2:
help()