Check available ipv6 in environment vip
178259
def check_vip_ip(self, ip, environment_vip):
        
        uri = 'api/ipv6/ip/%s/environment-vip/%s/' % (ip, environment_vip)

        return super(ApiNetworkIPv6, self).get(uri)
1142220
def get_environ(self):
        """"""
        req = self.req
        req_conn = req.conn
        env = {
            # set a non-standard environ entry so the WSGI app can know what
            # the *real* server protocol is (and what features to support).
            # See http://www.faqs.org/rfcs/rfc2145.html.
            'ACTUAL_SERVER_PROTOCOL': req.server.protocol,
            'PATH_INFO': bton(req.path),
            'QUERY_STRING': bton(req.qs),
            'REMOTE_ADDR': req_conn.remote_addr or '',
            'REMOTE_PORT': str(req_conn.remote_port or ''),
            'REQUEST_METHOD': bton(req.method),
            'REQUEST_URI': bton(req.uri),
            'SCRIPT_NAME': '',
            'SERVER_NAME': req.server.server_name,
            # Bah. "SERVER_PROTOCOL" is actually the REQUEST protocol.
            'SERVER_PROTOCOL': bton(req.request_protocol),
            'SERVER_SOFTWARE': req.server.software,
            'wsgi.errors': sys.stderr,
            'wsgi.input': req.rfile,
            'wsgi.input_terminated': bool(req.chunked_read),
            'wsgi.multiprocess': False,
            'wsgi.multithread': True,
            'wsgi.run_once': False,
            'wsgi.url_scheme': bton(req.scheme),
            'wsgi.version': self.version,
        }

        if isinstance(req.server.bind_addr, six.string_types):
            # AF_UNIX. This isn't really allowed by WSGI, which doesn't
            # address unix domain sockets. But it's better than nothing.
            env['SERVER_PORT'] = ''
            try:
                env['X_REMOTE_PID'] = str(req_conn.peer_pid)
                env['X_REMOTE_UID'] = str(req_conn.peer_uid)
                env['X_REMOTE_GID'] = str(req_conn.peer_gid)

                env['X_REMOTE_USER'] = str(req_conn.peer_user)
                env['X_REMOTE_GROUP'] = str(req_conn.peer_group)

                env['REMOTE_USER'] = env['X_REMOTE_USER']
            except RuntimeError:
                """Unable to retrieve peer creds data.

                Unsupported by current kernel or socket error happened, or
                unsupported socket type, or disabled.
                """
        else:
            env['SERVER_PORT'] = str(req.server.bind_addr[1])

        # Request headers
        env.update(
            ('HTTP_' + bton(k).upper().replace('-', '_'), bton(v))
            for k, v in req.inheaders.items()
        )

        # CONTENT_TYPE/CONTENT_LENGTH
        ct = env.pop('HTTP_CONTENT_TYPE', None)
        if ct is not None:
            env['CONTENT_TYPE'] = ct
        cl = env.pop('HTTP_CONTENT_LENGTH', None)
        if cl is not None:
            env['CONTENT_LENGTH'] = cl

        if req.conn.ssl_env:
            env.update(req.conn.ssl_env)

        return env
485530
def list_network_ip_availabilities(self, retrieve_all=True, **_params):
        """"""
        return self.list('network_ip_availabilities',
                         self.network_ip_availabilities_path,
                         retrieve_all, **_params)
375734
def _ttl(self):
        """"""
        return self.hlim if isinstance(self, scapy.layers.inet6.IPv6) else self.ttl
904538
def checkPortAvailable(ha):
    """"""
    # Not sure why OS would allow binding to one type and not other.
    # Checking for port available for TCP and UDP.
    sockTypes = (socket.SOCK_DGRAM, socket.SOCK_STREAM)
    for typ in sockTypes:
        sock = socket.socket(socket.AF_INET, typ)
        try:
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            sock.bind(ha)
            if typ == socket.SOCK_STREAM:
                l_onoff = 1
                l_linger = 0
                sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER,
                                struct.pack('ii', l_onoff, l_linger))
        except OSError as exc:
            if exc.errno in [
                errno.EADDRINUSE, errno.EADDRNOTAVAIL,
                WS_SOCKET_BIND_ERROR_ALREADY_IN_USE,
                WS_SOCKET_BIND_ERROR_NOT_AVAILABLE
            ]:
                raise PortNotAvailable(ha)
            else:
                raise exc
        finally:
            sock.close()
1151248
private static boolean anyInterfaceSupportsIpV6() {
        try {
            Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
            while (interfaces.hasMoreElements()) {
                NetworkInterface iface = interfaces.nextElement();
                Enumeration<InetAddress> addresses = iface.getInetAddresses();
                while (addresses.hasMoreElements()) {
                    if (addresses.nextElement() instanceof Inet6Address) {
                        return true;
                    }
                }
            }
        } catch (SocketException e) {
            logger.debug("Unable to detect if any interface supports IPv6, assuming IPv4-only", e);
            // ignore
        }
        return false;
    }
214681
def check_arguments(cls, conf):
        
        # Perform sanity checking on CIDR
        utils.ip_check(conf['fixed_cidr'], netmask_expected=True)

        # Perform sanity checking on host list
        for host in conf['fixed_hosts'].split(":"):
            utils.ip_check(host)
88175
def cli(env, ip_version):
    """"""

    mgr = SoftLayer.NetworkManager(env.client)

    table = formatting.Table(['id', 'ip', 'assigned', 'target'])

    version = None
    if ip_version == 'v4':
        version = 4
    elif ip_version == 'v6':
        version = 6

    ips = mgr.list_global_ips(version=version)

    for ip_address in ips:
        assigned = 'No'
        target = 'None'
        if ip_address.get('destinationIpAddress'):
            dest = ip_address['destinationIpAddress']
            assigned = 'Yes'
            target = dest['ipAddress']
            virtual_guest = dest.get('virtualGuest')
            if virtual_guest:
                target += (' (%s)'
                           % virtual_guest['fullyQualifiedDomainName'])
            elif ip_address['destinationIpAddress'].get('hardware'):
                target += (' (%s)'
                           % dest['hardware']['fullyQualifiedDomainName'])

        table.add_row([ip_address['id'],
                       ip_address['ipAddress']['ipAddress'],
                       assigned,
                       target])
    env.fout(table)
857809
private boolean checkVmIsOnline() {

		String zoneName = OpenstackIaasHandler.findZoneName( this.novaApi, this.targetProperties );
		Server server = this.novaApi.getServerApiForZone( zoneName ).get(this.machineId);
		return Status.ACTIVE.equals(server.getStatus());
	}
319984
def detect(self):
        """"""
        if self.opts_family == AF_INET6:
            kind = IPV6_PUBLIC
        else:  # 'INET':
            kind = IPV4
        theip = None
        try:
            theip = detect_ip(kind)
        except GetIpException:
            LOG.exception("socket detector raised an exception:")
        self.set_current_value(theip)
        return theip
65883
def network_details():
        
        # Get IPv4 details
        ipv4_addresses = [
            info[4][0]
            for info in socket.getaddrinfo(
                socket.gethostname(), None, socket.AF_INET
            )
        ]

        # Add localhost
        ipv4_addresses.extend(
            info[4][0]
            for info in socket.getaddrinfo("localhost", None, socket.AF_INET)
        )

        # Filter addresses
        ipv4_addresses = sorted(set(ipv4_addresses))

        try:
            # Get IPv6 details
            ipv6_addresses = [
                info[4][0]
                for info in socket.getaddrinfo(
                    socket.gethostname(), None, socket.AF_INET6
                )
            ]

            # Add localhost
            ipv6_addresses.extend(
                info[4][0]
                for info in socket.getaddrinfo(
                    "localhost", None, socket.AF_INET6
                )
            )

            # Filter addresses
            ipv6_addresses = sorted(set(ipv6_addresses))
        except (socket.gaierror, AttributeError):
            # AttributeError: AF_INET6 is missing in some versions of Python
            ipv6_addresses = None

        return {
            "IPv4": ipv4_addresses,
            "IPv6": ipv6_addresses,
            "host.name": socket.gethostname(),
            "host.fqdn": socket.getfqdn(),
        }
404686
public void expectIpv6(String name, String message) {
        String value = Optional.ofNullable(get(name)).orElse("");

        if (!InetAddressValidator.getInstance().isValidInet6Address(value)) {
            addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.IPV6_KEY.name(), name)));
        }
    }
469868
def is_reserved(self):
        
        reserved_nets = [IPv6Network('::/8'), IPv6Network('100::/8'),
                         IPv6Network('200::/7'), IPv6Network('400::/6'),
                         IPv6Network('800::/5'), IPv6Network('1000::/4'),
                         IPv6Network('4000::/3'), IPv6Network('6000::/3'),
                         IPv6Network('8000::/3'), IPv6Network('A000::/3'),
                         IPv6Network('C000::/3'), IPv6Network('E000::/4'),
                         IPv6Network('F000::/5'), IPv6Network('F800::/6'),
                         IPv6Network('FE00::/9')]

        return any(self in x for x in reserved_nets)
578486
public void expectIpv6(String name) {
        expectIpv6(name, messages.get(Validation.IPV6_KEY.name(), name));
    }
358552
def get_environ(self, sock):
        """"""
        cipher = sock.cipher()
        ssl_environ = {
            "wsgi.url_scheme": "https",
            "HTTPS": "on",
            'SSL_PROTOCOL': cipher[1],
            'SSL_CIPHER': cipher[0]
##            SSL_VERSION_INTERFACE 	string 	The mod_ssl program version
##            SSL_VERSION_LIBRARY 	string 	The OpenSSL program version
            }
        return ssl_environ
515838
def cli(env, identifier):
    """"""

    mgr = SoftLayer.NetworkManager(env.client)
    global_ip_id = helpers.resolve_id(mgr.resolve_global_ip_ids, identifier,
                                      name='global ip')
    mgr.unassign_global_ip(global_ip_id)
844448
def _in6_getifaddr(ifname):
    

    # Get the output of ifconfig
    try:
        f = os.popen("%s %s" % (conf.prog.ifconfig, ifname))
    except OSError:
        log_interactive.warning("Failed to execute ifconfig.")
        return []

    # Iterate over lines and extract IPv6 addresses
    ret = []
    for line in f:
        if "inet6" in line:
            addr = line.rstrip().split(None, 2)[1]  # The second element is the IPv6 address  # noqa: E501
        else:
            continue
        if '%' in line:  # Remove the interface identifier if present
            addr = addr.split("%", 1)[0]

        # Check if it is a valid IPv6 address
        try:
            inet_pton(socket.AF_INET6, addr)
        except (socket.error, ValueError):
            continue

        # Get the scope and keep the address
        scope = in6_getscope(addr)
        ret.append((addr, scope, ifname))

    return ret