Skip to content

Commit

Permalink
Jl/nfdv proxy (#73)
Browse files Browse the repository at this point in the history
* 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 <jordan.layton@metaswitch.com>
  • Loading branch information
jordlay and Jordan committed Sep 4, 2023
1 parent 28e3262 commit 445c220
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
13 changes: 13 additions & 0 deletions src/aosm/azext_aosm/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand All @@ -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

Expand Down Expand Up @@ -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}"
Expand Down
3 changes: 1 addition & 2 deletions src/aosm/azext_aosm/deploy/pre_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions src/aosm/azext_aosm/generate_nsd/nf_ret.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, {})

Expand Down

0 comments on commit 445c220

Please sign in to comment.