コード例 #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
ファイル: fabric.py プロジェクト: thinkbrown/rtslib-fb
 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
ファイル: target.py プロジェクト: afamilyman/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
コード例 #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
ファイル: target.py プロジェクト: afamilyman/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
コード例 #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
ファイル: target.py プロジェクト: vipinparashar/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
コード例 #26
0
ファイル: target.py プロジェクト: afamilyman/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
コード例 #27
0
ファイル: target.py プロジェクト: vipinparashar/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
コード例 #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
ファイル: target.py プロジェクト: vipinparashar/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
コード例 #32
0
ファイル: target.py プロジェクト: vipinparashar/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()
コード例 #33
0
ファイル: node.py プロジェクト: balagopalraj/clearlinux
 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
ファイル: fabric.py プロジェクト: josephglanville/rtslib-fb
 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
ファイル: node.py プロジェクト: josephglanville/rtslib-fb
 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
ファイル: node.py プロジェクト: balagopalraj/clearlinux
 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
ファイル: target.py プロジェクト: afamilyman/rtslib-fb
 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
ファイル: target.py プロジェクト: vipinparashar/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
コード例 #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
ファイル: target.py プロジェクト: vipinparashar/rtslib
 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
ファイル: fabric.py プロジェクト: josephglanville/rtslib-fb
 def wwns(self):
     for wwn_file in glob("/sys/class/infiniband/*/ports/*/gids/0"):
         yield self.from_fabric_wwn(fread(wwn_file))
コード例 #51
0
ファイル: fabric.py プロジェクト: josephglanville/rtslib-fb
 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
ファイル: fabric.py プロジェクト: josephglanville/rtslib-fb
 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
ファイル: fabric.py プロジェクト: josephglanville/rtslib-fb
 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
ファイル: fabric.py プロジェクト: josephglanville/rtslib-fb
 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()