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

[Automanage] #5404

Merged
merged 33 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b300765
automanage init
calvinhzy Sep 29, 2022
9000d27
start tests
calvinhzy Sep 29, 2022
bab92cd
test
calvinhzy Sep 30, 2022
d3638c5
add empty --configuration to automanage configuration-profile create
calvinhzy Oct 4, 2022
41bd09a
add configuration-profile tests, test for version is N/A because of s…
calvinhzy Oct 4, 2022
718a24e
rerun tests
calvinhzy Oct 6, 2022
b5a86b0
configuration as dict of strings
calvinhzy Oct 8, 2022
ae693cc
configuration profile assignment for vm
calvinhzy Oct 9, 2022
e15dee4
configuration profile assignment for arc, test failing
calvinhzy Oct 13, 2022
88647c8
freeformdict for configuration
calvinhzy Oct 18, 2022
712a1bd
lint
calvinhzy Oct 25, 2022
466f173
run arc test(needed role assignment)
calvinhzy Oct 25, 2022
f90624c
add cluster test
calvinhzy Oct 25, 2022
5ed6821
split up assignment reports
calvinhzy Oct 27, 2022
e3a444b
no longer flatten report response
calvinhzy Oct 28, 2022
dd304e1
move report into each type of assignment
calvinhzy Oct 28, 2022
3024856
fix arg len
calvinhzy Oct 28, 2022
9c8b940
add test for assignment report
calvinhzy Oct 31, 2022
a1aa49a
rerun tests, lint
calvinhzy Oct 31, 2022
95d8bc7
Merge remote-tracking branch 'upstream/main' into automanage
calvinhzy Oct 31, 2022
f5af459
vm create --generate-ssh-keys
calvinhzy Oct 31, 2022
886bd7d
make test record-only
calvinhzy Oct 31, 2022
b00b159
make test record-only
calvinhzy Nov 1, 2022
f2e091a
rerun aazdev and rerun test
calvinhzy Nov 18, 2022
bc8de47
latest swagger and rerun test
calvinhzy Nov 18, 2022
db49024
rerun azdev
calvinhzy Jan 20, 2023
2224063
server errors all fixed.
calvinhzy Jan 20, 2023
f4b6301
rerun all tests
calvinhzy Jan 20, 2023
5a783de
Merge remote-tracking branch 'upstream/main' into automanage
calvinhzy Jan 20, 2023
dab9054
record only
calvinhzy Jan 20, 2023
463fb3c
add examples
calvinhzy Jan 20, 2023
68f545a
remove test which relying on other extensions
calvinhzy Jan 20, 2023
bfcb753
add readme example
calvinhzy Jan 20, 2023
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,5 @@
/src/billing-benefits/ @gaoyp830 @rkapso @msft-adrianma @sornaks

/src/mobile-network/ @jsntcy

/src/automanage/ @calvinhzy
8 changes: 8 additions & 0 deletions src/automanage/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:
Release History
===============

0.1.0
++++++
* Initial release.
39 changes: 39 additions & 0 deletions src/automanage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Azure CLI Automanage Extension #
This is an extension to Azure CLI to manage Automanage resources.

## How to use ##
# configuration-profile
Create a configuration-profile
`az automanage configuration-profile create -n {profile_name} -g {rg} --configuration {"Antimalware/Enable":false,"Backup/Enable":false,"VMInsights/Enable":true,"AzureSecurityCenter/Enable":true,"UpdateManagement/Enable":true,"ChangeTrackingAndInventory/Enable":true,"GuestConfiguration/Enable":true,"LogAnalytics/Enable":true,"BootDiagnostics/Enable":true}`

Show a configuration-profile
`az automanage configuration-profile show -n {profile_name} -g {rg}`

Update a configuration-profile
`az automanage configuration-profile update -n {profile_name} -g {rg} --configuration {"Antimalware/Enable":true,"VMInsights/Enable":false}`

List configuration-profiles
`az automanage configuration-profile list -g {rg}`

Delete a configuration-profile
`az automanage configuration-profile delete -n {profile_name} -g {rg}`

# configuration-profile-assignment
Create a configuration-profile-assignment for vm
`az automanage configuration-profile-assignment vm create -n default -g {rg} --vm-name {vm_name} --configuration-profile {profile_id}`

Show a configuration-profile-assignment for vm
`az automanage configuration-profile-assignment vm show -n default -g {rg} --vm-name {vm_name}`

Update a configuration-profile-assignment for vm
`az automanage configuration-profile-assignment vm update --n default -g {rg} --vm-name {vm_name} --configuration-profile {profile_id_2}`

Delete configuration-profile-assignment for vm
`az automanage configuration-profile-assignment vm delete -n default -g {rg} --vm-name {vm_name}`

Create a configuration-profile-assignment for arc
`az automanage configuration-profile-assignment arc create -n default -g {rg} --machine-name {arc_name} --configuration-profile {profile_id}`

# configuration-profile-assignment report
List configuration-profile-assignment report for vm
`az automanage configuration-profile-assignment vm report list --assignment-name default -g {rg} --vm-name {vm_name}`
42 changes: 42 additions & 0 deletions src/automanage/azext_automanage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader
from azext_automanage._help import helps # pylint: disable=unused-import


class AutomanageCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
custom_command_type = CliCommandType(
operations_tmpl='azext_automanage.custom#{}')
super().__init__(cli_ctx=cli_ctx,
custom_command_type=custom_command_type)

def load_command_table(self, args):
from azext_automanage.commands import load_command_table
from azure.cli.core.aaz import load_aaz_command_table
try:
from . import aaz
except ImportError:
aaz = None
if aaz:
load_aaz_command_table(
loader=self,
aaz_pkg_name=aaz.__name__,
args=args
)
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azext_automanage._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = AutomanageCommandsLoader
11 changes: 11 additions & 0 deletions src/automanage/azext_automanage/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long
# pylint: disable=too-many-lines

from knack.help_files import helps # pylint: disable=unused-import
13 changes: 13 additions & 0 deletions src/automanage/azext_automanage/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: disable=too-many-lines
# pylint: disable=too-many-statements


def load_arguments(self, _): # pylint: disable=unused-argument
pass
6 changes: 6 additions & 0 deletions src/automanage/azext_automanage/aaz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------
6 changes: 6 additions & 0 deletions src/automanage/azext_automanage/aaz/latest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"automanage",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Automanage
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"automanage best-practice",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Automanage best practice
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._list import *
from ._show import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command(
"automanage best-practice list",
)
class List(AAZCommand):
"""List Automanage best practices

:example: List best practices
az automanage best-practice list
"""

_aaz_info = {
"version": "2022-05-04",
"resources": [
["mgmt-plane", "/providers/microsoft.automanage/bestpractices", "2022-05-04"],
]
}

def _handler(self, command_args):
super()._handler(command_args)
self._execute_operations()
return self._output()

def _execute_operations(self):
self.pre_operations()
self.BestPracticesListByTenant(ctx=self.ctx)()
self.post_operations()

@register_callback
def pre_operations(self):
pass

@register_callback
def post_operations(self):
pass

def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True)
return result

class BestPracticesListByTenant(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
request = self.make_request()
session = self.client.send_request(request=request, stream=False, **kwargs)
if session.http_response.status_code in [200]:
return self.on_200(session)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/providers/Microsoft.Automanage/bestPractices",
**self.url_parameters
)

@property
def method(self):
return "GET"

@property
def error_format(self):
return "MgmtErrorFormat"

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2022-05-04",
required=True,
),
}
return parameters

@property
def header_parameters(self):
parameters = {
**self.serialize_header_param(
"Accept", "application/json",
),
}
return parameters

def on_200(self, session):
data = self.deserialize_http_content(session)
self.ctx.set_var(
"instance",
data,
schema_builder=self._build_schema_on_200
)

_schema_on_200 = None

@classmethod
def _build_schema_on_200(cls):
if cls._schema_on_200 is not None:
return cls._schema_on_200

cls._schema_on_200 = AAZObjectType()

_schema_on_200 = cls._schema_on_200
_schema_on_200.value = AAZListType()

value = cls._schema_on_200.value
value.Element = AAZObjectType()

_element = cls._schema_on_200.value.Element
_element.id = AAZStrType(
flags={"read_only": True},
)
_element.name = AAZStrType(
flags={"read_only": True},
)
_element.properties = AAZObjectType()
_element.system_data = AAZObjectType(
serialized_name="systemData",
flags={"read_only": True},
)
_element.type = AAZStrType(
flags={"read_only": True},
)

properties = cls._schema_on_200.value.Element.properties
properties.configuration = AAZFreeFormDictType()

system_data = cls._schema_on_200.value.Element.system_data
system_data.created_at = AAZStrType(
serialized_name="createdAt",
)
system_data.created_by = AAZStrType(
serialized_name="createdBy",
)
system_data.created_by_type = AAZStrType(
serialized_name="createdByType",
)
system_data.last_modified_at = AAZStrType(
serialized_name="lastModifiedAt",
)
system_data.last_modified_by = AAZStrType(
serialized_name="lastModifiedBy",
)
system_data.last_modified_by_type = AAZStrType(
serialized_name="lastModifiedByType",
)

return cls._schema_on_200


class _ListHelper:
"""Helper class for List"""


__all__ = ["List"]
Loading