Skip to content
Snippets Groups Projects
Commit b57ab5c6 authored by Alfonso Tierno's avatar Alfonso Tierno
Browse files

Merge 'master' into v7.0 for v7.1.0


Change-Id: Icf8af24c306a5714dbbaa2d71a06cf6f0fd0ca91
Signed-off-by: default avatartierno <alfonso.tiernosepulveda@telefonica.com>
parents 9256900f df6f9b1c
No related branches found
No related tags found
No related merge requests found
Showing
with 2754 additions and 13 deletions
......@@ -27,19 +27,17 @@ RUN apt-get update && apt-get install -y git python3 python3-pip \
# This is not needed, because package dependency will install anyway.
# But done here in order to harry up image generation using cache
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python3-neutronclient python3-openstackclient \
python3-requests python3-netaddr python3-argcomplete
python3-requests python3-netaddr python3-argcomplete \
&& DEBIAN_FRONTEND=noninteractive python3 -m pip install -U jsonrpclib-pelix cvprac \
"osm-im @ git+https://osm.etsi.org/gerrit/osm/IM.git#egg=osm-im" "azure==4.0.0" boto "fog05rest>=0.0.4" \
untangle pyone "oca @ git+https://github.com/python-oca/python-oca#egg=oca"
# DEBIAN_FRONTEND=noninteractive apt-get -y install python-openstacksdk python-openstackclient && \
# TODO py3 DEBIAN_FRONTEND=noninteractive add-apt-repository -y cloud-archive:rocky && apt-get update && apt-get install -y python3-networking-l2gw \
# DEBIAN_FRONTEND=noninteractive apt-get -y install python-cffi libssl-dev libffi-dev python-mysqldb && \
# DEBIAN_FRONTEND=noninteractive pip2 install -U azure && \
# DEBIAN_FRONTEND=noninteractive pip2 install -U fog05rest && \
# && DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common && \
# DEBIAN_FRONTEND=noninteractive apt-get -y install wget tox && \
# DEBIAN_FRONTEND=noninteractive pip2 install untangle && \
# DEBIAN_FRONTEND=noninteractive pip2 install pyone && \
# DEBIAN_FRONTEND=noninteractive pip2 install -e git+https://github.com/python-oca/python-oca#egg=oca && \
COPY . /root/RO
......@@ -57,7 +55,9 @@ RUN /root/RO/RO/osm_ro/scripts/install-osm-im.sh --develop && \
python3 -m pip install -e /root/RO/RO-SDN-tapi && \
python3 -m pip install -e /root/RO/RO-SDN-onos_vpls && \
python3 -m pip install -e /root/RO/RO-SDN-onos_openflow && \
python3 -m pip install -e /root/RO/RO-SDN-odl_openflow && \
python3 -m pip install -e /root/RO/RO-SDN-floodlight_openflow && \
python3 -m pip install -e /root/RO/RO-SDN-arista && \
rm -rf /root/.cache && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
......
......@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright Copyright 2019 ETSI
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......
##
# 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.
##
all: clean package
clean:
rm -rf dist deb_dist osm_rosdn_arista-*.tar.gz osm_rosdn_arista.egg-info .eggs
package:
python3 setup.py --command-packages=stdeb.command sdist_dsc
cp debian/python3-osm-rosdn-arista.postinst deb_dist/osm-rosdn-arista*/debian/
cd deb_dist/osm-rosdn-arista*/ && dpkg-buildpackage -rfakeroot -uc -us
#!/bin/bash
##
# 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.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact with: OSM_TECH@list.etsi.org
##
echo "POST INSTALL OSM-ROSDN-ARISTA"
#Pip packages required for openstack connector
python3 -m pip install cvprac
# -*- coding: utf-8 -*-
##
# Copyright 2019 Atos - CoE Telco NFV Team
# All Rights Reserved.
#
# Contributors: Oscar Luis Peral, Atos
#
# 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.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact with: <oscarluis.peral@atos.net>
#
# Neither the name of Atos 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 context of Arista Telefonica OSM PoC.
##
class AristaSDNConfigLet:
_configLet_SRIOV = """
interface {interface}
!! service: {uuid}
switchport
switchport mode trunk
switchport trunk group {service}{vlan_id}
!
"""
def _get_sriov(self, uuid, interface, vlan_id, s_type, index):
return self._configLet_SRIOV.format(uuid=uuid, interface=interface, service=s_type, vlan_id=vlan_id)
def getElan_sriov(self, uuid, interface, vlan_id, index):
return self._get_sriov(uuid, interface, vlan_id, "ELAN", index)
def getEline_sriov(self, uuid, interface, vlan_id, index):
return self._get_sriov(uuid, interface, vlan_id, "ELINE", index)
_configLet_PASSTROUGH = """
interface {interface}
!! service: {uuid}
switchport
switchport mode dot1q-tunnel
switchport access vlan {vlan_id}
!
"""
def _get_passthrough(self, uuid, interface, vlan_id, s_type, index):
return self._configLet_PASSTROUGH.format(uuid=uuid, interface=interface, vlan_id=vlan_id)
def getElan_passthrough(self, uuid, interface, vlan_id, index):
return self._get_passthrough(uuid, interface, vlan_id, "ELAN", index)
def getEline_passthrough(self, uuid, interface, vlan_id, index):
return self._get_passthrough(uuid, interface, vlan_id, "ELINE", index)
_configLet_VLAN = """
vlan {vlan}
!! service: {service} {vlan} {uuid}
name {service}{vlan}
trunk group {service}{vlan}
trunk group MLAGPEER
interface VXLAN1
VXLAN vlan {vlan} vni {vni}
!
"""
def _get_vlan(self, uuid, vlan_id, vni_id, s_type):
return self._configLet_VLAN.format(service=s_type, vlan=vlan_id, uuid=uuid, vni=vni_id)
def getElan_vlan(self, uuid, vlan_id, vni_id):
return self._get_vlan(uuid, vlan_id, vni_id, "ELAN")
def getEline_vlan(self, uuid, vlan_id, vni_id):
return self._get_vlan(uuid, vlan_id, vni_id, "ELINE")
_configLet_BGP = """
router bgp {bgp}
vlan {vlan}
!! service: {uuid}
rd {loopback}:{vni}
route-target both {vni}:{vni}
redistribute learned
!
"""
def _get_bgp(self, uuid, vlan_id, vni_id, loopback0, bgp, s_type):
return self._configLet_BGP.format(uuid=uuid, bgp=bgp, vlan=vlan_id, loopback=loopback0, vni=vni_id)
def getElan_bgp(self, uuid, vlan_id, vni_id, loopback0, bgp):
return self._get_bgp(uuid, vlan_id, vni_id, loopback0, bgp, "ELAN")
def getEline_bgp(self, uuid, vlan_id, vni_id, loopback0, bgp):
return self._get_bgp(uuid, vlan_id, vni_id, loopback0, bgp, "ELINE")
# -*- coding: utf-8 -*-
##
# Copyright 2019 Atos - CoE Telco NFV Team
# All Rights Reserved.
#
# Contributors: Oscar Luis Peral, Atos
#
# 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.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact with: <oscarluis.peral@atos.net>
#
# Neither the name of Atos 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 context of Arista Telefonica OSM PoC.
##
from jsonrpclib import Server
import socket
import ssl
class AristaSwitch():
"""
Used to run switch commands through eAPI and check command output
"""
def __init__(self, name=None, host=None, user=None, passwd=None,
verify_ssl=False, unix_socket=None,
logger=None):
self.host = host
self.user = user
self.passwd = passwd
self.unix_socket = unix_socket
self.local_ep = Server(unix_socket) \
if unix_socket is not None else None
s = "https://{user}:{passwd}@{host}/command-api"
self.url = s.format(user=user, passwd=passwd, host=host)
self.ep = Server(self.url)
self.verify_ssl = verify_ssl
if not self.verify_ssl:
try:
ssl._create_default_https_context = ssl.\
_create_unverified_context
except AttributeError:
# Old python versions do not verify certs by default
pass
self.log = logger
def _multilinestr_to_list(self, multilinestr=None):
"""
Returns a list, each item been one line of a (multi)line string
Handy for running multiple lines commands through one API call
"""
mylist = \
[x.strip() for x in multilinestr.split('\n') if x.strip() != '']
return mylist
def run(self, cmds=None, timeout=10, local_run=False):
"""
Runs commands through eAPI
If local_run is True eAPI call will be done using local unix socket
If local run is False eAPI call will be done using TCPIP
"""
socket.setdefaulttimeout(timeout)
r = None
if type(cmds) is str:
run_list = self._multilinestr_to_list(cmds)
if type(cmds) is list:
run_list = cmds
if local_run:
ep = self.local_ep
ep_log = "local unix socket {}".format(str(self.unix_socket))
else:
ep = self.ep
ep_log = "tcpip socket {}".format(str(self.host))
self.log.debug("Calling eAPI at {} with commands {}".
format(ep_log, str(run_list)))
try:
r = ep.runCmds(1, run_list)
except Exception as e:
self.log.error(str(e))
raise(e)
return r
# -*- coding: utf-8 -*-
##
# Copyright 2019 Atos - CoE Telco NFV Team
# All Rights Reserved.
#
# Contributors: Oscar Luis Peral, Atos
#
# 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.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact with: <oscarluis.peral@atos.net>
#
# Neither the name of Atos 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 context of Arista Telefonica OSM PoC.
##
import time
class AristaCVPTask:
def __init__(self, cvpClientApi):
self.cvpClientApi = cvpClientApi
def __get_id(self, task):
return task.get("workOrderId")
def __get_state(self, task):
return task.get("workOrderUserDefinedStatus")
def __execute_task(self, task_id):
return self.cvpClientApi.execute_task(task_id)
def __cancel_task(self, task_id):
return self.cvpClientApi.cancel_task(task_id)
def __apply_state(self, task, state):
t_id = self.__get_id(task)
self.cvpClientApi.add_note_to_task(t_id, "Executed by OSM")
if state == "executed":
return self.__execute_task(t_id)
elif state == "cancelled":
return self.__cancel_task(t_id)
def __actionable(self, state):
return state in ["Pending"]
def __terminal(self, state):
return state in ["Completed", "Cancelled"]
def __state_is_different(self, task, target):
return self.__get_state(task) != target
def update_all_tasks(self, data):
new_data = dict()
for task_id in data.keys():
res = self.cvpClientApi.get_task_by_id(task_id)
new_data[task_id] = res
return new_data
def get_pending_tasks(self):
return self.cvpClientApi.get_tasks_by_status('Pending')
def get_pending_tasks_old(self):
taskList = []
tasksField = {'workOrderId': 'workOrderId',
'workOrderState': 'workOrderState',
'currentTaskName': 'currentTaskName',
'description': 'description',
'workOrderUserDefinedStatus':
'workOrderUserDefinedStatus',
'note': 'note',
'taskStatus': 'taskStatus',
'workOrderDetails': 'workOrderDetails'}
tasks = self.cvpClientApi.get_tasks_by_status('Pending')
# Reduce task data to required fields
for task in tasks:
taskFacts = {}
for field in task.keys():
if field in tasksField:
taskFacts[tasksField[field]] = task[field]
taskList.append(taskFacts)
return taskList
def task_action(self, tasks, wait, state):
changed = False
data = dict()
warnings = list()
at = [t for t in tasks if self.__actionable(self.__get_state(t))]
actionable_tasks = at
if len(actionable_tasks) == 0:
warnings.append("No actionable tasks found on CVP")
return changed, data, warnings
for task in actionable_tasks:
if self.__state_is_different(task, state):
self.__apply_state(task, state)
changed = True
data[self.__get_id(task)] = task
if wait == 0:
return changed, data, warnings
start = time.time()
now = time.time()
while (now - start) < wait:
data = self.update_all_tasks(data)
if all([self.__terminal(self.__get_state(t)) for t in data.values()]):
break
time.sleep(1)
now = time.time()
if wait:
for i, task in data.items():
if not self.__terminal(self.__get_state(task)):
warnings.append("Task {} has not completed in {} seconds".
format(i, wait))
return changed, data, warnings
This diff is collapsed.
##
# 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.
##
requests
jsonrpclib-pelix
uuid
cvprac
git+https://osm.etsi.org/gerrit/osm/RO.git#egg=osm-ro
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
##
# 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.
##
from setuptools import setup
_name = "osm_rosdn_arista"
README = """
===========
osm-rosdn_arista
===========
osm-ro pluging for arista SDN
"""
setup(
name=_name,
description='OSM ro sdn plugin for arista',
long_description=README,
version_command=('git describe --match v* --tags --long --dirty', 'pep440-git-full'),
# version=VERSION,
# python_requires='>3.5.0',
author='ETSI OSM',
# TODO py3 author_email='',
maintainer='oscarluis.peral@atos.net', # TODO py3
# TODO py3 maintainer_email='',
url='https://osm.etsi.org/gitweb/?p=osm/RO.git;a=summary',
license='Apache 2.0',
packages=[_name],
include_package_data=True,
install_requires=["requests",
"uuid",
"jsonrpclib-pelix",
"cvprac",
"osm-ro @ git+https://osm.etsi.org/gerrit/osm/RO.git#egg=osm-ro&subdirectory=RO"],
setup_requires=['setuptools-version-command'],
entry_points={
'osm_rosdn.plugins': ['rosdn_arista = osm_rosdn_arista.wimconn_arista:AristaSdnConnector']
},
)
#
# 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.
#
[DEFAULT]
X-Python3-Version : >= 3.5
Depends3: python3-requests, python3-osm-ro, python3-jsonrpclib-pelix
##
# 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.
##
[tox]
envlist = py3
toxworkdir={homedir}/.tox
[testenv]
basepython = python3
install_command = python3 -m pip install -r requirements.txt -U {opts} {packages}
# deps = -r{toxinidir}/test-requirements.txt
commands=python3 -m unittest discover -v
[testenv:flake8]
basepython = python3
deps = flake8
commands = flake8 osm_rosdn_arista --max-line-length 120 \
--exclude .svn,CVS,.gz,.git,__pycache__,.tox,local,temp --ignore W291,W293,E226,W504
[testenv:unittest]
basepython = python3
commands = python3 -m unittest osm_rosdn_arista.tests
[testenv:build]
basepython = python3
deps = stdeb
setuptools-version-command
commands = python3 setup.py --command-packages=stdeb.command bdist_deb
......@@ -14,5 +14,5 @@
##
requests
git+https://osm.etsi.org/gerrit/osm/RO.git#egg=osm-ro
git+https://osm.etsi.org/gerrit/osm/RO.git#egg=osm-ro&subdirectory=RO
......@@ -44,8 +44,10 @@ setup(
packages=[_name],
include_package_data=True,
dependency_links=["git+https://osm.etsi.org/gerrit/osm/RO.git#egg=osm-ro"],
install_requires=["requests", "osm-ro"],
install_requires=[
"requests",
"osm-ro @ git+https://osm.etsi.org/gerrit/osm/RO.git#egg=osm-ro&subdirectory=RO"
],
setup_requires=['setuptools-version-command'],
entry_points={
'osm_rosdn.plugins': ['rosdn_dynpac = osm_rosdn_dynpac.wimconn_dynpac:DynpacConnector'],
......
......@@ -33,7 +33,7 @@ class SdnConnectorFloodLightOf(SdnConnectorOpenFlow):
super().__init__(wim, wim_account, config, logger)
of_params = {
"of_url": wim["wim_url"],
"of_dpid": config.get("dpid"),
"of_dpid": config.get("dpid") or config.get("switch_id"),
"of_user": wim_account["user"],
"of_password": wim_account["password"],
}
......
......@@ -44,8 +44,10 @@ setup(
packages=[_name],
include_package_data=True,
dependency_links=["git+https://osm.etsi.org/gerrit/osm/RO.git#egg=osm-ro"],
install_requires=["requests", "osm-ro"],
install_requires=[
"requests",
"osm-ro @ git+https://osm.etsi.org/gerrit/osm/RO.git#egg=osm-ro&subdirectory=RO"
],
setup_requires=['setuptools-version-command'],
entry_points={
'osm_rosdn.plugins': ['rosdn_floodlightof = osm_rosdn_floodlightof.sdnconn_floodlightof:'
......
##
# 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.
##
all: clean package
clean:
rm -rf dist deb_dist osm_rosdn_odlof-*.tar.gz osm_rosdn_odlof.egg-info .eggs
package:
python3 setup.py --command-packages=stdeb.command sdist_dsc
cd deb_dist/osm-rosdn-odlof*/ && dpkg-buildpackage -rfakeroot -uc -us
This diff is collapsed.
##
# Copyright 2019 Telefonica Investigacion y Desarrollo, S.A.U.
# 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.
#
##
"""The SdnConnectorOdlOf connector is responsible for creating services using pro active operflow rules.
"""
import logging
from osm_ro.wim.openflow_conn import SdnConnectorOpenFlow
from .odl_of import OfConnOdl
class SdnConnectorOdlOf(SdnConnectorOpenFlow):
def __init__(self, wim, wim_account, config=None, logger=None):
"""Creates a connectivity based on pro-active openflow rules
"""
self.logger = logging.getLogger('openmano.sdnconn.odlof')
super().__init__(wim, wim_account, config, logger)
of_params = {
"of_url": wim["wim_url"],
"of_dpid": config.get("dpid") or config.get("switch_id"),
"of_user": wim_account["user"],
"of_password": wim_account["password"],
}
self.openflow_conn = OfConnOdl(of_params)
super().__init__(wim, wim_account, config, logger, self.openflow_conn)
##
# 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.
##
requests
git+https://osm.etsi.org/gerrit/osm/RO.git#egg=osm-ro&subdirectory=RO
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment