Adding an open, unsecured network
487334
private static void changeNetworkUnEncrypted(WifiManager wifiManager, WifiParsedResult wifiResult) {
    WifiConfiguration config = changeNetworkCommon(wifiResult);
    config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
    updateNetwork(wifiManager, config);
  }
884240
def open(
        self,
        hostname: Optional[str],
        username: Optional[str],
        password: Optional[str],
        port: Optional[int],
        platform: Optional[str],
        extras: Optional[Dict[str, Any]] = None,
        configuration: Optional[Config] = None,
    ) -> None:
        
        pass
1313454
def add_nic(self, instance_id, net_id):
        """"""
        #TODO: upgrade with port_id and fixed_ip in future
        self.client.servers.interface_attach(
            instance_id, None, net_id, None)
        return True
661562
def add(env, securitygroup_id, network_component, server, interface):
    """"""
    _validate_args(network_component, server, interface)

    mgr = SoftLayer.NetworkManager(env.client)
    component_id = _get_component_id(env, network_component, server, interface)

    ret = mgr.attach_securitygroup_component(securitygroup_id,
                                             component_id)
    if not ret:
        raise exceptions.CLIAbort("Could not attach network component")

    table = formatting.Table(REQUEST_COLUMNS)
    table.add_row([ret['requestId']])

    env.fout(table)
915128
def create_api_network_ipv4(self):
        """"""

        return ApiNetworkIPv4(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
1139482
def nginx(ctx, hostname):
    """"""

    install_nginx(ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port'], hostname)
819857
def add_network_to_dhcp_agent(self, dhcp_agent, body=None):
        """"""
        return self.post((self.agent_path + self.DHCP_NETS) % dhcp_agent,
                         body=body)
999568
def router_added_to_hosting_device(self, context, router):
        """"""
        self._notification(context, 'router_added_to_hosting_device',
                           [router], operation=None, shuffle_agents=False)
885634
def create_network(userid, os_version, network_info):
    
    print("\nConfiguring network interface for %s ..." % userid)
    network_create_info = client.send_request('guest_create_network_interface', 
                                              userid, os_version, network_info)

    if network_create_info['overallRC']:
        raise RuntimeError("Failed to create network for guest %s!\n%s" % 
                           (userid, network_create_info))
    else:
        print("Succeeded to create network for guest %s!" % userid)
621721
def add_hostname_cn(self):
        """"""
        ip = unit_get('private-address')
        addresses = [ip]
        # If a vip is being used without os-hostname config or
        # network spaces then we need to ensure the local units
        # cert has the approriate vip in the SAN list
        vip = get_vip_in_network(resolve_network_cidr(ip))
        if vip:
            addresses.append(vip)
        self.hostname_entry = {
            'cn': get_hostname(ip),
            'addresses': addresses}
1090454
def samba():
    '''
    '''
    username = env.user
    install_packages(['samba'])
    run(flo('sudo smbpasswd -a {username}'))

    path = '$HOME/shared'
    sharename = 'shared'
    comment = '"smb share; everyone has full access (read/write)"'
    acl = flo('Everyone:F,{username}:F guest_ok=y')

    with warn_only():
        run(flo('mkdir {path}'))
    run(flo('sudo net usershare add {sharename} {path} {comment} {acl}'))
    run(flo('sudo net usershare info {sharename}'))
936796
def open(self, *args, **kwargs):
        
        Telnet.open(self, *args, **kwargs)
        if self.force_ssl:
            self._start_tls()
1304042
def create_security_group(self, name, desc=None):
        '''
        
        '''
        body = {'security_group': {'name': name,
                                   'description': desc}}
        return self.network_conn.create_security_group(body=body)
630618
def _build_con_add_cmd(ssid: str, security_type: SECURITY_TYPES,
                       psk: Optional[str], hidden: bool,
                       eap_args: Optional[Dict[str, Any]]) -> List[str]:
    
    configure_cmd = ['connection', 'add',
                     'save', 'yes',
                     'autoconnect', 'yes',
                     'ifname', 'wlan0',
                     'type', 'wifi',
                     'con-name', ssid,
                     'wifi.ssid', ssid]
    if hidden:
        configure_cmd += ['wifi.hidden', 'true']
    if security_type == SECURITY_TYPES.WPA_PSK:
        configure_cmd += ['wifi-sec.key-mgmt', security_type.value]
        if psk is None:
            raise ValueError('wpa-psk security type requires psk')
        configure_cmd += ['wifi-sec.psk', psk]
    elif security_type == SECURITY_TYPES.WPA_EAP:
        if eap_args is None:
            raise ValueError('wpa-eap security type requires eap_args')
        configure_cmd += _add_eap_args(eap_args)
    elif security_type == SECURITY_TYPES.NONE:
        pass
    else:
        raise ValueError("Bad security_type {}".format(security_type))

    return configure_cmd
653580
def setup(addr, user, remote_path, local_key=None):
    """"""
    port = find_port(addr, user)

    if not port or not is_alive(addr, user):
        port = new_port()

        scp(addr, user, __file__, '~/unixpipe', local_key)

        ssh_call = ['ssh', '-fL%d:127.0.0.1:12042' % port,
                    '-o', 'ExitOnForwardFailure=yes',
                    '-o', 'ControlPath=~/.ssh/unixpipe_%%r@%%h_%d' % port,
                    '-o', 'ControlMaster=auto',
                    '%s@%s' % (user, addr,), 'python', '~/unixpipe',
                    'server', remote_path]
        if local_key:
            ssh_call.insert(1, local_key)
            ssh_call.insert(1, '-i')

        subprocess.call(ssh_call)
        # XXX Sleep is a bad way to wait for the tunnel endpoint
        time.sleep(1)

    return port
497077
def _create_network_interface(
        self, ip_config_name, nic_name, public_ip, region,
        resource_group_name, subnet, accelerated_networking=False
    ):
        
        nic_config = {
            'location': region,
            'ip_configurations': [{
                'name': ip_config_name,
                'private_ip_allocation_method': 'Dynamic',
                'subnet': {
                    'id': subnet.id
                },
                'public_ip_address': {
                    'id': public_ip.id
                },
            }]
        }

        if accelerated_networking:
            nic_config['enable_accelerated_networking'] = True

        try:
            nic_setup = self.network.network_interfaces.create_or_update(
                resource_group_name, nic_name, nic_config
            )
        except Exception as error:
            raise AzureCloudException(
                'Unable to create network interface: {0}.'.format(
                    error
                )
            )

        return nic_setup.result()
265699
function buildNatSecurityGroup(subnets = [], { name = 'NatSecurityGroup' } = {}) {
  const SecurityGroupIngress = [];

  if (Array.isArray(subnets) && subnets.length > 0) {
    subnets.forEach((subnet, index) => {
      const position = index + 1;

      const http = {
        Description: `Allow inbound HTTP traffic from ${APP_SUBNET}Subnet${position}`,
        IpProtocol: 'tcp',
        FromPort: 80,
        ToPort: 80,
        CidrIp: subnet,
      };
      const https = {
        Description: `Allow inbound HTTPS traffic from ${APP_SUBNET}Subnet${position}`,
        IpProtocol: 'tcp',
        FromPort: 443,
        ToPort: 443,
        CidrIp: subnet,
      };
      SecurityGroupIngress.push(http, https);
    });
  }

  return {
    [name]: {
      Type: 'AWS::EC2::SecurityGroup',
      Properties: {
        GroupDescription: 'NAT Instance',
        VpcId: {
          Ref: 'VPC',
        },
        SecurityGroupEgress: [
          {
            Description: 'Allow outbound HTTP access to the Internet',
            IpProtocol: 'tcp',
            FromPort: 80,
            ToPort: 80,
            CidrIp: '0.0.0.0/0',
          },
          {
            Description: 'Allow outbound HTTPS access to the Internet',
            IpProtocol: 'tcp',
            FromPort: 443,
            ToPort: 443,
            CidrIp: '0.0.0.0/0',
          },
        ],
        SecurityGroupIngress,
        Tags: [
          {
            Key: 'Name',
            Value: {
              'Fn::Join': [
                '-',
                [
                  {
                    Ref: 'AWS::StackName',
                  },
                  'nat',
                ],
              ],
            },
          },
        ],
      },
    },
  };
}