예제 #1
0
def get_connected_nsg():
    '''Finds a connected Network Security Group'''
    nsg = None
    nsg_name = None
    for rel in ctx.instance.relationships:
        if constants.REL_NIC_CONNECTED_TO_NSG in rel.type_hierarchy:
            nsg = NetworkSecurityGroup(_ctx=rel.target)
            nsg_name = utils.get_resource_name(rel.target)
    return {
        'id':
        '/subscriptions/{0}{1}/{2}'.format(
            utils.get_subscription_id(_ctx=nsg.ctx), nsg.endpoint, nsg_name)
    } if nsg else None
def get_connected_nsg():
    '''Finds a connected Network Security Group'''
    nsg = None
    nsg_name = None
    for rel in ctx.instance.relationships:
        if constants.REL_NIC_CONNECTED_TO_NSG in rel.type_hierarchy:
            nsg = NetworkSecurityGroup(_ctx=rel.target)
            nsg_name = utils.get_resource_name(rel.target)
    return {
        'id': '/subscriptions/{0}{1}/{2}'.format(
            utils.get_subscription_id(_ctx=nsg.ctx),
            nsg.endpoint,
            nsg_name)
    } if nsg else None
예제 #3
0
def attach_network_security_group(**_):
    '''Attaches a Network Security Group (source) to the Subnet (target)'''
    nsg = NetworkSecurityGroup(_ctx=ctx.source)
    nsg_name = utils.get_resource_name(ctx.source)
    # Attach
    utils.task_resource_update(Subnet(_ctx=ctx.target), {
        'properties': {
            'networkSecurityGroup': {
                'id':
                '/subscriptions/{0}{1}/{2}'.format(
                    utils.get_subscription_id(_ctx=ctx.source), nsg.endpoint,
                    nsg_name)
            }
        }
    },
                               _ctx=ctx.target)
예제 #4
0
def attach_route_table(**_):
    '''Attaches a Route Table (source) to the Subnet (target)'''
    rtbl = RouteTable(_ctx=ctx.source)
    rtbl_name = utils.get_resource_name(ctx.source)
    # Attach
    utils.task_resource_update(Subnet(_ctx=ctx.target), {
        'properties': {
            'routeTable': {
                'id':
                '/subscriptions/{0}{1}/{2}'.format(
                    utils.get_subscription_id(_ctx=ctx.source), rtbl.endpoint,
                    rtbl_name)
            }
        }
    },
                               _ctx=ctx.target)
예제 #5
0
def attach_network_security_group(**_):
    '''Attaches a Network Security Group (source) to the Subnet (target)'''
    nsg = NetworkSecurityGroup(_ctx=ctx.source)
    nsg_name = utils.get_resource_name(ctx.source)
    # Attach
    utils.task_resource_update(
        Subnet(_ctx=ctx.target), {
            'properties': {
                'networkSecurityGroup': {
                    'id': '/subscriptions/{0}{1}/{2}'.format(
                        utils.get_subscription_id(_ctx=ctx.source),
                        nsg.endpoint,
                        nsg_name)
                }
            }
        }, _ctx=ctx.target)
예제 #6
0
def attach_route_table(**_):
    '''Attaches a Route Table (source) to the Subnet (target)'''
    rtbl = RouteTable(_ctx=ctx.source)
    rtbl_name = utils.get_resource_name(ctx.source)
    # Attach
    utils.task_resource_update(
        Subnet(_ctx=ctx.target), {
            'properties': {
                'routeTable': {
                    'id': '/subscriptions/{0}{1}/{2}'.format(
                        utils.get_subscription_id(_ctx=ctx.source),
                        rtbl.endpoint,
                        rtbl_name)
                }
            }
        }, _ctx=ctx.target)