Пример #1
0
def build_output_deployment_resource(key,
                                     property_name,
                                     property_provider,
                                     property_type,
                                     parent_name=None,
                                     output_type='object',
                                     path=None):
    from azure.cli.command_modules.vm._vm_utils import random_string
    output_tb = ArmTemplateBuilder()
    output_tb.add_output(key,
                         property_name,
                         property_provider,
                         property_type,
                         output_type=output_type,
                         path=path)
    output_template = output_tb.build()

    deployment_name = '{}_{}'.format(property_name, random_string(16))
    deployment = {
        'name': deployment_name,
        'type': 'Microsoft.Resources/deployments',
        'apiVersion': '2015-01-01',
        'properties': {
            'mode': 'Incremental',
            'template': output_template,
        }
    }
    deployment['dependsOn'] = [] if not parent_name \
        else ['Microsoft.Resources/deployments/{}'.format(parent_name)]

    return deployment
Пример #2
0
def validate_nsg_name(namespace):
    namespace.network_security_group_name = namespace.network_security_group_name \
        or '{}_NSG_{}'.format(namespace.vm_name, random_string(8))