diff options
author | stark, steven <steven.stark@att.com> | 2020-10-15 12:34:35 -0700 |
---|---|---|
committer | stark, steven <steven.stark@att.com> | 2020-10-15 12:39:49 -0700 |
commit | a0984e365a7c610e9cb91cf73e5d09db2be6df6a (patch) | |
tree | 67b8aaaffb37b56105569f2233672db9e5720cbd /onap-client/onap_client/so/catalog | |
parent | 82f201fb65094aad55b3e46634bad39713387c6e (diff) |
[VVP] VVP onap-client enhancements
Adding capability for custom auth plugin (defaults to basic auth).
During updates to VNF models, resource and policy objects are deletd and recreated.
Issue-ID: VVP-477
Signed-off-by: stark, steven <steven.stark@att.com>
Change-Id: Iba743176167c2b1df185666b08cbd79c6a559c9e
Diffstat (limited to 'onap-client/onap_client/so/catalog')
-rw-r--r-- | onap-client/onap_client/so/catalog/infra_catalog.py | 91 | ||||
-rw-r--r-- | onap-client/onap_client/so/catalog/service_instantiation.py | 24 |
2 files changed, 103 insertions, 12 deletions
diff --git a/onap-client/onap_client/so/catalog/infra_catalog.py b/onap-client/onap_client/so/catalog/infra_catalog.py new file mode 100644 index 0000000..9245004 --- /dev/null +++ b/onap-client/onap_client/so/catalog/infra_catalog.py @@ -0,0 +1,91 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2020 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the "License"); +# you may not use this software 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. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# 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. +# +# ============LICENSE_END============================================ +import uuid +from functools import partial + +from onap_client.so.client import SOClient +from onap_client.util import utility +from onap_client.client.clients import get_client as Client + + +class ServiceInstantiationClient(SOClient): + @property + def namespace(self): + return "infra" + + @property + def catalog_resources(self): + return { + "GET_ACTIVE_REQUESTS": { + "verb": "GET", + "description": "Queries for the list of infraActiveRequests", + "uri": partial( + "{endpoint}/infraActiveRequests?size={size}&sort=startTime,DESC".format, + endpoint=self.config.so.SO_ENDPOINT, + ), + "uri-parameters": ["size"], + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": self.config.application_id, + }, + "auth": self.auth, + }, + } + + +@utility +def get_all_infra_requests(oc=None): + if not oc: + oc = Client() + + infra_data = oc.so.infra.get_active_requests(size="20").response_data + + total_elements = int(infra_data.get("page", {}).get("totalElements", 20)) + + return oc.so.infra.get_active_requests(size=total_elements).response_data + + +@utility +def get_recent_infra_requests(size, oc=None): + if not oc: + oc = Client() + + return oc.so.infra.get_active_requests(size=size).response_data + diff --git a/onap-client/onap_client/so/catalog/service_instantiation.py b/onap-client/onap_client/so/catalog/service_instantiation.py index 3874aef..e18aca1 100644 --- a/onap-client/onap_client/so/catalog/service_instantiation.py +++ b/onap-client/onap_client/so/catalog/service_instantiation.py @@ -81,7 +81,7 @@ class ServiceInstantiationClient(SOClient): # "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, "DELETE_SERVICE_INSTANCE": { "verb": "DELETE", @@ -107,7 +107,7 @@ class ServiceInstantiationClient(SOClient): # "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, "CREATE_VNF_INSTANCE": { "verb": "POST", @@ -147,7 +147,7 @@ class ServiceInstantiationClient(SOClient): # "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, "DELETE_VNF_INSTANCE": { "verb": "DELETE", @@ -175,7 +175,7 @@ class ServiceInstantiationClient(SOClient): "Content-Type": "application/json", "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, "CREATE_VOLUME_MODULE_INSTANCE": { "verb": "POST", @@ -218,7 +218,7 @@ class ServiceInstantiationClient(SOClient): "Content-Type": "application/json", "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, "CREATE_MODULE_INSTANCE": { "verb": "POST", @@ -261,7 +261,7 @@ class ServiceInstantiationClient(SOClient): "Content-Type": "application/json", "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, "DELETE_MODULE_INSTANCE": { "verb": "DELETE", @@ -289,7 +289,7 @@ class ServiceInstantiationClient(SOClient): "Content-Type": "application/json", "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, "DELETE_VOLUME_MODULE_INSTANCE": { "verb": "DELETE", @@ -317,7 +317,7 @@ class ServiceInstantiationClient(SOClient): "Content-Type": "application/json", "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, "GET_REQUEST_STATUS": { "verb": "GET", @@ -335,7 +335,7 @@ class ServiceInstantiationClient(SOClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, "GET_SERVICE_MODEL": { "verb": "GET", @@ -352,7 +352,7 @@ class ServiceInstantiationClient(SOClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, "GET_SERVICE_MODEL_DETAILS": { "verb": "GET", @@ -369,7 +369,7 @@ class ServiceInstantiationClient(SOClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, "GET_MODULE_CUSTOMIZATION": { "verb": "GET", @@ -386,6 +386,6 @@ class ServiceInstantiationClient(SOClient): "X-TransactionId": str(uuid.uuid4()), "X-FromAppId": self.config.application_id, }, - "auth": (self.config.so.SO_USERNAME, self.config.so.SO_PASSWORD), + "auth": self.auth, }, } |