diff options
author | xinhuili <lxinhui@vmware.com> | 2017-03-22 02:00:41 -0700 |
---|---|---|
committer | xinhuili <lxinhui@vmware.com> | 2017-03-22 02:00:41 -0700 |
commit | 22ce175d1479837c3ece813df4c1f1f2a4395a50 (patch) | |
tree | dd7a7b5814587d45b71d5bfb1a1fe6bfb11368e4 | |
parent | 77cedaa2788fdd9094a70ec9b2d7c84f408485b6 (diff) |
Merge network fix
This patch is to fix network problems.
Change-Id: I28106902a1e5e5d134651739294766815c784d9f
Issue-ids: MULTIVIM-36
Signed-off-by: xinhuili <lxinhui@vmware.com>
-rw-r--r-- | vio/vio/pub/vim/vimapi/network/OperatePort.py | 9 | ||||
-rw-r--r-- | vio/vio/swagger/views/network/views.py | 5 | ||||
-rw-r--r-- | vio/vio/swagger/views/port/views.py | 5 | ||||
-rw-r--r-- | vio/vio/swagger/views/subnet/views.py | 5 |
4 files changed, 20 insertions, 4 deletions
diff --git a/vio/vio/pub/vim/vimapi/network/OperatePort.py b/vio/vio/pub/vim/vimapi/network/OperatePort.py index ac4f564..8f89ffc 100644 --- a/vio/vio/pub/vim/vimapi/network/OperatePort.py +++ b/vio/vio/pub/vim/vimapi/network/OperatePort.py @@ -25,9 +25,7 @@ class OperatePort(BaseNet): "networkId": "network_id", "vnicType": "binding:vnic_type", "securityGroups": "security_groups", - "macAddress": "mac_address", - # "subnetId": "subnet_id", - "ip": "ip_address" + "macAddress": "mac_address" } def ___init__(self, params): @@ -53,7 +51,10 @@ class OperatePort(BaseNet): vim_info = self.get_vim_info(vimid) network = self.auth(vim_info, tenantid) body = translate(self.keys_mapping, body) - if body.get('subnetId'): + if "ip" in body: + body['fixed_ips'] = [{'subnet_id': body.pop('subnetId'), + "ip_address": body.pop('ip')}] + else: body['fixed_ips'] = [{'subnet_id': body.pop('subnetId')}] port = network.port_create(**body) vim_dict = {"vimName": vim_info['name'], "vimId": vim_info['vimId']} diff --git a/vio/vio/swagger/views/network/views.py b/vio/vio/swagger/views/network/views.py index 773f200..b420e5c 100644 --- a/vio/vio/swagger/views/network/views.py +++ b/vio/vio/swagger/views/network/views.py @@ -34,6 +34,11 @@ class CreateNetworkView(APIView): return Response(data={'error': 'Fail to decode request body.'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) try: + req_paras = ["name", "shared"] + for para in req_paras: + if para not in body: + raise Exception('Required parameter %s is ' + 'missing in net creation.' % para) network_name = body.get('name') network_id = body.get('id', None) target = network_id or network_name diff --git a/vio/vio/swagger/views/port/views.py b/vio/vio/swagger/views/port/views.py index 8952f2b..3019003 100644 --- a/vio/vio/swagger/views/port/views.py +++ b/vio/vio/swagger/views/port/views.py @@ -34,6 +34,11 @@ class CreatePortView(APIView): return Response(data={'error': 'Fail to decode request body.'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) try: + req_paras = ["subnetId", "networkId", "name"] + for para in req_paras: + if para not in body: + raise Exception('Required parameter %s is ' + 'missing in port creation.' % para) port_name = body.get('name') port_id = body.get('id', None) target = port_id or port_name diff --git a/vio/vio/swagger/views/subnet/views.py b/vio/vio/swagger/views/subnet/views.py index b782b50..06d7548 100644 --- a/vio/vio/swagger/views/subnet/views.py +++ b/vio/vio/swagger/views/subnet/views.py @@ -34,6 +34,11 @@ class CreateSubnetView(APIView): return Response(data={'error': 'Fail to decode request body.'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) try: + req_paras = ["name", "networkId", "cidr", "ipVersion"] + for para in req_paras: + if para not in body: + raise Exception('Required parameter %s is ' + 'missing in subnet creation.' % para) subnet_name = body.get('name') subnet_id = body.get('id', None) target = subnet_id or subnet_name |