Assigns a Floating IP to a Droplet.
483255
def assign_floating_ip(self, ip_addr, droplet_id):
        
        if self.api_version == 2:
            params = {'type': 'assign','droplet_id': droplet_id}

            json = self.request('/floating_ips/' + ip_addr + '/actions', params=params, method='POST')
            return json['action']
        else:
            raise DoError(v2_api_required_str)
845726
def convert_to_ip(self):
        """"""
        self._values, self._header._unit = self._header.data_type.to_ip(
                self._values, self._header.unit)
550177
protected synchronized void dropClient(ClientImpl clientToDrop) {
        Client currentClient = this.client.get();
        if (currentClient != null && currentClient == clientToDrop) {
            try {
                currentClient.close();
                this.client.set(null);
            }
            catch (Exception x) {
                // ignore
            }
        }
        this.users = 0;
    }
774894
def create_private_ip(linode_id):
    
    '''
    kwargs = {'LinodeID': linode_id}
    result = _query('linode', 'ip.addprivate', args=kwargs)

    return _clean_data(result)
670798
static function sp($ip = null) {return dfcf(function($ip = null) {return new self([
		self::$P__IP => $ip ?: df_visitor_ip()
	]);}, [$ip]);}
687682
def pack_ip_addr(addr):
    """"""
    addr, port = addr
    return socket.inet_aton(addr) + struct.pack('!H', port & _short_mask)
965100
def to_ip(self, values, from_unit):
        """"""
        if from_unit == 'Btu/h-ft2-F':
            return values, from_unit
        else:
            return self.to_unit(values, 'Btu/h-ft2-F', from_unit), 'Btu/h-ft2-F'
513616
def allocate_ip_for_subnet(self, subnet_id, mac, port_id):
        """"""
        # Get an available IP and mark it as used before someone else does
        # If there's no IP, , log it and return an error
        # If we successfully get an IP, create a port with the specified MAC and device data
        # If port creation fails, deallocate the IP
        subnet = self.get_subnet(subnet_id)
        ip, mask, port_id = self.a10_allocate_ip_from_dhcp_range(subnet, "vlan", mac, port_id)
        return ip, mask, port_id
1021959
@Override
  public FloatingIPs getAvailableFloatingIPs(Integer pageNo, Integer perPage)
      throws DigitalOceanException, RequestUnsuccessfulException {
    validatePageNo(pageNo);

    return (FloatingIPs) perform(new ApiRequest(ApiAction.FLOATING_IPS, pageNo, perPage)).getData();
  }
391118
protected function setmyip() {
    // BLP 2018-07-02 -- replace old logic with 'isMe()'
    
    if($this->isMe()) {
      return;
    }
    
    $this->query("select count(*) from information_schema.tables ".
                 "where (table_schema = '$this->masterdb') and (table_name = 'myip')");

    list($ok) = $this->fetchrow('num');

    if($ok == 0) {
      $this->debug("$this->siteName: $this->self: table myip does not exist in the $this->masterdb database");
      return;
    }

    $this->query("insert ignore into $this->masterdb.myip values('$ip', now())");
  }
1030568
static void updateNetworkVariables( Map<String,String> instanceExports, String ipAddress ) {

		// Find the keys to update ( xxx.ip )
		Set<String> keysToUpdate = new HashSet<> ();
		for( Map.Entry<String,String> entry : instanceExports.entrySet()) {
			String suffix = parseVariableName( entry.getKey()).getValue();
			if( Constants.SPECIFIC_VARIABLE_IP.equalsIgnoreCase( suffix ))
				keysToUpdate.add( entry.getKey());
		}

		// Update them
		for( String key : keysToUpdate )
			instanceExports.put( key, ipAddress );
	}
60738
def inet_ntop(af, addr):
    """"""
    if af == socket.AF_INET:
        return inet_ntoa(addr)
    elif af == socket.AF_INET6:
        # IPv6 addresses have 128bits (16 bytes)
        if len(addr) != 16:
            raise Exception("Illegal syntax for IP address")
        parts = []
        for left in [0, 2, 4, 6, 8, 10, 12, 14]:
            try: 
                value = struct.unpack("!H", addr[left:left+2])[0]
                hexstr = hex(value)[2:]
            except TypeError:
                raise Exception("Illegal syntax for IP address")
            parts.append(hexstr.lstrip("0").lower())
        result = b":".join(parts)
        while b":::" in result:
            result = result.replace(b":::", b"::")
        # Leaving out leading and trailing zeros is only allowed with ::
        if result.endswith(b":") and not result.endswith(b"::"):
            result = result + b"0"
        if result.startswith(b":") and not result.startswith(b"::"):
            result = b"0" + result
        return result
    else:
        raise Exception("Address family not supported yet")
1265554
public void setFloat(int index, float value)
    {
        checkIndexLength(index, SizeOf.SIZE_OF_FLOAT);
        unsafe.putFloat(base, address + index, value);
    }
993131
private function setIp()
    {
        if (class_exists($Ip = 'Josantonius\Ip\Ip')) {
            $ip = $Ip::get();
            $this->setOption('IP', ($ip) ? $ip : 'unknown');
        }
    }
1246675
def associate_public_ip(self, instance_id, public_ip_id, private_ip=None):
        """"""
        return self.driver.associate_public_ip(
            instance_id, public_ip_id, private_ip)
84429
public function setIPId(int $nb_ip_id) : CNabuDataObject
    {
        if ($nb_ip_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_ip_id")
            );
        }
        $this->setValue('nb_ip_id', $nb_ip_id);
        
        return $this;
    }
387331
private void heapifyUp(int i)
    {
        int iP = parent(i);
        while(i != 0 && cmp(i, iP) < 0)//Should not be greater then our parent
        {
            swapHeapValues(iP, i);
            i = iP;
            iP = parent(i);
        }
    }