Exemple #1
0
                    get_sql_elastic_pools_operations,
                    get_sql_server_azure_ad_administrators_operations,
                    get_sql_capabilities_operations)

if not supported_api_version(PROFILE_TYPE, max_api='2017-03-09-profile'):
    custom_path = 'azure.cli.command_modules.sql.custom#{}'

    ###############################################
    #                sql capabilities             #
    ###############################################

    capabilities_operations = create_service_adapter(
        'azure.mgmt.sql.operations.capabilities_operations',
        'CapabilitiesOperations')

    with ServiceGroup(__name__, get_sql_capabilities_operations,
                      capabilities_operations, custom_path) as s:
        with s.group('sql db') as c:
            c.custom_command('list-editions', 'db_list_capabilities')

        with s.group('sql elastic-pool') as c:
            c.custom_command('list-editions', 'elastic_pool_list_capabilities')

    ###############################################
    #                sql db                       #
    ###############################################

    database_operations = create_service_adapter(
        'azure.mgmt.sql.operations.databases_operations',
        'DatabasesOperations')

    with ServiceGroup(__name__, get_sql_databases_operations,
Exemple #2
0
            del artifact.status
            del artifact.deployment_status_message
            del artifact.vm_extension_status_message
            del artifact.install_time
    return artifacts


# Custom Command's service adapter
custom_operations = create_service_adapter(custom_path)

# Virtual Machine Operations Commands
virtual_machine_operations = create_service_adapter(
    mgmt_operations_path.format('virtual_machine_operations'),
    'VirtualMachineOperations')

with ServiceGroup(__name__, get_devtestlabs_virtual_machine_operation,
                  virtual_machine_operations) as s:
    with s.group('lab vm') as c:
        c.command('show', 'get_resource')
        c.command('list', 'list')
        c.command('delete', 'delete_resource')
        c.command('start', 'start')
        c.command('stop', 'stop')
        c.command('apply-artifacts', 'apply_artifacts')

# Virtual Machine Operations Custom Commands
with ServiceGroup(__name__, get_devtestlabs_virtual_machine_operation,
                  custom_operations) as s:
    with s.group('lab vm') as c:
        c.command('list', 'list_vm')

# Lab Operations Custom Commands
    get_sql_restorable_dropped_databases_operations,
    get_sql_server_keys_operations, get_sql_servers_operations,
    get_sql_server_usages_operations, get_sql_virtual_network_rules_operations)

if not supported_api_version(PROFILE_TYPE, max_api='2017-03-09-profile'):
    custom_path = 'azure.cli.command_modules.sql.custom#{}'

    ###############################################
    #                sql capabilities             #
    ###############################################

    capabilities_operations = create_service_adapter(
        'azure.mgmt.sql.operations.capabilities_operations',
        'CapabilitiesOperations')

    with ServiceGroup(__name__, get_sql_capabilities_operations,
                      capabilities_operations, custom_path) as s:
        with s.group('sql db') as c:
            c.custom_command('list-editions', 'db_list_capabilities')

        with s.group('sql elastic-pool') as c:
            c.custom_command('list-editions', 'elastic_pool_list_capabilities')

    ###############################################
    #                sql db                       #
    ###############################################

    database_operations = create_service_adapter(
        'azure.mgmt.sql.operations.databases_operations',
        'DatabasesOperations')

    with ServiceGroup(__name__, get_sql_databases_operations,
Exemple #4
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
from azure.cli.command_modules.sf._factory import cf_sf_client
from azure.cli.core.profiles import supported_api_version, PROFILE_TYPE
from azure.cli.core.sdk.util import (create_service_adapter, ServiceGroup)

if not supported_api_version(PROFILE_TYPE, max_api='2017-03-09-profile'):
    custom_path = "azure.cli.command_modules.sf.custom#{}"
    cluster_operations = create_service_adapter("azure.servicefabric",
                                                "ServiceFabricClientAPIs")

    # No client commands
    with ServiceGroup(__name__, None, None, custom_path) as sg:
        with sg.group("sf cluster") as g:
            g.custom_command("select", "sf_select")
        with sg.group("sf application") as g:
            g.custom_command("upload", "sf_upload_app")

    # Standard commands
    with ServiceGroup(__name__, cf_sf_client, cluster_operations,
                      custom_path) as sg:
        # Cluster level commands
        with sg.group("sf cluster") as cl_group:
            cl_group.command("manifest", "get_cluster_manifest")
            cl_group.command("code-version",
                             "get_provisioned_fabric_code_version_info_list")
            cl_group.command(
                "config-version",
                "get_provisioned_fabric_config_version_info_list")
Exemple #5
0
                              get_monitor_autoscale_settings_operation,
                              get_monitor_diagnostic_settings_operation,
                              get_monitor_activity_log_operation,
                              get_monitor_metric_definitions_operation,
                              get_monitor_metrics_operation)
from azure.cli.core.sdk.util import (ServiceGroup, create_service_adapter)

# MANAGEMENT COMMANDS
custom_operations = create_service_adapter(
    'azure.cli.command_modules.monitor.custom')

alert_rules_operations = create_service_adapter(
    'azure.mgmt.monitor.operations.alert_rules_operations',
    'AlertRulesOperations')

with ServiceGroup(__name__, get_monitor_alert_rules_operation,
                  alert_rules_operations) as s:
    with s.group('monitor alert-rules') as c:
        c.command('create', 'create_or_update')
        c.command('delete', 'delete')
        c.command('show', 'get')
        c.command('list', 'list_by_resource_group')
        c.generic_update_command('update', 'get', 'create_or_update')

alert_rule_incidents_operations = create_service_adapter(
    'azure.mgmt.monitor.operations.alert_rule_incidents_operations',
    'AlertRuleIncidentsOperations')

with ServiceGroup(__name__, get_monitor_alert_rule_incidents_operation,
                  alert_rule_incidents_operations) as s:
    with s.group('monitor alert-rule-incidents') as c:
        c.command('show', 'get')
Exemple #6
0
    def load_commands_from_factory(server_type, command_group_name,
                                   management_client):
        # server
        server_sa = create_service_adapter(
            'azure.mgmt.rdbms.{}.operations.servers_operations'.format(
                server_type), 'ServersOperations')

        def server_factory(args):
            return management_client(args).servers

        with ServiceGroup(__name__, server_factory, server_sa,
                          custom_path) as s:
            with s.group('{} server'.format(command_group_name)) as c:
                c.command('create', 'create_or_update')
                c.custom_command('restore', '_server_restore')
                c.command('delete', 'delete', confirmation=True)
                c.command('show', 'get')
                c.custom_command('list', '_server_list_custom_func')
                c.generic_update_command(
                    'update',
                    'get',
                    'update',
                    custom_func_name='_server_update_custom_func')

        # firewall rule
        firewall_rule_sa = create_service_adapter(
            'azure.mgmt.rdbms.{}.operations.firewall_rules_operations'.format(
                server_type), 'FirewallRulesOperations')

        def firewall_rule_factory(args):
            return management_client(args).firewall_rules

        with ServiceGroup(__name__, firewall_rule_factory, firewall_rule_sa,
                          custom_path) as s:
            with s.group(
                    '{} server firewall-rule'.format(command_group_name)) as c:
                c.command('create', 'create_or_update')
                c.command('delete', 'delete', confirmation=True)
                c.command('show', 'get')
                c.command('list', 'list_by_server')
        cli_generic_update_command(
            __name__,
            '{} server firewall-rule update'.format(command_group_name),
            firewall_rule_sa('get'),
            custom_path.format('_firewall_rule_custom_setter'),
            firewall_rule_factory,
            custom_function_op=custom_path.format(
                '_firewall_rule_update_custom_func'))

        # configuration
        configuration_sa = create_service_adapter(
            'azure.mgmt.rdbms.{}.operations.configurations_operations'.format(
                server_type), 'ConfigurationsOperations')

        def configuration_factory(args):
            return management_client(args).configurations

        with ServiceGroup(__name__, configuration_factory,
                          configuration_sa) as s:
            with s.group(
                    '{} server configuration'.format(command_group_name)) as c:
                c.command('set', 'create_or_update')
                c.command('show', 'get')
                c.command('list', 'list_by_server')

        # log_files
        log_file_sa = create_service_adapter(
            'azure.mgmt.rdbms.{}.operations.log_files_operations'.format(
                server_type), 'LogFilesOperations')

        def log_file_factory(args):
            return management_client(args).log_files

        with ServiceGroup(__name__, log_file_factory, log_file_sa,
                          custom_path) as s:
            with s.group('{} server-logs'.format(command_group_name)) as c:
                c.custom_command('list', '_list_log_files_with_filter')
                c.custom_command('download', '_download_log_files')

        # database
        database_sa = create_service_adapter(
            'azure.mgmt.rdbms.{}.operations.databases_operations'.format(
                server_type), 'DatabasesOperations')

        def database_factory(args):
            return management_client(args).databases

        with ServiceGroup(__name__, database_factory, database_sa) as s:
            with s.group('{} db'.format(command_group_name)) as c:
                # c.command('create', 'create_or_update')
                # c.command('delete', 'delete', confirmation=True)
                # c.command('show', 'get')
                c.command('list', 'list_by_server')
Exemple #7
0
    # endregion

    # region Activity Log

    monitor_command(__name__, 'monitor activity-log list',
                    custom_path + 'list_activity_log', cf_activity_log)

    # endregion

    action_group_operations = create_service_adapter(
        'azure.mgmt.monitor.operations.action_groups_operations',
        'ActionGroupsOperations')
    ag_custom_path = '.'.join(__name__.split('.')[:-1] +
                              ['action_groups']) + '#{}'

    with ServiceGroup(__name__, cf_action_groups, action_group_operations,
                      ag_custom_path) as s:
        with s.group('monitor action-group') as c:
            c.command('show', 'get', table_transformer=action_group_list_table)
            c.command('create',
                      'create_or_update',
                      table_transformer=action_group_list_table)
            c.command('delete', 'delete')
            c.command('enable-receiver',
                      'enable_receiver',
                      table_transformer=action_group_list_table)
            c.custom_command('list',
                             'list_action_groups',
                             table_transformer=action_group_list_table)
            c.generic_update_command(
                'update',
                'get',
Exemple #8
0
                               autoscale_path + 'get', autoscale_path + 'create_or_update', cf_autoscale,
                               exception_handler=monitor_exception_handler)

    # endregion

    # region Activity Log

    monitor_command(__name__, 'monitor activity-log list', custom_path + 'list_activity_log', cf_activity_log)

    # endregion

    action_group_operations = create_service_adapter(
        'azure.mgmt.monitor.operations.action_groups_operations', 'ActionGroupsOperations')
    ag_custom_path = '.'.join(__name__.split('.')[:-1] + ['action_groups']) + '#{}'

    with ServiceGroup(__name__, cf_action_groups, action_group_operations, ag_custom_path) as s:
        with s.group('monitor action-group') as c:
            c.command('show', 'get', table_transformer=action_group_list_table)
            c.command('create', 'create_or_update', table_transformer=action_group_list_table)
            c.command('delete', 'delete')
            c.command('enable-receiver', 'enable_receiver', table_transformer=action_group_list_table)
            c.custom_command('list', 'list_action_groups', table_transformer=action_group_list_table)
            c.generic_update_command('update', 'get', 'create_or_update', 'update_action_groups',
                                     setter_arg_name='action_group',
                                     table_transformer=action_group_list_table,
                                     exception_handler=monitor_exception_handler)

    activity_log_alerts_operations = create_service_adapter(
        'azure.mgmt.monitor.operations.activity_log_alerts_operations', 'ActivityLogAlertsOperations')
    ala_custom_path = '.'.join(__name__.split('.')[:-1] + ['activity_log_alerts']) + '#{}'
Exemple #9
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core.sdk.util import ServiceGroup, create_service_adapter
from ._client_factory import cf_cdn

custom_operations = 'azure.cli.command_modules.cdn.custom#{}'

mgmt_operations = create_service_adapter('azure.mgmt.cdn',
                                         'CdnManagementClient')
with ServiceGroup(__name__, cf_cdn, mgmt_operations, custom_operations) as s:
    with s.group('cdn') as c:
        c.command('name-exists', 'check_name_availability')
        c.command('usage', 'check_resource_usage')

endpoint_operations = create_service_adapter(
    'azure.mgmt.cdn.operations.endpoints_operations', 'EndpointsOperations')
with ServiceGroup(__name__, cf_cdn, endpoint_operations,
                  custom_operations) as s:
    with s.group('cdn endpoint') as c:
        for name in ['start', 'stop', 'delete']:
            c.command(name, name)
        c.command('show', 'get')
        c.command('list', 'list_by_profile')
        c.command('load', 'load_content')
        c.command('purge', 'purge_content')
        c.command('validate-custom-domain', 'validate_custom_domain')
        c.custom_command('create', 'create_endpoint')
        c.generic_update_command('update',
Exemple #10
0
from ._util import (get_sql_servers_operations,
                    get_sql_firewall_rules_operations,
                    get_sql_databases_operations,
                    get_sql_elastic_pools_operations)
from azure.cli.core.sdk.util import (create_service_adapter, ServiceGroup)

custom_path = 'azure.cli.command_modules.sql.custom#{}'

###############################################
#                sql db                       #
###############################################

database_operations = create_service_adapter(
    'azure.mgmt.sql.operations.databases_operations', 'DatabasesOperations')

with ServiceGroup(__name__, get_sql_databases_operations, database_operations,
                  custom_path) as s:
    with s.group('sql db') as c:
        c.custom_command('create', 'db_create')
        c.custom_command('copy', 'db_copy')
        c.custom_command('restore', 'db_restore')
        c.command('show', 'get')
        c.custom_command('list', 'db_list')
        # # Usages will not be included in the first batch of GA commands
        # c.command('show-usage', 'list_usages')
        c.command('delete', 'delete', confirmation=True)
        c.generic_update_command('update',
                                 'get',
                                 'create_or_update',
                                 custom_func_name='db_update')
        c.custom_command('import', 'db_import')
        c.custom_command('export', 'db_export')
Exemple #11
0
    get_sql_database_usages_operations, get_sql_elastic_pools_operations,
    get_sql_firewall_rules_operations, get_sql_replication_links_operations,
    get_sql_servers_operations, get_sql_server_usages_operations)

if not supported_api_version(PROFILE_TYPE, max_api='2017-03-09-profile'):
    custom_path = 'azure.cli.command_modules.sql.custom#{}'

    ###############################################
    #                sql capabilities             #
    ###############################################

    capabilities_operations = create_service_adapter(
        'azure.mgmt.sql.operations.capabilities_operations',
        'CapabilitiesOperations')

    with ServiceGroup(__name__, get_sql_capabilities_operations,
                      capabilities_operations, custom_path) as s:
        with s.group('sql db') as c:
            c.custom_command('list-editions', 'db_list_capabilities')

        with s.group('sql elastic-pool') as c:
            c.custom_command('list-editions', 'elastic_pool_list_capabilities')

    ###############################################
    #                sql db                       #
    ###############################################

    database_operations = create_service_adapter(
        'azure.mgmt.sql.operations.databases_operations',
        'DatabasesOperations')

    with ServiceGroup(__name__, get_sql_databases_operations,
Exemple #12
0
            raise ex

        return _inner_not_found

    not_found_msg = "{}(s) not found. Please verify the resource(s), group or it's parent resources " \
                    "exist."
    profile_not_found_msg = not_found_msg.format('Profile')
    endpoint_not_found_msg = not_found_msg.format('Endpoint')
    cd_not_found_msg = not_found_msg.format('Custom Domain')
    origin_not_found_msg = not_found_msg.format('Origin')

    custom_operations = 'azure.cli.command_modules.cdn.custom#{}'

    mgmt_operations = create_service_adapter('azure.mgmt.cdn',
                                             'CdnManagementClient')
    with ServiceGroup(__name__, cf_cdn, mgmt_operations,
                      custom_operations) as s:
        with s.group('cdn') as c:
            c.command('name-exists', 'check_name_availability')
            c.command('usage', 'check_resource_usage')

    endpoint_operations = create_service_adapter(
        'azure.mgmt.cdn.operations.endpoints_operations',
        'EndpointsOperations')
    with ServiceGroup(
            __name__,
            cf_cdn,
            endpoint_operations,
            custom_operations,
            exception_handler=_not_found(endpoint_not_found_msg)) as s:
        with s.group('cdn endpoint') as c:
            for name in ['start', 'stop', 'delete']:
Exemple #13
0
                                  cf_activity_log_alerts, cf_event_categories)
    from ._exception_handler import monitor_exception_handler, missing_resource_handler

    from .transformers import (action_group_list_table)

    def service_adapter(module_name, class_name):
        return create_service_adapter(
            'azure.mgmt.monitor.operations.{}'.format(module_name), class_name)

    def custom_path(module_name):
        return '.'.join(__name__.split('.')[:-1]) + '.operations.{}#'.format(
            module_name) + '{}'

    with ServiceGroup(
            __name__, cf_action_groups,
            service_adapter('action_groups_operations',
                            'ActionGroupsOperations'),
            custom_path('action_groups')) as s:
        with s.group('monitor action-group') as c:
            c.command('show', 'get', table_transformer=action_group_list_table)
            c.command('create',
                      'create_or_update',
                      table_transformer=action_group_list_table)
            c.command('delete', 'delete')
            c.command('enable-receiver',
                      'enable_receiver',
                      table_transformer=action_group_list_table,
                      exception_handler=monitor_exception_handler)
            c.custom_command('list',
                             'list_action_groups',
                             table_transformer=action_group_list_table)