mise a jour

This commit is contained in:
Abdel-Kader Chabi-Sika-Boni 2021-01-01 01:35:59 +01:00
parent dc5e27d665
commit 5badaa6284
14 changed files with 204 additions and 189 deletions

View file

@ -1,33 +1,71 @@
#!/usr/bin/python
'''In our topology, we assume the container running this script has ip address 10.10.10.10/24
'''In our topology, we assume the container running this script has ip address 10.10.10.10
(useful information according to our topology: useless otherwise)
'''
from flask import Flask
app = Flask(__name__)
SVR_IP = ''
GWI1_IP = ''
GWI2_IP = ''
GWF1_IP = ''
DEV1_GWF1_IP = ''
DEV2_GWF1_IP = ''
DEV3_GWF1_IP = ''
GWF2_IP = ''
DEV1_GWF2_IP = ''
DEV2_GWF2_IP = ''
DEV3_GWF2_IP = ''
GWF3_IP = ''
DEV1_GWF3_IP = ''
DEV2_GWF3_IP = ''
DEV3_GWF3_IP = ''
SVR_IP = '192.168.0.1' #name = srv
GWI1_IP = '10.0.1.1' #name = gwi1
GWI2_IP = '10.0.1.2' #name = gwi2
GWF1_IP = '10.0.0.1' #name = gwf1
DEV1_GWF1_IP = '192.168.1.1' #name = dev1gwf1
DEV2_GWF1_IP = '192.168.1.2' #name = dev2gwf1
DEV3_GWF1_IP = '192.168.1.3' #name = dev3gwf1
GWF2_IP = '10.0.0.2' #name = gwf2
DEV1_GWF2_IP = '192.168.2.1' #name = dev1gwf2
DEV2_GWF2_IP = '192.168.2.2' #name = dev2gwf2
DEV3_GWF2_IP = '192.168.2.3' #name = dev3gwf2
GWF3_IP = '10.0.0.3' #name = gwf3
DEV1_GWF3_IP = '192.168.3.1' #name = dev1gwf3
DEV2_GWF3_IP = '192.168.3.2' #name = dev2gwf3
DEV3_GWF3_IP = '192.168.3.3' #name = dev3gwf3
#Formats of configs:
SERVER = "--local_ip 127.0.0.1 --local_port 8080 --local_name %s"
GATEWAY_I = "--local_ip 127.0.0.1 --local_port 8181 --local_name %s --remote_ip %s --remote_port 8080 --remote_name %s"
GATEWAY_F = "--local_ip 127.0.0.1 --local_port 8282 --local_name %s --remote_ip %s --remote_port 8181 --remote_name %s"
DEV = "--local_ip 127.0.0.1 --local_port 9001 --local_name %s --remote_ip %s --remote_port 8282 --remote_name %s --send_period 3000"
@app.route("/getmyconfig/<string:my_ip>")
def configurations_giver(my_ip):
configs = ""
if my_ip=='10.0.0.3':
configs = '--local_name xxx --remote_ip xxx --remote_name xxx'
if my_ip==SVR_IP:
configs = SERVER%('srv')
elif my_ip==GWI1_IP:
configs = GATEWAY_I%('gwi1',SVR_IP,'srv')
elif my_ip==GWI2_IP:
configs = GATEWAY_I%('gwi2',SVR_IP,'srv')
elif my_ip==GWF1_IP:
configs = GATEWAY_F%('gwf1',GWI1_IP,'gwi1')
elif my_ip==GWF2_IP:
configs = GATEWAY_F%('gwf2',GWI1_IP,'gwi1')
elif my_ip==GWF3_IP:
configs = GATEWAY_F%('gwf3',GWI1_IP,'gwi1')
elif my_ip==DEV1_GWF1_IP:
configs = DEV%('dev1gwf1',GWF1_IP,'gwf1')
elif my_ip==DEV2_GWF1_IP:
configs = DEV%('dev2gwf1',GWF1_IP,'gwf1')
elif my_ip==DEV3_GWF1_IP:
configs = DEV%('dev3gwf1',GWF1_IP,'gwf1')
elif my_ip==DEV1_GWF2_IP:
configs = DEV%('dev1gwf2',GWF2_IP,'gwf2')
elif my_ip==DEV2_GWF2_IP:
configs = DEV%('dev2gwf2',GWF2_IP,'gwf2')
elif my_ip==DEV3_GWF2_IP:
configs = DEV%('dev3gwf2',GWF2_IP,'gwf2')
elif my_ip==DEV1_GWF3_IP:
configs = DEV%('dev1gwf3',GWF3_IP,'gwf3')
elif my_ip==DEV2_GWF3_IP:
configs = DEV%('dev2gwf3',GWF3_IP,'gwf3')
elif my_ip==DEV3_GWF3_IP:
configs = DEV%('dev3gwf3',GWF3_IP,'gwf3')
return configs
if __name__=='__main__':

View file

@ -1,22 +0,0 @@
# Choosing the image to use
FROM node:alpine
# Installing required libraries
RUN apk add npm && \
mkdir device && \
cd device && \
npm install express && \
npm install yargs && \
npm install systeminformation && \
npm install request && \
wget http://homepages.laas.fr/smedjiah/tmp/device.js
# set entry point for emulator gatekeeper (needed for compatibility with vim-emu datacenters)
#ENV VIM_EMU_CMD "node /device/device.js --local_ip "127.0.0.1" --local_port 9001 --local_name "dev1" --remote_ip "127.0.0.1" --remote_port 8282 --remote_name "gwf1" --send_period 3000" #uncomment when on ContainerNet datacenter
#ENV VIM_EMU_CMD "TODO at startup"
#ENV VIM_EMU_CMD_STOP "TODO at shutdown"
# CMD should always point to /bin/bash to not block the emulator (sh for node:alpine)
CMD node /device/device.js --local_ip "127.0.0.1" --local_port 9001 --local_name "dev1" --remote_ip "127.0.0.1" --remote_port 8282 --remote_name "gwf1" --send_period 3000 #comment when on ContainerNet datacenter
#CMD /bin/sh #uncomment when on ContainerNet datacenter

View file

@ -1,24 +0,0 @@
# Choosing the image to use
FROM node:alpine
# Installing required libraries
RUN apk add npm && \
mkdir gateway && \
cd gateway && \
npm install express && \
npm install yargs && \
npm install systeminformation && \
npm install request && \
wget http://homepages.laas.fr/smedjiah/tmp/gateway.js
# set entry point for emulator gatekeeper (needed for compatibility with vim-emu datacenters)
#ENV VIM_EMU_CMD "node /gateway/gateway.js --local_ip "127.0.0.1" --local_port 8282 --local_name "gwf1" --remote_ip "127.0.0.1" --remote_port 8181 --remote_name "gwi"
#uncomment when on ContainerNet datacenter
#ENV VIM_EMU_CMD "TODO at startup"
#ENV VIM_EMU_CMD_STOP "TODO at shutdown"
# CMD should always point to /bin/bash to not block the emulator (sh for node:alpine)
CMD node /gateway/gateway.js --local_ip "127.0.0.1" --local_port 8282 --local_name "gwf1" --remote_ip "127.0.0.1" --remote_port 8181 --remote_name "gwi"
#comment when on ContainerNet datacenter
#CMD /bin/sh #uncomment when on ContainerNet datacenter

View file

@ -1,22 +0,0 @@
# Choosing the image to use
FROM node:alpine
# Installing required libraries
RUN apk add npm && \
mkdir gateway && \
cd gateway && \
npm install express && \
npm install yargs && \
npm install systeminformation && \
npm install request && \
wget http://homepages.laas.fr/smedjiah/tmp/gateway.js
# set entry point for emulator gatekeeper (needed for compatibility with vim-emu datacenters)
#ENV VIM_EMU_CMD "node /gateway/gateway.js --local_ip "127.0.0.1" --local_port 8181 --local_name "gwi" --remote_ip "127.0.0.1" --remote_port 8080 --remote_name "srv" #uncomment when on ContainerNet datacenter
#ENV VIM_EMU_CMD "TODO at startup"
#ENV VIM_EMU_CMD_STOP "TODO at shutdown"
# CMD should always point to /bin/bash to not block the emulator (sh for node:alpine)
CMD node /gateway/gateway.js --local_ip "172.17.0.4" --local_port 8181 --local_name "gwi" --remote_ip "172.17.0.2" --remote_port 8080 --remote_name "srv" #comment when on ContainerNet datacenter
#CMD /bin/sh #uncomment when on ContainerNet datacenter

View file

@ -1,20 +0,0 @@
# Choosing the image to use
FROM node:alpine
# Installing required libraries
RUN apk add npm && \
mkdir server && \
cd server && \
npm install express && \
npm install yargs && \
npm install systeminformation && \
wget http://homepages.laas.fr/smedjiah/tmp/server.js
# set entry point for emulator gatekeeper (needed for compatibility with vim-emu datacenters)
#ENV VIM_EMU_CMD "node /server/server.js --local_ip '127.0.0.1' --local_port '8080' --local_name 'srv'" #uncomment when on ContainerNet datacenter
#ENV VIM_EMU_CMD "TODO at startup"
#ENV VIM_EMU_CMD_STOP "TODO at shutdown"
# CMD should always point to /bin/bash to not block the emulator (sh for node:alpine)
CMD node /server/server.js --local_ip '127.0.0.1' --local_port '8080' --local_name 'srv' #comment when on ContainerNet datacenter
#CMD /bin/sh #uncomment when on ContainerNet datacenter

View file

@ -1,83 +0,0 @@
#!/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, 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 logging
from mininet.log import setLogLevel, info
from emuvim.dcemulator.net import DCNetwork
from emuvim.api.rest.rest_api_endpoint import RestApiEndpoint
from emuvim.api.openstack.openstack_api_endpoint import OpenstackApiEndpoint
logging.basicConfig(level=logging.INFO)
setLogLevel('info') # set Mininet loglevel
logging.getLogger('werkzeug').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.base').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.compute').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.keystone').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.nova').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.neutron').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.heat').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.heat.parser').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.glance').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.helper').setLevel(logging.DEBUG)
def create_topology():
net = DCNetwork(monitor=False, enable_learning=True)
dc1 = net.addDatacenter("dc1")
# add OpenStack-like APIs to the emulated DC
api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
api1.connect_datacenter(dc1)
api1.start()
api1.connect_dc_network(net)
# add the command line interface endpoint to the emulated DC (REST API)
rapi1 = RestApiEndpoint("0.0.0.0", 5001)
rapi1.connectDCNetwork(net)
rapi1.connectDatacenter(dc1)
rapi1.start()
d1 = net.addDocker('srv', ip='10.0.0.3', dimage="server:topo")
d2 = net.addDocker('gwi', ip='10.0.0.6', dimage="server:topo")
info('*** Adding switches\n')
s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
info('*** Creating links\n')
net.addLink(dc1, s1)
net.addLink(d1, s1)
net.addLink(s1, s2)
net.addLink(s2, d2)
info('*** Starting network\n')
net.start()
net.CLI()
# when the user types exit in the CLI, we stop the emulator
net.stop()
def main():
create_topology()
if __name__ == '__main__':
main()

148
topologie/topology.py Executable file
View file

@ -0,0 +1,148 @@
#!/usr/bin/python
# Copyright (c) 2020 INSA Toulouse
# ALL RIGHTS RESERVED.
#
# This topology has been built by inspiring on the 'default_single_dc_topology.py' example of son-emu
#
# Authors
# Abdel Kader CHABI SIKA BONI (Master2 ILoRD at INSA Toulouse, chabisik@etud.insa-toulouse.fr)
# Arnaud PRIEU (5SDBD at INSA Toulouse, prieu@etud.insa-toulouse.fr)
# Year: 2020-2021
import logging
from mininet.log import setLogLevel, info
from emuvim.dcemulator.net import DCNetwork
from emuvim.api.rest.rest_api_endpoint import RestApiEndpoint
from emuvim.api.openstack.openstack_api_endpoint import OpenstackApiEndpoint
logging.basicConfig(level=logging.INFO)
setLogLevel('info') # set Mininet loglevel
logging.getLogger('werkzeug').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.base').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.compute').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.keystone').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.nova').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.neutron').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.heat').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.heat.parser').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.glance').setLevel(logging.DEBUG)
logging.getLogger('api.openstack.helper').setLevel(logging.DEBUG)
#####################################################################################################
# OUR TOPOLOGY'S DETAILS #
# (if changed, bootstrap server script must be changed too and the new config:topo image builded) #
#####################################################################################################
BOOTSTRAP_SERVER = '10.10.10.10' #name = btrap; port = 5555
SVR_IP = '192.168.0.1' #name = srv
GWI1_IP = '10.0.1.1' #name = gwi1
GWI2_IP = '10.0.1.2' #name = gwi2
GWF1_IP = '10.0.0.1' #name = gwf1
DEV1_GWF1_IP = '192.168.1.1' #name = dev1gwf1
DEV2_GWF1_IP = '192.168.1.2' #name = dev2gwf1
DEV3_GWF1_IP = '192.168.1.3' #name = dev3gwf1
GWF2_IP = '10.0.0.2' #name = gwf2
DEV1_GWF2_IP = '192.168.2.1' #name = dev1gwf2
DEV2_GWF2_IP = '192.168.2.2' #name = dev2gwf2
DEV3_GWF2_IP = '192.168.2.3' #name = dev3gwf2
GWF3_IP = '10.0.0.3' #name = gwf3
DEV1_GWF3_IP = '192.168.3.1' #name = dev1gwf3
DEV2_GWF3_IP = '192.168.3.2' #name = dev2gwf3
DEV3_GWF3_IP = '192.168.3.3' #name = dev3gwf3
'''
'''
#####################################################################################################
def create_topology():
net = DCNetwork(monitor=False, enable_learning=True)
dc1 = net.addDatacenter("dc1")
# add OpenStack-like APIs to the emulated DC
api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
api1.connect_datacenter(dc1)
api1.start()
api1.connect_dc_network(net)
# add the command line interface endpoint to the emulated DC (REST API)
rapi1 = RestApiEndpoint("0.0.0.0", 5001)
rapi1.connectDCNetwork(net)
rapi1.connectDatacenter(dc1)
rapi1.start()
info('*** Adding bootstrap server\n')
btrap = net.addDocker('btrap', ip=BOOTSTRAP_SERVER, dimage="config:topo")
info('*** Adding topology server\n')
srv = net.addDocker('srv', ip=SVR_IP, dimage="server:topo", environment={})
info('*** Adding topology intermediary gateway\n')
gwi1 = net.addDocker('gwi1', ip=GWI1_IP, dimage="gateway:topo", environment={'MY_IP':GWI1_IP})
info('*** Adding topology final gateways\n')
gwf1 = net.addDocker('gwf1', ip=GWF1_IP, dimage="gateway:topo", environment={'MY_IP':GWF1_IP})
gwf2 = net.addDocker('gwf2', ip=GWF2_IP, dimage="gateway:topo", environment={'MY_IP':GWF2_IP})
gwf3 = net.addDocker('gwf3', ip=GWF3_IP, dimage="gateway:topo", environment={'MY_IP':GWF3_IP})
info('*** Adding 1st final gateway devices\n')
dev1gwf1 = net.addDocker('dev1gwf1', ip=DEV1_GWF1_IP, dimage="device:topo", environment={'MY_IP':DEV1_GWF1_IP})
dev2gwf1 = net.addDocker('dev2gwf1', ip=DEV2_GWF1_IP, dimage="device:topo", environment={'MY_IP':DEV2_GWF1_IP})
dev3gwf1 = net.addDocker('dev3gwf1', ip=DEV3_GWF1_IP, dimage="device:topo", environment={'MY_IP':DEV3_GWF1_IP})
info('*** Adding 2nd final gateway devices\n')
dev1gwf2 = net.addDocker('dev1gwf2', ip=DEV1_GWF2_IP, dimage="device:topo", environment={'MY_IP':DEV1_GWF2_IP})
dev2gwf2 = net.addDocker('dev2gwf2', ip=DEV2_GWF2_IP, dimage="device:topo", environment={'MY_IP':DEV2_GWF2_IP})
dev3gwf2 = net.addDocker('dev3gwf2', ip=DEV3_GWF2_IP, dimage="device:topo", environment={'MY_IP':DEV3_GWF2_IP})
info('*** Adding 3rd final gateway devices\n')
dev1gwf3 = net.addDocker('dev1gwf3', ip=DEV1_GWF3_IP, dimage="device:topo", environment={'MY_IP':DEV1_GWF3_IP})
dev2gwf3 = net.addDocker('dev2gwf3', ip=DEV2_GWF3_IP, dimage="device:topo", environment={'MY_IP':DEV2_GWF3_IP})
dev3gwf3 = net.addDocker('dev3gwf3', ip=DEV3_GWF3_IP, dimage="device:topo", environment={'MY_IP':DEV3_GWF3_IP})
info('*** Adding switches\n')
s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
s3 = net.addSwitch('s3')
s4 = net.addSwitch('s4')
info('*** Creating links\n')
net.addLink(btrap, s2)
net.addLink(s1, s2)
net.addLink(s1, srv)
net.addLink(gwi1, s2)
net.addLink(s2, s3)
net.addLink(s2, s4)
net.addLink(s3, s4)
net.addLink(dc1, s4)
net.addLink(gwf1, s3)
net.addLink(dev1gwf1, gwf1)
net.addLink(dev2gwf1, gwf1)
net.addLink(dev3gwf1, gwf1)
net.addLink(gwf2, s3)
net.addLink(dev1gwf2, gwf2)
net.addLink(dev2gwf2, gwf2)
net.addLink(dev3gwf2, gwf2)
net.addLink(gwf3, s4)
net.addLink(dev1gwf3, gwf3)
net.addLink(dev2gwf3, gwf3)
net.addLink(dev3gwf3, gwf3)
info('*** Starting network\n')
net.start()
net.CLI()
# when the user types exit in the CLI, we stop the emulator
net.stop()
def main():
create_topology()
if __name__ == '__main__':
main()