Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jl/nfdv proxy (#73) #75

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading