forked from Azure/azure-cli-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure#1 from jddarby/sunny/vnf-definition
VNF NFD generator
- Loading branch information
Showing
7 changed files
with
139 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
"""Constants used across aosm cli extension.""" | ||
|
||
# The types of definition that can be generated | ||
VNF = "vnf" | ||
CNF = "cnf" | ||
NSD = "nsd" | ||
|
||
# Artifact Types | ||
VHD_ARTIFACT = "VhdImageFile" | ||
ARM_TEMPLATE_ARTIFACT = "ArmTemplate" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT | ||
# License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------- | ||
"""Contains a class for generating VNF NFDs and associated resources.""" | ||
from typing import Dict, Any | ||
from .nfd_generator_base import NFDGenerator | ||
|
||
class CnfNfdGenerator(NFDGenerator): | ||
"""_summary_ | ||
:param NFDGenerator: _description_ | ||
:type NFDGenerator: _type_ | ||
""" | ||
def __init__( | ||
self, | ||
config: Dict[Any, Any] | ||
): | ||
super(NFDGenerator, self).__init__( | ||
config=config, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT | ||
# License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------- | ||
"""Contains a base class for generating NFDs.""" | ||
from typing import Dict, Any | ||
from knack.log import get_logger | ||
logger = get_logger(__name__) | ||
|
||
class NFDGenerator: | ||
"""A class for generating an NFD from a config file.""" | ||
|
||
def __init__( | ||
self, | ||
config: Dict[Any, Any] | ||
) -> None: | ||
"""_summary_ | ||
:param definition_type: _description_ | ||
:type definition_type: str | ||
:param config: _description_ | ||
:type config: Dict[Any, Any] | ||
""" | ||
self.config = config | ||
|
||
def generate_nfd(self) -> None: | ||
"""No-op on base class | ||
""" | ||
logger.error("Generate NFD called on base class. No-op") | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# -------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT | ||
# License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------- | ||
"""Contains a class for generating VNF NFDs and associated resources.""" | ||
from typing import Dict, Any | ||
from .nfd_generator_base import NFDGenerator | ||
from knack.log import get_logger | ||
from azext_aosm.vendored_sdks import HybridNetworkManagementClient | ||
from azext_aosm.vendored_sdks.models import Publisher, NetworkFunctionDefinitionVersion, NetworkFunctionDefinitionGroup, ArtifactManifest, ManifestArtifactFormat | ||
from azext_aosm._constants import VHD_ARTIFACT, ARM_TEMPLATE_ARTIFACT | ||
|
||
|
||
logger = get_logger(__name__) | ||
|
||
class VnfNfdGenerator(NFDGenerator): | ||
"""_summary_ | ||
:param NFDGenerator: _description_ | ||
:type NFDGenerator: _type_ | ||
""" | ||
def __init__( | ||
self, | ||
config: Dict[Any, Any] | ||
): | ||
super(NFDGenerator, self).__init__( | ||
config=config, | ||
) | ||
|
||
def generate_nfd(self) -> None: | ||
"""Generate a VNF NFD which comprises an group, an Artifact Manifest and a NFDV. | ||
""" | ||
arty_manny_sa = ArtifactManifest(location="blah", | ||
tags={"blah": "blah"}, | ||
artifacts=[ManifestArtifactFormat(artifact_name="blah", | ||
artifact_type=VHD_ARTIFACT, | ||
artifact_version="blah")]) | ||
|
||
arty_manny_acr = ArtifactManifest(location="blah", | ||
tags={"blah": "blah"}, | ||
artifacts=[ManifestArtifactFormat(artifact_name="blah", | ||
artifact_type=ARM_TEMPLATE_ARTIFACT, | ||
artifact_version="blah")]) | ||
|
||
|
||
|
||
|