def make_nic(context, net_name, subnet, external_ip=False):
    prop = context.properties
    network_interface = {
        'kind': 'compute#networkInterface',
        'network': common.GlobalNetworkLink(prop['project'], net_name)
    }
    if subnet:
        network_interface["subnetwork"] = common.MakeRegionalSubnetworkLink(
            prop['project'], prop['zone'], subnet)
    # add ephemeral public IP address
    if external_ip:
        network_interface["accessConfigs"] = \
            [make_access_config(name="external-nat")]
    return network_interface
Esempio n. 2
0
def make_nic(prop, net_name, zone_name, subnet_name, externalIP=False):
    network_interface = {
        'kind':
        'compute#networkInterface',
        'network':
        common.GlobalNetworkLink(prop['project'], net_name),
        'subnetwork':
        common.MakeRegionalSubnetworkLink(prop['project'], zone_name,
                                          subnet_name)
    }
    # add ephemeral public IP address
    if externalIP:
        network_interface["accessConfigs"] = [
            make_access_config(name="external-nat")
        ]
    return network_interface