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

Temp 16feb wheel #145

Merged
merged 39 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
28013e0
added nexus arm processor; added nfvi type to vnfinput.json; added co…
Jan 25, 2024
7f08186
pipe through nfvi type from vnf input to template; added nexus input;…
Jan 25, 2024
30979f5
initial commit for children vnf handlers
Jan 30, 2024
68f46f2
added core and nexus config logic
Jan 30, 2024
5d0f8ea
merged main
Jan 31, 2024
e81e482
fixed nexus input and nexus processor; fixed templates
Feb 1, 2024
99a713b
generalised render manifest and render definition bicep functions to …
Feb 1, 2024
01100dc
added incorrect config error handling
Feb 1, 2024
7196d34
added nexus flag to publish; added error handling for incorrect vnf t…
Feb 2, 2024
53b1ad0
added vnf nexus base bicep; fixed vnf definition template; temp fix f…
Feb 2, 2024
a723cdb
moved render bicep to common/utils; replaced build base bicep with re…
Feb 2, 2024
5e229d5
general tidyup: removed prints, added return types
Feb 2, 2024
7628817
added nfvi type to nsds
Feb 2, 2024
0b20c58
removed old todos
Feb 2, 2024
1c20ecb
refactored nexus handler, moved generate params code into processor
Feb 6, 2024
e2c6d68
moved logic to base vnf handler; moved more logic to processor
Feb 9, 2024
b1d0575
fix template name in vnf j2
Feb 9, 2024
e3d7b62
fixed nexus image file
Feb 9, 2024
0fe396b
added nfvitype to nsd nf template by making new j2 + changing how nfd…
Feb 9, 2024
9ffb640
added nfvitype to nsd nf template by making new j2 + changing how nfd…
Feb 9, 2024
3e77347
minor formatting
Feb 9, 2024
e63ab2f
made vnfnexus a definition type; slight refactor of custom.py
Feb 9, 2024
9240657
removed nexus param, removed prints, added commented out test file
Feb 9, 2024
797ac3e
merge with main; prestylng
Feb 9, 2024
4fd6404
fixed flake8 + pylint issues
Feb 9, 2024
b075d3b
Base handler treats command inputs separately (#143)
jordlay Feb 12, 2024
17bd37b
mypy fixes
Feb 12, 2024
143f3d2
fixed customLocation id for vnf nexus
Feb 16, 2024
0ff7b3d
markups from review inc moving build manifest to parent vnf handler
Feb 16, 2024
9d3eb7b
added better docstrings
Feb 16, 2024
f5cd320
updated history.rst
Feb 19, 2024
03c1680
Achurchard/fix helm chart upload (#144)
jordlay Feb 19, 2024
b3d9f54
bumped version
Feb 19, 2024
b6c781b
Bug: No type in schema (#148)
jordlay Feb 26, 2024
84e5a3b
Bug: Nexus Image Version Must be Semver (#149)
jordlay Feb 26, 2024
4d90245
Create RG if it doesn't exist (#150)
jordlay Feb 26, 2024
8cfdd0c
Bug Fix: NFD and NSD Manifest Names Clash (#147)
jordlay Feb 26, 2024
81d31a3
Fix Nexus Linting + Add Unit Tests (#146)
jordlay Feb 27, 2024
cadf02e
Use ephemeral tempdir for generated helm package .tgz file. (#151)
Cyclam Feb 28, 2024
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
12 changes: 12 additions & 0 deletions src/aosm/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ Release History
===============

Unreleased

1.0.0b8
++++++++

1.0.0b7
++++++++
* Fixed: customLocation missing from Nexus
* Fixed: helm charts not uploading correctly

++++++++
1.0.0b6
++++++++
* Added Nexus support

1.0.0b5
++++++++
Expand Down
11 changes: 6 additions & 5 deletions src/aosm/azext_aosm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
from azure.cli.core import AzCommandsLoader

from .common.constants import (
ARTIFACT_UPLOAD,
BICEP_PUBLISH,
CNF,
VNF,
VNF_NEXUS,
BICEP_PUBLISH,
ARTIFACT_UPLOAD,
HELM_TEMPLATE,
IMAGE_UPLOAD,
VNF,
)


Expand All @@ -23,7 +24,7 @@ def load_arguments(self: AzCommandsLoader, _):
get_three_state_flag,
)

definition_type = get_enum_type([VNF, CNF])
definition_type = get_enum_type([VNF, CNF, VNF_NEXUS])
nf_skip_steps = get_enum_type(
[BICEP_PUBLISH, ARTIFACT_UPLOAD, IMAGE_UPLOAD, HELM_TEMPLATE]
)
Expand All @@ -36,7 +37,7 @@ def load_arguments(self: AzCommandsLoader, _):
c.argument(
"definition_type",
arg_type=definition_type,
help="Type of AOSM definition.",
help="Type of AOSM definition to be published.",
required=True,
)
c.argument(
Expand Down
118 changes: 91 additions & 27 deletions src/aosm/azext_aosm/build_processors/arm_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,41 @@
# --------------------------------------------------------------------------------------------

import json
from pathlib import Path
from abc import abstractmethod
from typing import List, Tuple, final

from knack.log import get_logger

from azext_aosm.build_processors.base_processor import BaseInputProcessor
from azext_aosm.common.artifact import BaseArtifact, LocalFileACRArtifact
from azext_aosm.common.artifact import (BaseArtifact, LocalFileACRArtifact)
from azext_aosm.definition_folder.builder.local_file_builder import LocalFileBuilder
from azext_aosm.inputs.arm_template_input import ArmTemplateInput
from azext_aosm.vendored_sdks.models import (
ApplicationEnablement,
ArmResourceDefinitionResourceElementTemplate,
ArtifactType,
AzureOperatorNexusNetworkFunctionArmTemplateApplication,
ApplicationEnablement, ArmResourceDefinitionResourceElementTemplate,
ArmResourceDefinitionResourceElementTemplateDetails,
ArmTemplateArtifactProfile,
ArmTemplateMappingRuleProfile,
AzureCoreArmTemplateArtifactProfile,
NetworkFunctionApplication, NSDArtifactProfile,
ResourceElementTemplate, TemplateType, AzureOperatorNexusArtifactType,
AzureOperatorNexusArmTemplateDeployMappingRuleProfile, AzureOperatorNexusArmTemplateArtifactProfile,
AzureCoreArmTemplateDeployMappingRuleProfile,
AzureCoreArtifactType,
AzureCoreNetworkFunctionArmTemplateApplication,
DependsOnProfile,
ManifestArtifactFormat,
NetworkFunctionApplication,
NSDArtifactProfile,
ReferencedResource,
ResourceElementTemplate,
TemplateType,
)

from azext_aosm.common.constants import (
VNF_OUTPUT_FOLDER_FILENAME,
NF_DEFINITION_FOLDER_NAME,
TEMPLATE_PARAMETERS_FILENAME)


logger = get_logger(__name__)


Expand Down Expand Up @@ -71,7 +78,7 @@ def get_artifact_manifest_list(self) -> List[ManifestArtifactFormat]:
return [
ManifestArtifactFormat(
artifact_name=self.input_artifact.artifact_name,
artifact_type=AzureCoreArtifactType.ARM_TEMPLATE.value,
artifact_type=ArtifactType.ARM_TEMPLATE.value,
artifact_version=self.input_artifact.artifact_version,
)
]
Expand All @@ -93,7 +100,7 @@ def get_artifact_details(
[
LocalFileACRArtifact(
artifact_name=self.input_artifact.artifact_name,
artifact_type=AzureCoreArtifactType.ARM_TEMPLATE.value,
artifact_type=ArtifactType.ARM_TEMPLATE.value,
artifact_version=self.input_artifact.artifact_version,
file_path=self.input_artifact.template_path,
)
Expand All @@ -105,22 +112,15 @@ def get_artifact_details(
def generate_nf_application(self) -> NetworkFunctionApplication:
return self.generate_nfvi_specific_nf_application()

def generate_artifact_profile(self) -> AzureCoreArmTemplateArtifactProfile:
artifact_profile = ArmTemplateArtifactProfile(
template_name=self.input_artifact.artifact_name,
template_version=self.input_artifact.artifact_version,
)
return AzureCoreArmTemplateArtifactProfile(
artifact_store=ReferencedResource(id=""),
template_artifact_profile=artifact_profile,
)

@abstractmethod
def generate_nfvi_specific_nf_application(self):
pass

def generate_resource_element_template(self) -> ResourceElementTemplate:
"""Generate the resource element template."""
"""Generate the resource element template.

Note: There is no Nexus specific RET
"""
parameter_values = self.generate_values_mappings(
self.input_artifact.get_schema(), self.input_artifact.get_defaults(), True
)
Expand All @@ -143,11 +143,31 @@ def generate_resource_element_template(self) -> ResourceElementTemplate:
),
)

def generate_parameters_file(self) -> LocalFileBuilder:
"""Generate parameters file."""
mapping_rule_profile = self._generate_mapping_rule_profile()
params = (
mapping_rule_profile.template_mapping_rule_profile.template_parameters
)
logger.info(
"Created parameters file for arm template."
)
return LocalFileBuilder(
Path(
VNF_OUTPUT_FOLDER_FILENAME,
NF_DEFINITION_FOLDER_NAME,
self.input_artifact.artifact_name + '-' + TEMPLATE_PARAMETERS_FILENAME,
),
json.dumps(json.loads(params), indent=4),
)

@abstractmethod
def _generate_mapping_rule_profile(self):
pass


class AzureCoreArmBuildProcessor(BaseArmBuildProcessor):
"""
This class represents an ARM template processor for Azure Core.
"""
"""This class represents an ARM template processor for Azure Core."""

def generate_nfvi_specific_nf_application(
self,
Expand All @@ -158,7 +178,7 @@ def generate_nfvi_specific_nf_application(
install_depends_on=[], uninstall_depends_on=[], update_depends_on=[]
),
artifact_type=AzureCoreArtifactType.ARM_TEMPLATE,
artifact_profile=self.generate_artifact_profile(),
artifact_profile=self._generate_artifact_profile(),
deploy_parameters_mapping_rule_profile=self._generate_mapping_rule_profile(),
)

Expand All @@ -178,11 +198,55 @@ def _generate_mapping_rule_profile(
template_mapping_rule_profile=mapping_profile,
)

def _generate_artifact_profile(self) -> AzureCoreArmTemplateArtifactProfile:
artifact_profile = ArmTemplateArtifactProfile(
template_name=self.input_artifact.artifact_name,
template_version=self.input_artifact.artifact_version,
)
return AzureCoreArmTemplateArtifactProfile(
artifact_store=ReferencedResource(id=""),
template_artifact_profile=artifact_profile,
)


class NexusArmBuildProcessor(BaseArmBuildProcessor):
"""
Not implemented yet. This class represents a processor for generating ARM templates specific to Nexus.
This class represents a processor for generating ARM templates specific to Nexus.
"""
def generate_nfvi_specific_nf_application(
self,
) -> AzureOperatorNexusNetworkFunctionArmTemplateApplication:
return AzureOperatorNexusNetworkFunctionArmTemplateApplication(
name=self.name,
depends_on_profile=DependsOnProfile(install_depends_on=[],
uninstall_depends_on=[], update_depends_on=[]),
artifact_type=AzureOperatorNexusArtifactType.ARM_TEMPLATE,
artifact_profile=self._generate_artifact_profile(),
deploy_parameters_mapping_rule_profile=self._generate_mapping_rule_profile(),
)

def generate_nfvi_specific_nf_application(self):
return NotImplementedError
def _generate_mapping_rule_profile(
self,
) -> AzureOperatorNexusArmTemplateDeployMappingRuleProfile:
template_parameters = self.generate_values_mappings(
self.input_artifact.get_schema(), self.input_artifact.get_defaults()
)

mapping_profile = ArmTemplateMappingRuleProfile(
template_parameters=json.dumps(template_parameters)
)

return AzureOperatorNexusArmTemplateDeployMappingRuleProfile(
application_enablement=ApplicationEnablement.ENABLED,
template_mapping_rule_profile=mapping_profile,
)

def _generate_artifact_profile(self) -> AzureOperatorNexusArmTemplateArtifactProfile:
artifact_profile = ArmTemplateArtifactProfile(
template_name=self.input_artifact.artifact_name,
template_version=self.input_artifact.artifact_version,
)
return AzureOperatorNexusArmTemplateArtifactProfile(
artifact_store=ReferencedResource(id=""),
template_artifact_profile=artifact_profile,
)
19 changes: 16 additions & 3 deletions src/aosm/azext_aosm/build_processors/base_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Any, Dict, List, Tuple

from knack.log import get_logger

from azure.cli.core.azclierror import InvalidArgumentValueError
from azext_aosm.common.artifact import BaseArtifact
from azext_aosm.common.constants import CGS_NAME
from azext_aosm.definition_folder.builder.local_file_builder import LocalFileBuilder
Expand Down Expand Up @@ -98,8 +98,7 @@ def generate_params_schema(self) -> Dict[str, Any]:
)

params_schema = json.loads(base_params_schema)
# print(json.dumps(self.input_artifact.get_schema(), indent=4))
# print(json.dumps(self.input_artifact.get_defaults(), indent=4))

self._generate_schema(
params_schema[self.name],
self.input_artifact.get_schema(),
Expand Down Expand Up @@ -185,6 +184,20 @@ def generate_values_mappings(

# Loop through each property in the schema.
for subschema_name, subschema in schema["properties"].items():

if "type" not in subschema:
if ["oneOf", "anyOf"] in subschema:
raise InvalidArgumentValueError(
f"The subschema '{subschema_name}' does not contain a type.\n"
"It contains 'anyOf' or 'oneOf' logic, which is not valid for AOSM.\n"
"Please remove this from your values.schema.json and provide a concrete type "
"or remove the schema and the CLI will generate a generic schema."
)
raise InvalidArgumentValueError(
f"The subschema {subschema_name} does not contain a type. This is a required field.\n"
"Please fix your values.schema.json or remove the schema and the CLI will generate a "
"generic schema."
)
# If the property is not in the values, and is required, add it to the values.
if (
"required" in schema
Expand Down
Loading