| peusterm | 5831076 | 2016-01-12 17:09:20 +0100 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | """ |
| peusterm | 79ef6ae | 2016-07-08 13:53:57 +0200 | [diff] [blame] | 3 | Copyright (c) 2015 SONATA-NFV and Paderborn University |
| 4 | ALL RIGHTS RESERVED. |
| peusterm | 5831076 | 2016-01-12 17:09:20 +0100 | [diff] [blame] | 5 | |
| peusterm | 79ef6ae | 2016-07-08 13:53:57 +0200 | [diff] [blame] | 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | you may not use this file except in compliance with the License. |
| 8 | You may obtain a copy of the License at |
| 9 | |
| 10 | http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | |
| 12 | Unless required by applicable law or agreed to in writing, software |
| 13 | distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | See the License for the specific language governing permissions and |
| 16 | limitations under the License. |
| 17 | |
| 18 | Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION] |
| 19 | nor the names of its contributors may be used to endorse or promote |
| 20 | products derived from this software without specific prior written |
| 21 | permission. |
| 22 | |
| 23 | This work has been performed in the framework of the SONATA project, |
| 24 | funded by the European Commission under Grant number 671517 through |
| 25 | the Horizon 2020 and 5G-PPP programmes. The authors would like to |
| 26 | acknowledge the contributions of their colleagues of the SONATA |
| 27 | partner consortium (www.sonata-nfv.eu). |
| 28 | """ |
| 29 | """ |
| 30 | Simple CLI client to interact with a running emulator. |
| peusterm | 2ec74e1 | 2016-01-13 11:17:53 +0100 | [diff] [blame] | 31 | |
| peusterm | 5831076 | 2016-01-12 17:09:20 +0100 | [diff] [blame] | 32 | The CLI offers different tools, e.g., compute, network, ... |
| 33 | Each of these tools is implemented as an independent Python |
| 34 | module. |
| 35 | |
| 36 | cli compute start dc1 my_name flavor_a |
| 37 | cli network create dc1 11.0.0.0/24 |
| 38 | """ |
| 39 | |
| 40 | import sys |
| hadik3r | 558504a | 2016-06-27 17:59:04 +0200 | [diff] [blame] | 41 | from emuvim.cli.rest import compute as restcom |
| 42 | from emuvim.cli.rest import datacenter as restdc |
| stevenvanrossem | 73efd19 | 2016-06-29 01:44:07 +0200 | [diff] [blame] | 43 | from emuvim.cli.rest import monitor as restmon |
| 44 | from emuvim.cli.rest import network as restnetw |
| hadik3r | 558504a | 2016-06-27 17:59:04 +0200 | [diff] [blame] | 45 | |
| peusterm | 68aaedb | 2017-06-15 14:27:46 +0200 | [diff] [blame] | 46 | def help(): |
| 47 | print("Missing arguments.\n") |
| 48 | print("Usage: son-emu-cli compute|datacenter|network|monitor <arguments>\n") |
| 49 | print("Get more help:") |
| 50 | print("\tson-emu-cli compute --help") |
| 51 | print("\tson-emu-cli datacenter --help") |
| 52 | print("\tson-emu-cli network --help") |
| 53 | print("\tson-emu-cli monitor --help") |
| 54 | exit(0) |
| peusterm | 5831076 | 2016-01-12 17:09:20 +0100 | [diff] [blame] | 55 | |
| 56 | def main(): |
| 57 | if len(sys.argv) < 2: |
| peusterm | 68aaedb | 2017-06-15 14:27:46 +0200 | [diff] [blame] | 58 | help() |
| stevenvanrossem | 73efd19 | 2016-06-29 01:44:07 +0200 | [diff] [blame] | 59 | elif sys.argv[1] == "monitor": |
| 60 | restmon.main(sys.argv[2:]) |
| 61 | elif sys.argv[1] == "network": |
| 62 | restnetw.main(sys.argv[2:]) |
| hadik3r | 558504a | 2016-06-27 17:59:04 +0200 | [diff] [blame] | 63 | elif sys.argv[1] == "compute": |
| 64 | restcom.main(sys.argv[2:]) |
| 65 | elif sys.argv[1] == "datacenter": |
| 66 | restdc.main(sys.argv[2:]) |
| peusterm | 68aaedb | 2017-06-15 14:27:46 +0200 | [diff] [blame] | 67 | else: |
| 68 | help() |
| hadik3r | 558504a | 2016-06-27 17:59:04 +0200 | [diff] [blame] | 69 | |
| peusterm | 5831076 | 2016-01-12 17:09:20 +0100 | [diff] [blame] | 70 | |
| 71 | if __name__ == '__main__': |
| 72 | main() |