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

Merge publish into temp wheel branch #131

Merged
merged 9 commits into from
Jan 17, 2024
78 changes: 7 additions & 71 deletions src/aosm/azext_aosm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,75 +49,12 @@ def load_arguments(self: AzCommandsLoader, _):
help="Also delete artifact stores, NFD Group and Publisher. Use with care.",
)
c.argument(
"definition_file",
options_list=["--definition-file", "-b"],
"build_output_folder",
options_list=["--build-output-folder", "-b"],
type=file_type,
completer=FilesCompleter(allowednames="*.json"),
help=(
"Optional path to a bicep file to publish. Use to override publish of"
" the built definition with an alternative file."
),
)
c.argument(
"design_file",
options_list=["--design-file", "-b"],
type=file_type,
completer=FilesCompleter(allowednames="*.bicep"),
help=(
"Optional path to a bicep file to publish. Use to override publish of"
" the built design with an alternative file."
),
)
c.argument(
"order_params",
arg_type=get_three_state_flag(),
help=(
"VNF definition_type only - ignored for CNF. Order deploymentParameters"
" schema and configMappings to have the parameters without default"
" values at the top and those with default values at the bottom. Can"
" make it easier to remove those with defaults which you do not want to"
" expose as NFD parameters."
),
)
c.argument(
"interactive",
options_list=["--interactive", "-i"],
arg_type=get_three_state_flag(),
help=(
"Prompt user to choose every parameter to expose as an NFD parameter."
" Those without defaults are automatically included."
),
)
c.argument(
"parameters_json_file",
options_list=["--parameters-file", "-p"],
type=file_type,
completer=FilesCompleter(allowednames="*.json"),
help=(
"Optional path to a parameters file for the bicep definition file. Use"
" to override publish of the built definition and config with"
" alternative parameters."
),
)
c.argument(
"manifest_file",
options_list=["--manifest-file", "-m"],
type=file_type,
completer=FilesCompleter(allowednames="*.json"),
help=(
"Optional path to a bicep file to publish manifests. Use to override"
" publish of the built definition with an alternative file."
),
)
c.argument(
"manifest_params_file",
options_list=["--manifest-params-file"],
type=file_type,
completer=FilesCompleter(allowednames="*.json"),
help=(
"Optional path to a parameters file for the manifest definition file."
" Use to override publish of the built definition and config with"
" alternative parameters."
"Path to the folder to publish, created by the build command."
),
)
c.argument(
Expand All @@ -135,11 +72,10 @@ def load_arguments(self: AzCommandsLoader, _):
options_list=["--no-subscription-permissions", "-u"],
arg_type=get_three_state_flag(),
help=(
"CNF definition_type publish only - ignored for VNF."
" Set to True if you do not "
"have permission to import to the Publisher subscription (Contributor "
"role + AcrPush role, or a custom role that allows the importImage "
"action and AcrPush over the "
"CNF definition_type publish only - ignored for VNF. "
"Pass this flag if you do not have permission to import to the "
"Publisher subscription (Contributor role + AcrPush role, or a "
"custom role that allows the importImage action and AcrPush over the "
"whole subscription). This means that the image artifacts will be "
"pulled to your local machine and then pushed to the Artifact Store. "
"Requires Docker to be installed locally."
Expand Down
8 changes: 3 additions & 5 deletions src/aosm/azext_aosm/build_processors/arm_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ def get_artifact_details(
return (
[
LocalFileACRArtifact(
artifact_manifest=ManifestArtifactFormat(
artifact_name=self.input_artifact.artifact_name,
artifact_type=AzureCoreArtifactType.ARM_TEMPLATE.value,
artifact_version=self.input_artifact.artifact_version,
),
artifact_name=self.input_artifact.artifact_name,
artifact_type=AzureCoreArtifactType.ARM_TEMPLATE.value,
artifact_version=self.input_artifact.artifact_version,
file_path=self.input_artifact.template_path,
)
],
Expand Down
24 changes: 10 additions & 14 deletions src/aosm/azext_aosm/build_processors/helm_chart_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,22 @@ def get_artifact_details(

# We only support local file artifacts for Helm charts
helm_chart_details = LocalFileACRArtifact(
ManifestArtifactFormat(
artifact_name=self.input_artifact.artifact_name,
artifact_type=ArtifactType.OCI_ARTIFACT.value,
artifact_version=self.input_artifact.artifact_version,
),
self.input_artifact.chart_path,
artifact_name=self.input_artifact.artifact_name,
artifact_type=ArtifactType.OCI_ARTIFACT.value,
artifact_version=self.input_artifact.artifact_version,
file_path=self.input_artifact.chart_path,
)
artifact_details.append(helm_chart_details)

print("artifact_details: ", helm_chart_details.type)
for image_name, image_version in self._find_chart_images():
# We only support remote ACR artifacts for container images
artifact_details.append(
RemoteACRArtifact(
ManifestArtifactFormat(
artifact_name=image_name,
artifact_type=ArtifactType.OCI_ARTIFACT.value,
artifact_version=image_version,
),
self.source_registry,
self.source_registry_namespace,
artifact_name=image_name,
artifact_type=ArtifactType.OCI_ARTIFACT.value,
artifact_version=image_version,
source_registry=self.source_registry,
source_registry_namespace=self.source_registry_namespace,
)
)

Expand Down
10 changes: 4 additions & 6 deletions src/aosm/azext_aosm/build_processors/nfd_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,10 @@ def get_artifact_details(
# The ARM template is written to a local file to be used as the artifact
# Path is relative to NSD_OUTPUT_FOLDER_FILENAME as this artifact is stored in the NSD output folder
artifact_details = LocalFileACRArtifact(
ManifestArtifactFormat(
artifact_name=self.input_artifact.artifact_name,
artifact_type=ArtifactType.OCI_ARTIFACT.value,
artifact_version=self.input_artifact.artifact_version,
),
self.input_artifact.arm_template_output_path.relative_to(Path(NSD_OUTPUT_FOLDER_FILENAME)),
artifact_name=self.input_artifact.artifact_name,
artifact_type=ArtifactType.OCI_ARTIFACT.value,
artifact_version=self.input_artifact.artifact_version,
file_path=self.input_artifact.arm_template_output_path.relative_to(Path(NSD_OUTPUT_FOLDER_FILENAME)),
)

# Create a local file builder for the ARM template
Expand Down
10 changes: 3 additions & 7 deletions src/aosm/azext_aosm/build_processors/vhd_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,15 @@ def get_artifact_details(
artifacts: List[BaseArtifact] = []
file_builders: List[LocalFileBuilder] = []

artifact_manifest = ManifestArtifactFormat(
artifact_name=self.input_artifact.artifact_name,
artifact_type=ArtifactType.VHD_IMAGE_FILE.value,
artifact_version=self.input_artifact.artifact_version,
)

if self.input_artifact.file_path:
logger.debug(
"VHD input has a file path. Adding LocalFileStorageAccountArtifact."
)
artifacts.append(
LocalFileStorageAccountArtifact(
artifact_manifest=artifact_manifest,
artifact_name=self.input_artifact.artifact_name,
artifact_type=ArtifactType.VHD_IMAGE_FILE.value,
artifact_version=self.input_artifact.artifact_version,
file_path=self.input_artifact.file_path,
)
)
Expand Down
33 changes: 21 additions & 12 deletions src/aosm/azext_aosm/cli_handlers/onboarding_base_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@
from jinja2 import StrictUndefined, Template
from knack.log import get_logger

from azext_aosm.common.local_file_builder import LocalFileBuilder
from azext_aosm.configuration_models.onboarding_base_input_config import (
OnboardingBaseInputConfig,
)
from azext_aosm.definition_folder.builder.definition_folder_builder import (
DefinitionFolderBuilder,
)
from azext_aosm.definition_folder.reader.definition_folder import DefinitionFolder
from azext_aosm.common.command_context import CommandContext
from azext_aosm.configuration_models.common_parameters_config import \
BaseCommonParametersConfig
from azext_aosm.configuration_models.onboarding_base_input_config import \
OnboardingBaseInputConfig
from azext_aosm.definition_folder.builder.definition_folder_builder import \
DefinitionFolderBuilder
from azext_aosm.common.local_file_builder import LocalFileBuilder
from azext_aosm.vendored_sdks import HybridNetworkManagementClient
from azext_aosm.vendored_sdks.models import \
AzureCoreNetworkFunctionVhdApplication
from azext_aosm.common.constants import DEPLOYMENT_PARAMETERS_FILENAME
logger = get_logger(__name__)

Expand All @@ -37,6 +39,7 @@ def __init__(
):
"""Initialize the CLI handler."""
self.aosm_client = aosm_client
config_file = Path(config_file)
# If config file provided (for build, publish and delete)
if config_file:
# If config file is the input.jsonc for build command
Expand Down Expand Up @@ -91,15 +94,21 @@ def build(self):
self.definition_folder_builder.add_element(self.build_all_parameters_json())
self.definition_folder_builder.write()

def publish(self):
def publish(self, command_context: CommandContext):
"""Publish the definition."""
# Takes folder, deploys to Azure
# - Work out where the definition folder is
# - If not specified, use a set path (see constants.py for directory names), and error if not found with option of moving to correct dir, or specifying path
# - If specified, use that path
# - Read folder/ create folder object
# - For each step (element):
# - Do element.deploy()
# TODO: Implement
if command_context.cli_options["definition_folder"]:
definition_folder = DefinitionFolder(
command_context.cli_options["definition_folder"]
)
# TODO: else logic for finding VNF_OUTPUT_FOLDER_FILENAME, etc., assuming command run from same directory as build.
definition_folder.deploy(config=self.config, command_context=command_context)

def delete(self):
def delete(self, command_context: CommandContext):
"""Delete the definition."""
# Takes folder, deletes to Azure
# - Read folder/ create folder object
Expand Down
2 changes: 2 additions & 0 deletions src/aosm/azext_aosm/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@


def load_command_table(self: AzCommandsLoader, _):
# TODO: think client_factory can be deleted. The handlers don't use it
with self.command_group("aosm nfd", client_factory=cf_aosm) as g:
# Add each command and bind it to a function in custom.py
g.custom_command("generate-config", "onboard_nfd_generate_config")
g.custom_command("build", "onboard_nfd_build")
g.custom_command("publish", "onboard_nfd_publish")
g.custom_command("delete", "onboard_nfd_delete")

# TODO: think client_factory can be deleted. The handlers don't use it
with self.command_group("aosm nsd", client_factory=cf_aosm) as g:
# Add each command and bind it to a function in custom.py
g.custom_command("generate-config", "onboard_nsd_generate_config")
Expand Down
Loading