Beispiel #1
0
 def wwns(self):
     for fname in glob("/sys/bus/firewire/devices/fw*/is_local"):
         if bool(int(fread(fname))):
             guid_path = os.path.dirname(fname) + "/guid"
             tmp = fread(guid_path)
             if tmp[0:2] == '0x':
                 tmp = tmp[2:]
             yield self.from_fabric_wwn(tmp)
             break
Beispiel #2
0
 def wwns(self):
     for fname in glob("/sys/bus/firewire/devices/fw*/is_local"):
         if bool(int(fread(fname))):
             guid_path = os.path.dirname(fname) + "/guid"
             tmp = fread(guid_path)
             if tmp[0:2] == '0x':
                 tmp = tmp[2:]
             yield self.from_fabric_wwn(tmp)
             break
Beispiel #3
0
 def is_configured(self):
     '''
     @return: True if the StorageObject is configured, else returns False
     '''
     self._check_self()
     path = "%s/info" % self.path
     try:
         fread(path)
     except IOError:
         return False
     else:
         return True
Beispiel #4
0
 def is_configured(self):
     '''
     @return: True if the StorageObject is configured, else returns False
     '''
     self._check_self()
     path = "%s/info" % self.path
     try:
         fread(path)
     except IOError:
         return False
     else:
         return True
Beispiel #5
0
    def restore_pr_aptpl(self, src_path=None):
        '''
        Restores StorageObject persistent reservations read from src_path.
        If src_path is omitted, uses the default LIO PR APTPL system
        path if it exists. This only works if the StorageObject is not
        in use currently, else an IO error will occur.

        @param src_path: The PR metadata file path.
        @type src_path: string or None
        '''
        dst_path = "%s/pr/res_aptpl_metadata" % self.path
        if src_path is None:
            src_path = "%s/aptpl_%s" % (self.pr_aptpl_metadata_dir, self.wwn)

        if not os.path.isfile(src_path):
            return

        lines = fread(src_path).split()
        if not lines[0].startswith("PR_REG_START:"):
            return

        for line in lines:
            if line.startswith("PR_REG_START:"):
                pr_lines = []
            elif line.startswith("PR_REG_END:"):
                fwrite(dst_path, ",".join(pr_lines))
            else:
                pr_lines.append(line.strip())
 def cleanProcess(self,fanNumber):
     try:
         pid = utils.fread(utils.getContextPath()+'/bin/scripts/fan/pid_'+str(fanNumber))
         subprocess.call(["sudo","kill",str(pid)])
         print("Process "+str(pid)+" killed")
     except:
         print("No process found")
Beispiel #7
0
    def _config_pr_aptpl(self):
        """
        LIO actually *writes* pr aptpl info to the filesystem, so we
        need to read it in and squirt it back into configfs when we configure
        the storage object. BLEH.
        """
        aptpl_dir = "/var/target/pr"

        try:
            lines = fread("%s/aptpl_%s" % (aptpl_dir, self.wwn)).split()
        except:
            return

        if not lines[0].startswith("PR_REG_START:"):
            return

        reservations = []
        for line in lines:
            if line.startswith("PR_REG_START:"):
                res_list = []
            elif line.startswith("PR_REG_END:"):
                reservations.append(res_list)
            else:
                res_list.append(line.strip())

        for res in reservations:
            fwrite(self.path + "/pr/res_aptpl_metadata", ",".join(res))
Beispiel #8
0
 def _get_authenticate_target(self):
     self._check_self()
     path = "%s/auth/authenticate_target" % self.path
     try:
         return bool(int(fread(path)))
     except:
         return None
Beispiel #9
0
 def _get_udev_path(self):
     self._check_self()
     path = "%s/udev_path" % self.path
     udev_path = fread(path)
     if not udev_path and self._backstore.plugin == "fileio":
         udev_path = self._parse_info('File').strip()
     return udev_path
Beispiel #10
0
 def _get_wwn(self):
     self._check_self()
     if self.is_configured():
         path = "%s/wwn/vpd_unit_serial" % self.path
         return fread(path).partition(":")[2].strip()
     else:
         return ""
Beispiel #11
0
 def _get_wwn(self):
     self._check_self()
     if self.is_configured():
         path = "%s/wwn/vpd_unit_serial" % self.path
         return fread(path).partition(":")[2].strip()
     else:
         return ""
Beispiel #12
0
    def _get_session(self):
        try:
            lines = fread("%s/info" % self.path).splitlines()
        except IOError:
            return None

        if lines[0].startswith("No active"):
            return None

        session = {}

        for line in lines:
            if line.startswith("InitiatorName:"):
                session['parent_nodeacl'] = self
                session['connections'] = []
            elif line.startswith("InitiatorAlias:"):
                session['alias'] = line.split(":")[1].strip()
            elif line.startswith("LIO Session ID:"):
                session['id'] = int(line.split(":")[1].split()[0])
                session['type'] = line.split(
                    "SessionType:")[1].split()[0].strip()
            elif "TARG_SESS_STATE_" in line:
                session['state'] = line.split("_STATE_")[1].split()[0]
            elif "TARG_CONN_STATE_" in line:
                cid = int(line.split(":")[1].split()[0])
                cstate = line.split("_STATE_")[1].split()[0]
                session['connections'].append(dict(cid=cid, cstate=cstate))
            elif "Address" in line:
                session['connections'][-1]['address'] = line.split()[1]
                session['connections'][-1]['transport'] = line.split()[2]

        return session
Beispiel #13
0
    def _get_session(self):
        try:
            lines = fread("%s/info" % self.path).splitlines()
        except IOError:
            return None

        if lines[0].startswith("No active"):
            return None

        session = {}

        for line in lines:
            if line.startswith("InitiatorName:"):
                session["parent_nodeacl"] = self
                session["connections"] = []
            elif line.startswith("InitiatorAlias:"):
                session["alias"] = line.split(":")[1].strip()
            elif line.startswith("LIO Session ID:"):
                session["id"] = int(line.split(":")[1].split()[0])
                session["type"] = line.split("SessionType:")[1].split()[0].strip()
            elif "TARG_SESS_STATE_" in line:
                session["state"] = line.split("_STATE_")[1].split()[0]
            elif "TARG_CONN_STATE_" in line:
                cid = int(line.split(":")[1].split()[0])
                cstate = line.split("_STATE_")[1].split()[0]
                session["connections"].append(dict(cid=cid, cstate=cstate))
            elif "Address" in line:
                session["connections"][-1]["address"] = line.split()[1]
                session["connections"][-1]["transport"] = line.split()[2]

        return session
Beispiel #14
0
 def _get_udev_path(self):
     self._check_self()
     path = "%s/udev_path" % self.path
     udev_path = fread(path).strip()
     if not udev_path and self.backstore.plugin == "fileio":
         udev_path = self._parse_info('File').strip()
     return udev_path
Beispiel #15
0
 def _get_authenticate_target(self):
     self._check_self()
     path = "%s/auth/authenticate_target" % self.path
     try:
         return bool(int(fread(path)))
     except:
         return None
Beispiel #16
0
    def _config_pr_aptpl(self):
        """
        LIO actually *writes* pr aptpl info to the filesystem, so we
        need to read it in and squirt it back into configfs when we configure
        the storage object. BLEH.
        """
        aptpl_dir = "/var/target/pr"

        try:
            lines = fread("%s/aptpl_%s" % (aptpl_dir, self.wwn)).split()
        except:
            return

        if not lines[0].startswith("PR_REG_START:"):
            return

        reservations = []
        for line in lines:
            if line.startswith("PR_REG_START:"):
                res_list = []
            elif line.startswith("PR_REG_END:"):
                reservations.append(res_list)
            else:
                res_list.append(line.strip())

        for res in reservations:
            fwrite(self.path + "/pr/res_aptpl_metadata", ",".join(res))
Beispiel #17
0
    def restore_pr_aptpl(self, src_path=None):
        '''
        Restores StorageObject persistent reservations read from src_path.
        If src_path is omitted, uses the default LIO PR APTPL system
        path if it exists. This only works if the StorageObject is not
        in use currently, else an IO error will occur.

        @param src_path: The PR metadata file path.
        @type src_path: string or None
        '''
        dst_path = "%s/pr/res_aptpl_metadata" % self.path
        if src_path is None:
            src_path = "%s/aptpl_%s" % (self.pr_aptpl_metadata_dir, self.wwn)

        if not os.path.isfile(src_path):
            return

        lines = fread(src_path).split()
        if not lines[0].startswith("PR_REG_START:"):
            return

        for line in lines:
            if line.startswith("PR_REG_START:"):
                pr_lines = []
            elif line.startswith("PR_REG_END:"):
                fwrite(dst_path, ",".join(pr_lines))
            else:
                pr_lines.append(line.strip())
Beispiel #18
0
 def _get_write_protect(self):
     self._check_self()
     path = "%s/write_protect" % self.path
     write_protect = fread(path).strip()
     if write_protect == "1":
         return True
     else:
         return False
Beispiel #19
0
 def _get_wwn(self):
     self._check_self()
     if self.is_configured():
         path = "%s/wwn/vpd_unit_serial" % self.path
         return fread(path).partition(":")[2].strip()
     else:
         raise RTSLibError("Cannot read a T10 WWN Unit Serial from "
                           + "an unconfigured StorageObject")
Beispiel #20
0
 def _get_wwn(self):
     self._check_self()
     if self.is_configured():
         path = "%s/wwn/vpd_unit_serial" % self.path
         return fread(path).partition(":")[2].strip()
     else:
         raise RTSLibError("Cannot read a T10 WWN Unit Serial from "
                           + "an unconfigured StorageObject")
 def cleanProcess(self):
     try:
         pidRedPath = utils.getContextPath() + '/bin/scripts/led/pid_red'
         pidBluePath = utils.getContextPath() + '/bin/scripts/led/pid_blue'
         if os.path.exists(pidRedPath) and os.path.isfile(pidRedPath):
             pidRed = utils.fread(utils.getContextPath() +
                                  '/bin/scripts/led/pid_red')
             if pidRed != None:
                 subprocess.call(["sudo", "kill", str(pidRed)])
                 print("Process " + str(pidRed) + " killed")
         if os.path.exists(pidBluePath) and os.path.isfile(pidBluePath):
             pidBlue = utils.fread(utils.getContextPath() +
                                   '/bin/scripts/led/pid_blue')
             if pidBlue != None:
                 subprocess.call(["sudo", "kill", str(pidBlue)])
                 print("Process " + str(pidBlue) + " killed")
     except:
         print("No process found")
Beispiel #22
0
 def _get_tag(self):
     self._check_self()
     try:
         tag = fread("%s/tag" % self.path)
         if tag:
             return tag
         return None
     except IOError:
         return None
Beispiel #23
0
 def _get_discovery_userid(self):
     self._check_self()
     self._assert_feature('discovery_auth')
     path = "%s/discovery_auth/userid" % self.path
     value = fread(path).strip()
     if value == "NULL":
         return ''
     else:
         return value
Beispiel #24
0
 def _get_enable(self):
     self._check_self()
     path = "%s/enable" % self.path
     # If the TPG does not have the enable attribute, then it is always
     # enabled.
     if os.path.isfile(path):
         return bool(int(fread(path)))
     else:
         return True
Beispiel #25
0
 def _get_discovery_userid(self):
     self._check_self()
     self._assert_feature('discovery_auth')
     path = "%s/discovery_auth/userid" % self.path
     value = fread(path).strip()
     if value == "NULL":
         return ''
     else:
         return value
Beispiel #26
0
 def _get_tag(self):
     self._check_self()
     try:
         tag = fread("%s/tag" % self.path)
         if tag:
             return tag
         return None
     except IOError:
         return None
Beispiel #27
0
 def _get_enable(self):
     self._check_self()
     path = "%s/enable" % self.path
     # If the TPG does not have the enable attribute, then it is always
     # enabled.
     if os.path.isfile(path):
         return bool(int(fread(path)))
     else:
         return True
Beispiel #28
0
 def _get_initiator(self):
     nexus_path = self._path + "/nexus"
     if os.path.isfile(nexus_path):
         try:
             initiator = fread(nexus_path)
         except IOError, msg:
             raise RTSLibError("Cannot read Nexus initiator address "
                               + "(>=4.0 style, %s): %s."
                               % (nexus_path, msg))
Beispiel #29
0
 def delete(self):
     '''
     Delete the NetworkPortal.
     '''
     path = "%s/iser" % self.path
     if os.path.isfile(path):
         iser_attr = fread(path).strip()
         if iser_attr == "1":
             fwrite(path, "0")
     super(NetworkPortal, self).delete()
Beispiel #30
0
 def _get_iser_attr(self):
     path = "%s/iser" % self.path
     if os.path.isfile(path):
         iser_attr = fread(path).strip()
         if iser_attr == "1":
             return True
         else:
             return False
     else:
         return False
Beispiel #31
0
 def _get_iser_attr(self):
     path = "%s/iser" % self.path
     if os.path.isfile(path):
         iser_attr = fread(path).strip()
         if iser_attr == "1":
             return True
         else:
             return False
     else:
         return False
Beispiel #32
0
 def delete(self):
     '''
     Delete the NetworkPortal.
     '''
     path = "%s/iser" % self.path
     if os.path.isfile(path):
         iser_attr = fread(path).strip()
         if iser_attr == "1":
             fwrite(path, "0")
     super(NetworkPortal, self).delete()
Beispiel #33
0
 def get_attribute(self, attribute):
     '''
     @param attribute: The attribute's name. It is case-sensitive.
     @return: The named attribute's value, as a string.
     '''
     self._check_self()
     path = "%s/attrib/%s" % (self.path, str(attribute))
     if not os.path.isfile(path):
         raise RTSLibError("Cannot find attribute: %s" % attribute)
     else:
         return fread(path)
Beispiel #34
0
 def _get_version(self):
     if self.exists:
         for attr in version_attributes:
             path = "%s/%s" % (self.path, attr)
             if os.path.isfile(path):
                 return fread(path)
         else:
             raise RTSLibError("Can't find version for fabric module %s."
                               % self.name)
     else:
         return None
Beispiel #35
0
 def get_attribute(self, attribute):
     '''
     @param attribute: The attribute's name. It is case-sensitive.
     @return: The named attribute's value, as a string.
     '''
     self._check_self()
     path = "%s/attrib/%s" % (self.path, str(attribute))
     if not os.path.isfile(path):
         raise RTSLibError("Cannot find attribute: %s." % str(attribute))
     else:
         return fread(path)
Beispiel #36
0
 def _get_version(self):
     if self.exists:
         for attr in version_attributes:
             path = "%s/%s" % (self.path, attr)
             if os.path.isfile(path):
                 return fread(path)
         else:
             raise RTSLibError("Can't find version for fabric module %s"
                               % self.name)
     else:
         return None
Beispiel #37
0
 def get_parameter(self, parameter):
     '''
     @param parameter: The RFC-3720 parameter's name. It is case-sensitive.
     @type parameter: string
     @return: The named parameter value as a string.
     '''
     self._check_self()
     path = "%s/param/%s" % (self.path, str(parameter))
     if not os.path.isfile(path):
         raise RTSLibError("Cannot find RFC-3720 parameter: %s" % parameter)
     else:
         return fread(path)
Beispiel #38
0
 def get_parameter(self, parameter):
     '''
     @param parameter: The RFC-3720 parameter's name. It is case-sensitive.
     @type parameter: string
     @return: The named parameter value as a string.
     '''
     self._check_self()
     path = "%s/param/%s" % (self.path, str(parameter))
     if not os.path.isfile(path):
         raise RTSLibError("Cannot find RFC-3720 parameter: %s" % parameter)
     else:
         return fread(path)
Beispiel #39
0
 def get_auth_attr(self, auth_attr):
     '''
     @param auth_attr: The auth_attr's name. It is case-sensitive.
     @return: The named auth_attr's value, as a string.
     '''
     self._check_self()
     path = "%s/auth/%s" % (self.path, str(auth_attr))
     if not os.path.isfile(path):
         raise RTSLibError("Cannot find auth attribute: %s."
                           % str(auth_attr))
     else:
         return fread(path).strip()
Beispiel #40
0
    def is_configured(self):
        '''
        @return: True if the StorageObject is configured, else returns False
        '''

        self._check_self()
        path = "%s/enable" % self.path
        try:
            configured = fread(path)
        except IOError:
            return True

        return bool(int(configured))
Beispiel #41
0
 def _get_nexus(self):
     """
     Gets the nexus initiator WWN, or None if the TPG does not have one.
     """
     self._check_self()
     if self.has_feature("nexus"):
         try:
             nexus_wwn = fread("%s/nexus" % self.path)
         except IOError:
             nexus_wwn = ""
         return nexus_wwn
     else:
         return None
Beispiel #42
0
 def _get_nexus(self):
     '''
     Gets the nexus initiator WWN, or None if the TPG does not have one.
     '''
     self._check_self()
     if self.has_feature('nexus'):
         try:
             nexus_wwn = fread("%s/nexus" % self.path).strip()
         except IOError:
             nexus_wwn = ''
         return nexus_wwn
     else:
         return None
Beispiel #43
0
 def _get_nexus(self):
     '''
     Gets the nexus initiator WWN, or None if the TPG does not have one.
     '''
     self._check_self()
     if self.has_feature('nexus'):
         try:
             nexus_wwn = fread("%s/nexus" % self.path).strip()
         except IOError:
             nexus_wwn = ''
         return nexus_wwn
     else:
         return None
Beispiel #44
0
    def is_configured(self):
        '''
        @return: True if the StorageObject is configured, else returns False
        '''

        self._check_self()
        path = "%s/enable" % self.path
        try:
            configured = fread(path)
        except IOError:
            return True

        return bool(int(configured))
Beispiel #45
0
 def _get_discovery_authenticate_target(self):
     self._check_self()
     self._assert_feature('discovery_auth')
     path = "%s/discovery_auth/authenticate_target" % self.path
     return bool(int(fread(path)))
Beispiel #46
0
 def _get_tcq_depth(self):
     self._check_self()
     path = "%s/cmdsn_depth" % self.path
     return fread(path).strip()
Beispiel #47
0
 def _get_write_protect(self):
     self._check_self()
     path = "%s/write_protect" % self.path
     return bool(int(fread(path)))
Beispiel #48
0
 def _get_tcq_depth(self):
     self._check_self()
     path = "%s/cmdsn_depth" % self.path
     return fread(path).strip()
Beispiel #49
0
 def wwns(self):
     for wwn_file in glob("/sys/class/fc_host/host*/port_name"):
         with ignored(IOError):
             if fread(os.path.dirname(wwn_file)+"/symbolic_name").startswith("fcoe"):
                 yield "naa." + fread(wwn_file)[2:]
Beispiel #50
0
 def wwns(self):
     for wwn_file in glob("/sys/class/infiniband/*/ports/*/gids/0"):
         yield self.from_fabric_wwn(fread(wwn_file))
Beispiel #51
0
 def _get_discovery_authenticate_target(self):
     self._check_self()
     self._assert_feature('discovery_auth')
     path = "%s/discovery_auth/authenticate_target" % self.path
     return bool(int(fread(path)))
Beispiel #52
0
 def _get_discovery_enable_auth(self):
     self._check_self()
     self._assert_feature('discovery_auth')
     path = "%s/discovery_auth/enforce_discovery_auth" % self.path
     value = fread(path)
     return bool(int(value))
Beispiel #53
0
import os
import sys
import utils
import json

if not os.path.exists('./out'):
    os.makedirs('./out')
fname = sys.argv[1]
utils.resume_file_name = fname.split('/')[-1]
print('Reading: %s' % fname)
print('Output will be written to: %s' %
      ('./out/' + utils.resume_file_name + '.json'))

content = utils.fread(fname, clean=True)
raw_content = utils.fread(fname, clean=False)

phone_numbers = utils.extract_phone_number(content)

emails = utils.extract_email(content)

names = utils.extract_names(content)

education = utils.get_education(raw_content)

skills = utils.get_skills(raw_content)

res = {
    'name': names,
    'email': emails,
    'phone': phone_numbers,
    'education': education,
Beispiel #54
0
 def wwns(self):
     for fname in glob("/sys/bus/firewire/devices/fw*/is_local"):
         if bool(int(fread(fname))):
             guid_path = os.path.dirname(fname) + "/guid"
             yield "eui." + fread(guid_path)[2:]
             break
Beispiel #55
0
 def _get_discovery_enable_auth(self):
     self._check_self()
     self._assert_feature('discovery_auth')
     path = "%s/discovery_auth/enforce_discovery_auth" % self.path
     value = fread(path)
     return bool(int(value))
Beispiel #56
0
 def wwns(self):
     for wwn_file in glob("/sys/class/infiniband/*/ports/*/gids/0"):
         yield "ib." + fread(wwn_file).replace(":", "")
Beispiel #57
0
 def wwns(self):
     for fname in glob("/sys/bus/firewire/devices/fw*/is_local"):
         if bool(int(fread(fname))):
             guid_path = os.path.dirname(fname) + "/guid"
             yield self.from_fabric_wwn(fread(guid_path))
             break
Beispiel #58
0
 def _get_vendor(self):
     self._check_self()
     info = fread("%s/info" % self.path)
     return str(
         re.search(".*Vendor:(.*)Model:",
                   ' '.join(info.split())).group(1)).strip()
Beispiel #59
0
 def wwns(self):
     for wwn_file in glob("/sys/class/fc_host/host*/port_name"):
         with ignored(IOError):
             if fread(os.path.dirname(wwn_file)+"/symbolic_name").startswith("fcoe"):
                 yield self.from_fabric_wwn(fread(wwn_file))
Beispiel #60
0
 def _parse_info(self, key):
     self._check_self()
     info = fread("%s/hba_info" % self.path)
     return re.search(".*%s: ([^: ]+).*" \
                      % key, ' '.join(info.split())).group(1).lower()