Return iSCSI IQN
325675
def iscsi_iqn():
    '''
    
    '''
    grains = {}
    grains['iscsi_iqn'] = False
    if salt.utils.platform.is_linux():
        grains['iscsi_iqn'] = _linux_iqn()
    elif salt.utils.platform.is_windows():
        grains['iscsi_iqn'] = _windows_iqn()
    elif salt.utils.platform.is_aix():
        grains['iscsi_iqn'] = _aix_iqn()
    return grains
1105273
def _ip_ifaces():
    '''
    
    '''
    tmp = {}
    ret = {}
    if_ = None
    at_ = None
    out = __salt__['cmd.run']('ip a')
    for line in out.splitlines():
        if not line.startswith(' '):
            comps = line.split(':')
            if_ = comps[1].strip()
            opts_comps = comps[2].strip().split()
            flags = opts_comps.pop(0).lstrip('<').rstrip('>').split(',')
            opts_iter = iter(opts_comps)
            ret[if_] = {
                'flags': flags,
                'options': dict(list(zip(opts_iter, opts_iter)))
            }
        else:
            if line.strip().startswith('link'):
                comps = iter(line.strip().split())
                ret[if_]['link_layer'] = dict(list(zip(comps, comps)))
            elif line.strip().startswith('inet'):
                comps = line.strip().split()
                at_ = comps[0]
                if len(comps) % 2 != 0:
                    last = comps.pop()
                    comps[-1] += ' {0}'.format(last)
                ifi = iter(comps)
                ret[if_][at_] = dict(list(zip(ifi, ifi)))
            else:
                comps = line.strip().split()
                ifi = iter(comps)
                ret[if_][at_].update(dict(list(zip(ifi, ifi))))
    return ret
1370976
def _partition_spec(self, shape, partition_info):
    """"""
    if partition_info is None:
      return ''  # Empty string indicates a non-partitioned tensor.
    ssi = tf.Variable.SaveSliceInfo(
        full_name=self._var_name,
        full_shape=partition_info.full_shape,
        var_offset=partition_info.var_offset,
        var_shape=shape)
    return ssi.spec
126974
def delif(self, iface):
        ''' '''
        if type(iface) == ifconfig.Interface:
            devindex = iface.index
        else:
            devindex = ifconfig.Interface(iface).index
        ifreq = struct.pack('16si', self.name, devindex)
        fcntl.ioctl(ifconfig.sockfd, SIOCBRDELIF, ifreq)    
        return self
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
1316852
def _aloadf(ins):
    ''' 
    '''
    output = _addr(ins.quad[2])
    output.append('call __LOADF')
    output.extend(_fpush())

    REQUIRES.add('iloadf.asm')

    return output
1073635
def _change_iscsi_settings(self, iscsi_info):
        
        headers, bios_uri, bios_settings = self._check_bios_resource()
        # Get the Mappings resource.
        map_settings = self._get_bios_mappings_resource(bios_settings)
        nics = []
        for mapping in map_settings['BiosPciSettingsMappings']:
            for subinstance in mapping['Subinstances']:
                for association in subinstance['Associations']:
                    if 'NicBoot' in association:
                        nics.append(association)

        if not nics:
            msg = ('No nics found')
            raise exception.IloError(msg)

        iscsi_uri = self._check_iscsi_rest_patch_allowed()
        # Set iSCSI info to all nics
        iscsi_infos = []
        for nic in nics:
            data = iscsi_info.copy()
            data['iSCSIBootAttemptName'] = nic
            data['iSCSINicSource'] = nic
            data['iSCSIBootAttemptInstance'] = nics.index(nic) + 1
            iscsi_infos.append(data)

        patch_data = {'iSCSIBootSources': iscsi_infos}
        status, headers, response = self._rest_patch(iscsi_uri,
                                                     None, patch_data)
        if status >= 300:
            msg = self._get_extended_error(response)
            raise exception.IloError(msg)
1274942
def ias60(msg):
    
    d = hex2bin(data(msg))

    if d[12] == '0':
        return None

    ias = bin2int(d[13:23])    # kts
    return ias
1004325
def iscsi_resource(self):
        
        return iscsi.ISCSIResource(
            self._conn, utils.get_subresource_path_by(
                self, ["Oem", "Hpe", "Links", "iScsi"]),
            redfish_version=self.redfish_version)
1335721
def interface_ip(interface):
    """"""
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    return socket.inet_ntoa(
        fcntl.ioctl(
            sock.fileno(), 0x8915, struct.pack('256s', interface[:15])
        )[20:24]
    )
230899
def update_iscsi_settings(self, iscsi_data):
        
        self._conn.patch(self.path, data=iscsi_data)
1256136
def _SignedBinaryURNFromID(binary_id
                          ):
  """"""
  binary_type = binary_id.binary_type
  if binary_type == rdf_objects.SignedBinaryID.BinaryType.PYTHON_HACK:
    return GetAFF4PythonHackRoot().Add(binary_id.path)
  elif binary_type == rdf_objects.SignedBinaryID.BinaryType.EXECUTABLE:
    return GetAFF4ExecutablesRoot().Add(binary_id.path)
  else:
    raise ValueError("Unknown binary type %s." % binary_type)
208587
def isxmap(xmethod, opt):
    

    if xmethod == 'admm':
        isx = {'XPrRsdl': 'PrimalRsdl', 'XDlRsdl': 'DualRsdl',
               'XRho': 'Rho'}
    else:
        isx = {'X_F_Btrack': 'F_Btrack', 'X_Q_Btrack': 'Q_Btrack',
               'X_ItBt': 'IterBTrack', 'X_L': 'L', 'X_Rsdl': 'Rsdl'}
    if not opt['AccurateDFid']:
        isx.update(evlmap(True))
    return isx
233197
def get_alias_address(iface_name, ip_mask, gw_str, metric):
    

    # Detect the architecture
    if scapy.consts.IS_64BITS:
        offset, name_len = 16, 40
    else:
        offset, name_len = 32, 32

    # Retrieve interfaces structures
    sck = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    names = array.array('B', b'\0' * 4096)
    ifreq = ioctl(sck.fileno(), SIOCGIFCONF,
                  struct.pack("iL", len(names), names.buffer_info()[0]))

    # Extract interfaces names
    out = struct.unpack("iL", ifreq)[0]
    names = names.tobytes() if six.PY3 else names.tostring()
    names = [names[i:i + offset].split(b'\0', 1)[0] for i in range(0, out, name_len)]  # noqa: E501

    # Look for the IP address
    for ifname in names:
        # Only look for a matching interface name
        if not ifname.decode("utf8").startswith(iface_name):
            continue

        # Retrieve and convert addresses
        ifreq = ioctl(sck, SIOCGIFADDR, struct.pack("16s16x", ifname))
        ifaddr = struct.unpack(">I", ifreq[20:24])[0]
        ifreq = ioctl(sck, SIOCGIFNETMASK, struct.pack("16s16x", ifname))
        msk = struct.unpack(">I", ifreq[20:24])[0]

        # Get the full interface name
        ifname = plain_str(ifname)
        if ':' in ifname:
            ifname = ifname[:ifname.index(':')]
        else:
            continue

        # Check if the source address is included in the network
        if (ifaddr & msk) == ip_mask:
            sck.close()
            return (ifaddr & msk, msk, gw_str, ifname,
                    scapy.utils.ltoa(ifaddr), metric)

    sck.close()
    return
38414
def get_interface(iface):
    '''
    
    '''
    _interfaces = get_interfaces_details()
    for _interface in _interfaces['interfaces']:
        if _interface['connectionid'] == iface:
            return _dict_to_string(_interface)
    return None
1113359
def get_jid(jid):
    '''
    
    '''
    jid = _escape_jid(jid)
    conn = _get_conn()
    if conn is None:
        return None
    cur = conn.cursor()
    sql = '''SELECT id, return FROM salt_returns WHERE jid = %s'''

    cur.execute(sql, (jid,))
    data = cur.fetchall()
    ret = {}
    if data:
        for minion, full_ret in data:
            ret_data = salt.utils.json.loads(full_ret)
            if not isinstance(ret_data, dict) or 'return' not in ret_data:
                # Convert the old format in which the return contains the only return data to the
                # new that is dict containing 'return' and optionally 'retcode' and 'success'.
                ret_data = {'return': ret_data}
            ret[minion] = ret_data
    _close_conn(conn)
    return ret
157580
def iscsi_settings(self):
        
        return ISCSISettings(
            self._conn, utils.get_subresource_path_by(
                self, ["@Redfish.Settings", "SettingsObject"]),
            redfish_version=self.redfish_version)