예제 #1
0
파일: fabric.py 프로젝트: JonnyJD/rtslib
 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
예제 #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
예제 #3
0
파일: tcm.py 프로젝트: vipinparashar/rtslib
 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
예제 #4
0
파일: tcm.py 프로젝트: Datera/rtslib
 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
예제 #5
0
파일: tcm.py 프로젝트: vipinparashar/rtslib
    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())
예제 #6
0
 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")
예제 #7
0
파일: tcm.py 프로젝트: benno16/rtslib-fb
    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))
예제 #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
예제 #9
0
파일: tcm.py 프로젝트: benno16/rtslib-fb
 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
예제 #10
0
파일: tcm.py 프로젝트: Thingee/rtslib
 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 ""
예제 #11
0
파일: tcm.py 프로젝트: vipinparashar/rtslib
 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 ""
예제 #12
0
파일: target.py 프로젝트: fielder/rtslib-fb
    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
예제 #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
예제 #14
0
파일: tcm.py 프로젝트: vipinparashar/rtslib
 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
예제 #15
0
파일: target.py 프로젝트: fielder/rtslib-fb
 def _get_authenticate_target(self):
     self._check_self()
     path = "%s/auth/authenticate_target" % self.path
     try:
         return bool(int(fread(path)))
     except:
         return None
예제 #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))
예제 #17
0
파일: tcm.py 프로젝트: Datera/rtslib
    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())
예제 #18
0
파일: target.py 프로젝트: Thingee/rtslib
 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
예제 #19
0
파일: tcm.py 프로젝트: benno16/rtslib-fb
 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")
예제 #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")
예제 #21
0
 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")
예제 #22
0
파일: target.py 프로젝트: fielder/rtslib-fb
 def _get_tag(self):
     self._check_self()
     try:
         tag = fread("%s/tag" % self.path)
         if tag:
             return tag
         return None
     except IOError:
         return None
예제 #23
0
파일: target.py 프로젝트: Datera/rtslib
 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
예제 #24
0
파일: target.py 프로젝트: Datera/rtslib
 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
예제 #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
예제 #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
예제 #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
예제 #28
0
파일: loop.py 프로젝트: Thingee/rtslib
 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))
예제 #29
0
파일: target.py 프로젝트: Datera/rtslib
 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()
예제 #30
0
파일: target.py 프로젝트: Datera/rtslib
 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
예제 #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
예제 #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()
예제 #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)
예제 #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
예제 #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)
예제 #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
예제 #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)
예제 #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)
예제 #39
0
파일: node.py 프로젝트: Datera/rtslib
 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()
예제 #40
0
파일: tcm.py 프로젝트: benno16/rtslib-fb
    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))
예제 #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
예제 #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
예제 #43
0
파일: target.py 프로젝트: Datera/rtslib
 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
예제 #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))
예제 #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)))
예제 #46
0
파일: target.py 프로젝트: Datera/rtslib
 def _get_tcq_depth(self):
     self._check_self()
     path = "%s/cmdsn_depth" % self.path
     return fread(path).strip()
예제 #47
0
파일: target.py 프로젝트: Datera/rtslib
 def _get_write_protect(self):
     self._check_self()
     path = "%s/write_protect" % self.path
     return bool(int(fread(path)))
예제 #48
0
 def _get_tcq_depth(self):
     self._check_self()
     path = "%s/cmdsn_depth" % self.path
     return fread(path).strip()
예제 #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:]
예제 #50
0
 def wwns(self):
     for wwn_file in glob("/sys/class/infiniband/*/ports/*/gids/0"):
         yield self.from_fabric_wwn(fread(wwn_file))
예제 #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)))
예제 #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))
예제 #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,
예제 #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
예제 #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))
예제 #56
0
 def wwns(self):
     for wwn_file in glob("/sys/class/infiniband/*/ports/*/gids/0"):
         yield "ib." + fread(wwn_file).replace(":", "")
예제 #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
예제 #58
0
파일: tcm.py 프로젝트: vipinparashar/rtslib
 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()
예제 #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))
예제 #60
0
파일: tcm.py 프로젝트: vipinparashar/rtslib
 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()