Example #1
0
def _tpg_lun_of(tpg, pool_name, vol_name):
    """
    Return a object of LUN for given lvm lv.
    If not exist, create one.
    """
    # get wwn of volume so LIO can export as vpd83 info
    vg_name, thin_pool = get_vg_lv(pool_name)

    with vgopen(vg_name) as vg:
        vol_serial = vg.lvFromName(vol_name).getUuid()

    # only add new SO if it doesn't exist
    # so.name concats pool & vol names separated by ':'
    so_name = "%s:%s" % (vg_name, vol_name)
    try:
        so = BlockStorageObject(so_name)
    except RTSLibError:
        so = BlockStorageObject(
            so_name, dev="/dev/%s/%s" % (vg_name, vol_name))
        so.wwn = vol_serial

    # export useful scsi model if kernel > 3.8
    with ignored(RTSLibError):
        so.set_attribute("emulate_model_alias", '1')

    # only add tpg lun if it doesn't exist
    for tmp_lun in tpg.luns:
        if tmp_lun.storage_object.name == so.name and \
           tmp_lun.storage_object.plugin == 'block':
            return tmp_lun
    else:
        return LUN(tpg, storage_object=so)
Example #2
0
def _tpg_lun_of(tpg, pool_name, vol_name):
    """
    Return a object of LUN for given lvm lv.
    If not exist, create one.
    """
    # get wwn of volume so LIO can export as vpd83 info
    vg_name, thin_pool = get_vg_lv(pool_name)

    with vgopen(vg_name) as vg:
        vol_serial = vg.lvFromName(vol_name).getUuid()

    # only add new SO if it doesn't exist
    # so.name concats pool & vol names separated by ':'
    so_name = "%s:%s" % (vg_name, vol_name)
    try:
        so = BlockStorageObject(so_name)
    except RTSLibError:
        so = BlockStorageObject(so_name,
                                dev="/dev/%s/%s" % (vg_name, vol_name))
        so.wwn = vol_serial

    # export useful scsi model if kernel > 3.8
    with ignored(RTSLibError):
        so.set_attribute("emulate_model_alias", '1')

    # only add tpg lun if it doesn't exist
    for tmp_lun in tpg.luns:
        if tmp_lun.storage_object.name == so.name and \
           tmp_lun.storage_object.plugin == 'block':
            return tmp_lun
    else:
        return LUN(tpg, storage_object=so)
Example #3
0
 def _convertImmutablePythonValue(self, value):
     #immutable values first
     with utils.ignored(TypeError):
         return QtScript.QScriptValue(value)
     #including null (None)
     if value is None:
         return self._engine.nullValue()
     raise ValueError("Unknown value type")
Example #4
0
	def _convertImmutablePythonValue(self, value):
		#immutable values first
		with utils.ignored(TypeError):
			return QtScript.QScriptValue(value)
		#including null (None)
		if value is None:
			return self._engine.nullValue()
		raise ValueError("Unknown value type")
Example #5
0
def destroy(req, pool, name):
    with ignored(RTSLibNotInCFS):
        fm = FabricModule('iscsi')
        t = Target(fm, target_name, mode='lookup')
        tpg = TPG(t, 1, mode='lookup')

        so_name = "%s:%s" % (pool, name)
        if so_name in (lun.storage_object.name for lun in tpg.luns):
            raise TargetdError(-303, "Volume '%s' cannot be "
                                     "removed while exported" % name)

    with vgopen(get_vg_lv(pool)[0]) as vg:
        vg.lvFromName(name).remove()
Example #6
0
def destroy(req, pool, name):
    with ignored(RTSLibNotInCFS):
        fm = FabricModule('iscsi')
        t = Target(fm, target_name, mode='lookup')
        tpg = TPG(t, 1, mode='lookup')

        so_name = "%s:%s" % (pool, name)
        if so_name in (lun.storage_object.name for lun in tpg.luns):
            raise TargetdError(
                -303, "Volume '%s' cannot be "
                "removed while exported" % name)

    with vgopen(get_vg_lv(pool)[0]) as vg:
        vg.lvFromName(name).remove()
Example #7
0
	def _excepthook(cls, type, value, tb):
		if not hasattr(value, "oldTraceback"):
			#the default excepthook
			sys.__excepthook__(type, value, tb)
			return

		print >> sys.stderr, "Traceback (most recent call last):"
		#the last 2 traceback items are just JSEvaluator internals; they
		#shouldn't be frustrating the debugging process.
		limit = cls._tbLength(tb) - 2
		traceback.print_tb(tb, limit=limit)
		with utils.ignored(AttributeError):
			print >> sys.stderr, value.oldTraceback
		print "%s: %s" % (type.__name__, value)
Example #8
0
    def _close(self):
        # Close input to the player first to signal the end of the
        # stream and allow the player to terminate of its own accord
        if self.namedpipe:
            self.namedpipe.close()
        elif self.http:
            self.http.close()
        elif not self.filename:
            self.player.stdin.close()

        if self.kill:
            with ignored(Exception):
                self.player.kill()
        self.player.wait()
Example #9
0
    def _close(self):
        # Close input to the player first to signal the end of the
        # stream and allow the player to terminate of its own accord
        if self.namedpipe:
            self.namedpipe.close()
        elif self.http:
            self.http.close()
        elif not self.filename:
            self.player.stdin.close()

        if self.kill:
            with ignored(Exception):
                self.player.kill()
        self.player.wait()
Example #10
0
    def _excepthook(cls, type, value, tb):
        if not hasattr(value, "oldTraceback"):
            #the default excepthook
            sys.__excepthook__(type, value, tb)
            return

        print >> sys.stderr, "Traceback (most recent call last):"
        #the last 2 traceback items are just JSEvaluator internals; they
        #shouldn't be frustrating the debugging process.
        limit = cls._tbLength(tb) - 2
        traceback.print_tb(tb, limit=limit)
        with utils.ignored(AttributeError):
            print >> sys.stderr, value.oldTraceback
        print "%s: %s" % (type.__name__, value)
Example #11
0
def free_wifi():
    '''
    Changes mac address, connects to hotspot and grabs free 15 minutes.
    '''
    print "Changing mac address.."
    random_mac()
    print "Connecting to Virgin WI-FI.."
    connect_hotspot("VirginTrainsEC-WiFi")

    while True:
        with ignored(Exception):
            res = requests.request(method="GET", url=LOGIN_ENDPOINT)
            if res.status_code == 200:
                break

    print "Grabbing free 15 minutes.."
    virgin_portal_login()
Example #12
0
	def property(self, object, name, id):
		name = self._pyName(name)
		with utils.ignored(KeyError):
			return self._toJS({
				"filter": self._filter,
				"indexOf": self._indexOf,
				"join": self._join,
				"length": self._length(),
				"push": self._push,
				"slice": self._slice,
				"splice": self._splice,
				"toJSON": self._toJSON,
				"toString": self._toString,
			}[name])
		try:
			return self._toJS(self._obj[int(name)])
		except (IndexError, ValueError):
			return self.engine().undefinedValue()
Example #13
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))
Example #14
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:]
Example #15
0
 def wwns(self):
     for wwn_file in glob("/sys/class/fc_host/host*/port_name"):
         with ignored(IOError):
             if not fread(os.path.dirname(wwn_file)+"/symbolic_name").startswith("fcoe"):
                 yield "naa." + fread(wwn_file)[2:]
Example #16
0
 def _set_tag(self, tag_str):
     with ignored(IOError):
         if tag_str is None:
             fwrite("%s/tag" % self.path, "NULL")
         else:
             fwrite("%s/tag" % self.path, tag_str)
Example #17
0
 def wwns(self):
     for wwn_file in glob("/sys/class/fc_host/host*/port_name"):
         with ignored(IOError):
             if not fread(os.path.dirname(wwn_file) +
                          "/symbolic_name").startswith("fcoe"):
                 yield self.from_fabric_wwn(fread(wwn_file))
Example #18
0
 def _set_tag(self, tag_str):
     with ignored(IOError):
         if tag_str is None:
             fwrite("%s/tag" % self.path, 'NULL')
         else:
             fwrite("%s/tag" % self.path, tag_str)
Example #19
0
 def _toPythonValue(self, value, scope=None):
     with utils.ignored(ValueError):
         return self._convertImmutableJSValue(value)
     return self._convertMutableJSValue(value, scope)
Example #20
0
	def _toPythonValue(self, value, scope=None):
		with utils.ignored(ValueError):
			return self._convertImmutableJSValue(value)
		return self._convertMutableJSValue(value, scope)