Return a DHT platform interface for the currently detected platform.
350232
def get_platform():
    """"""
    plat = platform_detect.platform_detect()
    if plat == platform_detect.RASPBERRY_PI:
        # Check for version 1 or 2 of the pi.
        version = platform_detect.pi_version()
        if version == 1:
            from . import Raspberry_Pi
            return Raspberry_Pi
        elif version == 2:
            from . import Raspberry_Pi_2
            return Raspberry_Pi_2
        elif version == 3:
            """Use Pi 2 driver even though running on Pi 3"""
            from . import Raspberry_Pi_2
            return Raspberry_Pi_2
        else:
            raise RuntimeError('No driver for detected Raspberry Pi version available!')
    elif plat == platform_detect.BEAGLEBONE_BLACK:
        from . import Beaglebone_Black
        return Beaglebone_Black
    else:
        raise RuntimeError('Unknown platform.')
897095
def ip_interfaces():
    '''
    
    '''
    # Provides:
    #   ip_interfaces

    if salt.utils.platform.is_proxy():
        return {}

    ret = {}
    ifaces = _get_interfaces()
    for face in ifaces:
        iface_ips = []
        for inet in ifaces[face].get('inet', []):
            if 'address' in inet:
                iface_ips.append(inet['address'])
        for inet in ifaces[face].get('inet6', []):
            if 'address' in inet:
                iface_ips.append(inet['address'])
        for secondary in ifaces[face].get('secondary', []):
            if 'address' in secondary:
                iface_ips.append(secondary['address'])
        ret[face] = iface_ips
    return {'ip_interfaces': ret}
278235
def select_ip_version(host, port):
    """"""
    # disabled due to problems with current ipv6 implementations
    # and various operating systems.  Probably this code also is
    # not supposed to work, but I can't come up with any other
    # ways to implement this.
    ##try:
    ##    info = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
    ##                              socket.SOCK_STREAM, 0,
    ##                              socket.AI_PASSIVE)
    ##    if info:
    ##        return info[0][0]
    ##except socket.gaierror:
    ##    pass
    if ':' in host and hasattr(socket, 'AF_INET6'):
        return socket.AF_INET6
    return socket.AF_INET
635812
def facilityMsToNet(SsVersionIndicator_presence=0):
    """"""
    a = TpPd(pd=0x3)
    b = MessageType(mesType=0x3a)  # 00111010
    c = Facility()
    packet = a / b / c
    if SsVersionIndicator_presence is 1:
        d = SsVersionIndicatorHdr(ieiSVI=0x7F, eightBitSVI=0x0)
        packet = packet / d
    return packet
841233
def Platform(name = platform_default()):
    
    module = platform_module(name)
    spec = PlatformSpec(name, module.generate)
    return spec
114255
protected function platform()
    {
        if (! $this->platform )
            $this->platform = new PlatformRest;


        # Default Options Overriding
        $this->platform->setServerUrl( $this->serverUrl );

        return $this->platform;
    }
450290
def get_canonical_host(self):
        
        host = self.host.lower()
        if self.port is not None:
            host = "%s:%s" % (host, self.port)
        return host
131301
def hw_addr(iface):
    '''
    

    '''
    if salt.utils.platform.is_aix():
        return _hw_addr_aix

    iface_info, error = _get_iface_info(iface)

    if error is False:
        return iface_info.get(iface, {}).get('hwaddr', '')
    else:
        return error
897494
def cli(env, identifier, enabled, port, weight, healthcheck_type, ip_address):
    """"""

    mgr = SoftLayer.LoadBalancerManager(env.client)

    loadbal_id, group_id = loadbal.parse_id(identifier)

    # check if the IP is valid
    ip_address_id = None
    if ip_address:
        ip_service = env.client['Network_Subnet_IpAddress']
        ip_record = ip_service.getByIpAddress(ip_address)
        if len(ip_record) > 0:
            ip_address_id = ip_record['id']

    mgr.add_service(loadbal_id,
                    group_id,
                    ip_address_id=ip_address_id,
                    enabled=enabled,
                    port=port,
                    weight=weight,
                    hc_type=healthcheck_type)
    env.fout('Load balancer service is being added!')
656208
def _get_ssh_client(self):
        """"""
        return ipa_utils.get_ssh_client(
            self.instance_ip,
            self.ssh_private_key_file,
            self.ssh_user,
            timeout=self.timeout
        )
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
402401
def interface_ip(iface):
    '''
    
    '''
    iface_info, error = _get_iface_info(iface)

    if error is False:
        inet = iface_info.get(iface, {}).get('inet', None)
        return inet[0].get('address', '') if inet else ''
    else:
        return error
574319
def get_docker_tag(platform: str, registry: str) -> str:
    """"""
    platform = platform if any(x in platform for x in ['build.', 'publish.']) else 'build.{}'.format(platform)
    if not registry:
        registry = "mxnet_local"
    return "{0}/{1}".format(registry, platform)
1034148
def ethernet_interfaces(self):
        """"""
        return ethernet_interface.EthernetInterfaceCollection(
            self._conn,
            self._get_hpe_sub_resource_collection_path('EthernetInterfaces'),
            redfish_version=self.redfish_version)
764706
def get_salt_interface(vm_, opts):
    '''
    
    '''
    salt_host = salt.config.get_cloud_config_value(
        'salt_interface', vm_, opts, default=False,
        search_global=False
    )

    if salt_host is False:
        salt_host = salt.config.get_cloud_config_value(
            'ssh_interface', vm_, opts, default='public_ips',
            search_global=False
        )

    return salt_host
1156963
def _interface_to_service(iface):
    '''
    
    '''
    for _service in _get_services():
        service_info = pyconnman.ConnService(os.path.join(SERVICE_PATH, _service))
        if service_info.get_property('Ethernet')['Interface'] == iface:
            return _service
    return None
1277636
def _Dhcpcd(self, interfaces, logger):
    
    for interface in interfaces:
      dhcpcd = ['/sbin/dhcpcd']
      try:
        subprocess.check_call(dhcpcd + ['-x', interface])
      except subprocess.CalledProcessError:
        # Dhcpcd not yet running for this device.
        logger.info('Dhcpcd not yet running for interface %s.', interface)
      try:
        subprocess.check_call(dhcpcd + [interface])
      except subprocess.CalledProcessError:
        # The interface is already active.
        logger.warning('Could not activate interface %s.', interface)