No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

topology.py 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #!/usr/bin/python
  2. # Copyright (c) 2020 INSA Toulouse
  3. # ALL RIGHTS RESERVED.
  4. #
  5. # This topology has been built by inspiring on the 'default_single_dc_topology.py' example of son-emu
  6. #
  7. # Authors
  8. # Abdel Kader CHABI SIKA BONI (Master2 ILoRD at INSA Toulouse, chabisik@etud.insa-toulouse.fr)
  9. # Arnaud PRIEU (5SDBD at INSA Toulouse, prieu@etud.insa-toulouse.fr)
  10. # Year: 2020-2021
  11. import logging
  12. from mininet.log import setLogLevel, info
  13. from emuvim.dcemulator.net import DCNetwork
  14. from emuvim.api.rest.rest_api_endpoint import RestApiEndpoint
  15. from emuvim.api.openstack.openstack_api_endpoint import OpenstackApiEndpoint
  16. logging.basicConfig(level=logging.INFO)
  17. setLogLevel('info') # set Mininet loglevel
  18. logging.getLogger('werkzeug').setLevel(logging.DEBUG)
  19. logging.getLogger('api.openstack.base').setLevel(logging.DEBUG)
  20. logging.getLogger('api.openstack.compute').setLevel(logging.DEBUG)
  21. logging.getLogger('api.openstack.keystone').setLevel(logging.DEBUG)
  22. logging.getLogger('api.openstack.nova').setLevel(logging.DEBUG)
  23. logging.getLogger('api.openstack.neutron').setLevel(logging.DEBUG)
  24. logging.getLogger('api.openstack.heat').setLevel(logging.DEBUG)
  25. logging.getLogger('api.openstack.heat.parser').setLevel(logging.DEBUG)
  26. logging.getLogger('api.openstack.glance').setLevel(logging.DEBUG)
  27. logging.getLogger('api.openstack.helper').setLevel(logging.DEBUG)
  28. #####################################################################################################
  29. # OUR TOPOLOGY'S DETAILS #
  30. # (if changed, bootstrap server script must be changed too and the new config:topo image builded) #
  31. #####################################################################################################
  32. BOOTSTRAP_SERVER = '10.10.10.10' #name = btrap; port = 5555
  33. SVR_IP = '10.0.0.1' #name = srv
  34. GWI1_IP = '10.2.2.1' #name = gwi1
  35. GWI2_IP = '10.2.2.2' #name = gwi2
  36. GWF1_IP = '10.0.1.100' #name = gwf1
  37. DEV1_GWF1_IP = '10.0.1.1' #name = dev1gwf1
  38. DEV2_GWF1_IP = '10.0.1.2' #name = dev2gwf1
  39. DEV3_GWF1_IP = '10.0.1.3' #name = dev3gwf1
  40. GWF2_IP = '10.0.2.100' #name = gwf2
  41. DEV1_GWF2_IP = '10.0.2.1' #name = dev1gwf2
  42. DEV2_GWF2_IP = '10.0.2.2' #name = dev2gwf2
  43. DEV3_GWF2_IP = '10.0.2.3' #name = dev3gwf2
  44. GWF3_IP = '10.0.3.100' #name = gwf3
  45. DEV1_GWF3_IP = '10.0.3.1' #name = dev1gwf3
  46. DEV2_GWF3_IP = '10.0.3.2' #name = dev2gwf3
  47. DEV3_GWF3_IP = '10.0.3.3' #name = dev3gwf3
  48. '''
  49. TOPOLOGY OVERVIEW
  50. Necessary docker images: config:topo ; server:topo ; gateway:topo ; device:topo
  51. ++++++++ ++++++++
  52. + dev1 +--- + gwf1 +
  53. ++++++++ | ++++++++
  54. | | ______________++++++++
  55. | | | + dev2 +
  56. ++++++++ | ++++++++ ++++++++ ++++++++
  57. + gwi1 + |_______+ s5 +----------------------------+ dev3 +
  58. ++++++++ ++++++++ ++++++++ ++++++++
  59. | | _____________________________________________+ gwf2 +
  60. | | | ++++++++
  61. +++++++ +++++++ +++++++ +++++++ ++++++++ ++++++++
  62. + srv +--------+ s1 +---------+ s2 +---------+ s3 +------+ s6 +--------------------+ dev1 +
  63. +++++++ +++++++ +++++++ +++++++ ++++++++ ++++++++
  64. | | | | | ++++++++
  65. | | | | |_____________+ dev2 +
  66. | | | | ++++++++
  67. | | ++++++ | ++++++++
  68. | | + s4 +---- |_____+ dev3 +
  69. | | ++++++ | ++++++++
  70. | +++++++++ | |
  71. | + btrap + | |____++++++++ ++++++++
  72. | +++++++++ ______| + s7 +--------+ dev1 +
  73. | | ++++++++ ++++++++
  74. | | ______________| | |
  75. | ________| | | |
  76. | | | | |___________++++++++
  77. | | | | + dev2 +
  78. | ++++++ | | ++++++++
  79. |____________________________+ DC + ++++++++ ++++++++
  80. ++++++ + dev3 + + gwf3 +
  81. ++++++++ ++++++++
  82. '''
  83. #####################################################################################################
  84. def create_topology():
  85. net = DCNetwork(monitor=False, enable_learning=True)
  86. dc1 = net.addDatacenter("dc1")
  87. # add OpenStack-like APIs to the emulated DC
  88. api1 = OpenstackApiEndpoint("0.0.0.0", 6001)
  89. api1.connect_datacenter(dc1)
  90. api1.start()
  91. api1.connect_dc_network(net)
  92. # add the command line interface endpoint to the emulated DC (REST API)
  93. rapi1 = RestApiEndpoint("0.0.0.0", 5001)
  94. rapi1.connectDCNetwork(net)
  95. rapi1.connectDatacenter(dc1)
  96. rapi1.start()
  97. info('*** Adding bootstrap server\n')
  98. btrap = net.addDocker('btrap', ip=BOOTSTRAP_SERVER, dimage="config:topo")
  99. info('*** Adding topology server\n')
  100. srv = net.addDocker('srv', ip=SVR_IP, dimage="server:topo", environment={'MY_IP':SVR_IP})
  101. info('*** Adding topology intermediary gateway\n')
  102. gwi1 = net.addDocker('gwi1', ip=GWI1_IP, dimage="gateway:topo", environment={'MY_IP':GWI1_IP})
  103. info('*** Adding topology final gateways\n')
  104. gwf1 = net.addDocker('gwf1', ip=GWF1_IP, dimage="gateway:topo", environment={'MY_IP':GWF1_IP})
  105. gwf2 = net.addDocker('gwf2', ip=GWF2_IP, dimage="gateway:topo", environment={'MY_IP':GWF2_IP})
  106. gwf3 = net.addDocker('gwf3', ip=GWF3_IP, dimage="gateway:topo", environment={'MY_IP':GWF3_IP})
  107. info('*** Adding 1st final gateway devices\n')
  108. dev1gwf1 = net.addDocker('dev1gwf1', ip=DEV1_GWF1_IP, dimage="device:topo", environment={'MY_IP':DEV1_GWF1_IP})
  109. dev2gwf1 = net.addDocker('dev2gwf1', ip=DEV2_GWF1_IP, dimage="device:topo", environment={'MY_IP':DEV2_GWF1_IP})
  110. dev3gwf1 = net.addDocker('dev3gwf1', ip=DEV3_GWF1_IP, dimage="device:topo", environment={'MY_IP':DEV3_GWF1_IP})
  111. info('*** Adding 2nd final gateway devices\n')
  112. dev1gwf2 = net.addDocker('dev1gwf2', ip=DEV1_GWF2_IP, dimage="device:topo", environment={'MY_IP':DEV1_GWF2_IP})
  113. dev2gwf2 = net.addDocker('dev2gwf2', ip=DEV2_GWF2_IP, dimage="device:topo", environment={'MY_IP':DEV2_GWF2_IP})
  114. dev3gwf2 = net.addDocker('dev3gwf2', ip=DEV3_GWF2_IP, dimage="device:topo", environment={'MY_IP':DEV3_GWF2_IP})
  115. info('*** Adding 3rd final gateway devices\n')
  116. dev1gwf3 = net.addDocker('dev1gwf3', ip=DEV1_GWF3_IP, dimage="device:topo", environment={'MY_IP':DEV1_GWF3_IP})
  117. dev2gwf3 = net.addDocker('dev2gwf3', ip=DEV2_GWF3_IP, dimage="device:topo", environment={'MY_IP':DEV2_GWF3_IP})
  118. dev3gwf3 = net.addDocker('dev3gwf3', ip=DEV3_GWF3_IP, dimage="device:topo", environment={'MY_IP':DEV3_GWF3_IP})
  119. info('*** Adding switches\n')
  120. s1 = net.addSwitch('s1')
  121. s2 = net.addSwitch('s2')
  122. s3 = net.addSwitch('s3')
  123. s4 = net.addSwitch('s4')
  124. s5 = net.addSwitch('s5')
  125. s6 = net.addSwitch('s6')
  126. s7 = net.addSwitch('s7')
  127. info('*** Creating links\n')
  128. net.addLink(btrap, s2)
  129. net.addLink(s1, s2)
  130. net.addLink(s1, srv)
  131. net.addLink(gwi1, s2)
  132. net.addLink(s2, s3)
  133. net.addLink(s3, s4)
  134. net.addLink(dc1, s4)
  135. net.addLink(dc1, srv) #
  136. ########ZONE1###########
  137. net.addLink(s3, s5)
  138. net.addLink(gwf1, s5)
  139. net.addLink(dev1gwf1, s5)
  140. net.addLink(dev2gwf1, s5)
  141. net.addLink(dev3gwf1, s5)
  142. ########ZONE2###########
  143. net.addLink(s3, s6)
  144. net.addLink(gwf2, s6)
  145. net.addLink(dev1gwf2, s6)
  146. net.addLink(dev2gwf2, s6)
  147. net.addLink(dev3gwf2, s6)
  148. ########ZONE3###########
  149. net.addLink(s4, s7)
  150. net.addLink(gwf3, s7)
  151. net.addLink(dev1gwf3, s7)
  152. net.addLink(dev2gwf3, s7)
  153. net.addLink(dev3gwf3, s7)
  154. info('*** Starting network\n')
  155. net.start()
  156. net.CLI()
  157. # when the user types exit in the CLI, we stop the emulator
  158. net.stop()
  159. def main():
  160. create_topology()
  161. if __name__ == '__main__':
  162. main()