- #print 'RESP: {}'.format(resp)
- if not resp or 'id' not in resp:
- raise ClientException('unexpected response from server: '.format(
- resp))
+ if not resp or "id" not in resp:
+ raise ClientException(
+ "unexpected response from server - {}".format(resp)
+ )
+ if wait:
+ # Wait for status for NS instance action
+ # For the 'action' operation, 'id' is used
+ self._wait(resp.get("id"), wait)
+ return resp["id"]
+ # else:
+ # msg = ""
+ # if resp:
+ # try:
+ # msg = json.loads(resp)
+ # except ValueError:
+ # msg = resp
+ # raise ClientException(msg)
+ except ClientException as exc:
+ message = "failed to exec operation {}:\nerror:\n{}".format(name, str(exc))
+ raise ClientException(message)
+
+ def scale_vnf(
+ self,
+ ns_name,
+ vnf_name,
+ scaling_group,
+ scale_in,
+ scale_out,
+ wait=False,
+ timeout=None,
+ ):
+ """Scales a VNF by adding/removing VDUs"""
+ self._logger.debug("")
+ self._client.get_token()
+ try:
+ op_data = {}
+ op_data["scaleType"] = "SCALE_VNF"
+ op_data["scaleVnfData"] = {}
+ if scale_in and not scale_out:
+ op_data["scaleVnfData"]["scaleVnfType"] = "SCALE_IN"
+ elif not scale_in and scale_out:
+ op_data["scaleVnfData"]["scaleVnfType"] = "SCALE_OUT"