From 445c2204580b758e1ccf1b6d46c90a3cc60ad60a Mon Sep 17 00:00:00 2001 From: jordlay <72226943+jordlay@users.noreply.github.com> Date: Mon, 4 Sep 2023 14:38:14 +0100 Subject: [PATCH] Jl/nfdv proxy (#73) * added publisher scope to input file; changed to proxy nsdv * fixed get request on proxy nfdv (should be overwritten when autogenerated again) * small print bug fix --------- Co-authored-by: Jordan --- src/aosm/azext_aosm/_configuration.py | 13 +++++++++++++ src/aosm/azext_aosm/deploy/pre_deploy.py | 3 +-- src/aosm/azext_aosm/generate_nsd/nf_ret.py | 7 ++++--- ...twork_function_definition_versions_operations.py | 7 ++----- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/aosm/azext_aosm/_configuration.py b/src/aosm/azext_aosm/_configuration.py index b8d14d68f77..7a5f2e00ac4 100644 --- a/src/aosm/azext_aosm/_configuration.py +++ b/src/aosm/azext_aosm/_configuration.py @@ -333,6 +333,7 @@ def validate(self): NFD_LOCATION = "The region that the NFDV is published to." PUBLISHER_RESOURCE_GROUP = "The resource group that the publisher is hosted in." PUBLISHER_NAME = "The name of the publisher that this NFDV is published under." +PUBLISHER_SCOPE = "The scope that the publisher is published under. Currently, only 'private' is supported." NFD_TYPE = "Type of Network Function. Valid values are 'cnf' or 'vnf'" MULTIPLE_INSTANCES = ( "Set to true or false. Whether the NSD should allow arbitrary numbers of this " @@ -350,6 +351,7 @@ class NFDRETConfiguration: name: str = NFD_NAME version: str = NFD_VERSION publisher_offering_location: str = NFD_LOCATION + publisher_scope: str = PUBLISHER_SCOPE type: str = NFD_TYPE multiple_instances: Union[str, bool] = MULTIPLE_INSTANCES @@ -380,6 +382,17 @@ def validate(self) -> None: f"Network function definition offering location must be set, for {self.name}" ) + if self.publisher_scope == PUBLISHER_SCOPE: + raise ValidationError( + f"Network function definition publisher scope must be set, for {self.name}" + ) + + # Temporary validation while only private publishers exist + if self.publisher_scope not in ["private", "Private"]: + raise ValidationError( + "Only private publishers are currently supported" + ) + if self.type not in [CNF, VNF]: raise ValueError( f"Network Function Type must be cnf or vnf for {self.name}" diff --git a/src/aosm/azext_aosm/deploy/pre_deploy.py b/src/aosm/azext_aosm/deploy/pre_deploy.py index 26deff1cf9e..2faa2109e97 100644 --- a/src/aosm/azext_aosm/deploy/pre_deploy.py +++ b/src/aosm/azext_aosm/deploy/pre_deploy.py @@ -440,8 +440,7 @@ def ensure_nsdg_exists( :type location: str """ print( - "Creating Network Service Design Group %s if it does not exist", - nsdg_name, + f"Creating Network Service Design Group {nsdg_name} if it does not exist", ) logger.info( "Creating Network Service Design Group %s if it does not exist", diff --git a/src/aosm/azext_aosm/generate_nsd/nf_ret.py b/src/aosm/azext_aosm/generate_nsd/nf_ret.py index ab335b1123f..04bca314bf5 100644 --- a/src/aosm/azext_aosm/generate_nsd/nf_ret.py +++ b/src/aosm/azext_aosm/generate_nsd/nf_ret.py @@ -50,9 +50,10 @@ def _get_nfdv( "Reading existing NFDV resource object " f"{config.version} from group {config.name}" ) - nfdv_object = api_clients.aosm_client.network_function_definition_versions.get( - resource_group_name=config.publisher_resource_group, - publisher_name=config.publisher, + nfdv_object = api_clients.aosm_client.proxy_network_function_definition_versions.get( + publisher_scope_name=config.publisher_scope, + publisher_location_name=config.publisher_offering_location, + proxy_publisher_name=config.publisher, network_function_definition_group_name=config.name, network_function_definition_version_name=config.version, ) diff --git a/src/aosm/azext_aosm/vendored_sdks/operations/_proxy_network_function_definition_versions_operations.py b/src/aosm/azext_aosm/vendored_sdks/operations/_proxy_network_function_definition_versions_operations.py index 7f0e01c882e..96a4972870d 100644 --- a/src/aosm/azext_aosm/vendored_sdks/operations/_proxy_network_function_definition_versions_operations.py +++ b/src/aosm/azext_aosm/vendored_sdks/operations/_proxy_network_function_definition_versions_operations.py @@ -98,8 +98,8 @@ def build_get_request( # Construct parameters _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['publisherScopeName'] = _SERIALIZER.query("publisher_scope_name", publisher_scope_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$') - _query_parameters['publisherLocationName'] = _SERIALIZER.query("publisher_location_name", publisher_location_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$') + _query_parameters['publisherScope'] = _SERIALIZER.query("publisher_scope_name", publisher_scope_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$') + _query_parameters['publisherLocation'] = _SERIALIZER.query("publisher_location_name", publisher_location_name, 'str', max_length=64, min_length=0, pattern=r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$') _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers @@ -285,21 +285,18 @@ def get( ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('NetworkFunctionDefinitionVersionOverview', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {})