예제 #1
0
파일: dasddevs.py 프로젝트: pawankg/ginger
    def format(self, bus_id, blk_size):
        woklock = threading.Lock()
        name = dev_details['name']
        dasd_name_list = dasd_utils._get_dasd_names()
        if name not in dasd_name_list:
            raise NotFoundError('GINDASD0007E')
        task_params = {'blk_size': blk_size, 'name': name}
        try:
            woklock.acquire()
            taskid = add_task(u'/dasddevs/%s/blksize/%s' % (name, blk_size),
                              self._format_task, self.objstore, task_params)
        except OperationFailed as e:
            woklock.release()
            wok_log.error("Formatting of DASD device %s failed" % bus_id)
            raise OperationFailed("GINDASD0008E", {'err': e})
        finally:
            woklock.release()

        return self.task.lookup(taskid)
예제 #2
0
    def format(self, bus_id, blk_size):
        woklock = threading.Lock()
        name = self.dev_details['name']
        dasd_name_list = dasd_utils._get_dasd_names()
        if name not in dasd_name_list:
            raise NotFoundError('GINDASD0007E')
        task_params = {'blk_size': blk_size, 'name': name}
        try:
            woklock.acquire()
            taskid = add_task(u'/dasddevs/%s/blksize/%s' % (name, blk_size),
                              self._format_task, self.objstore, task_params)
        except OperationFailed as e:
            woklock.release()
            wok_log.error("Formatting of DASD device %s failed" % bus_id)
            raise OperationFailed("GINDASD0008E", {'err': e})
        finally:
            woklock.release()

        return self.task.lookup(taskid)
예제 #3
0
    def format(self, bus_id, blk_size):
        tasks = []
        dasd_utils.validate_bus_id(bus_id)
        woklock = threading.Lock()
        name = self.dev_details['name']
        dasd_name_list = dasd_utils._get_dasd_names()
        if name not in dasd_name_list:
            raise NotFoundError('GINDASD0007E')
        task_params = {'blk_size': blk_size, 'name': name}
        try:
            woklock.acquire()
            with self.objstore as session:
                tasks = session.get_list('task')

            running_tasks = []
            for task in tasks:
                with self.objstore as session:
                    current_task = session.get('task', str(task))
                    if (current_task['target_uri'].startswith('/dasddevs') and
                       current_task['status']) == 'running':
                        running_tasks.append(current_task)

            # Limit the number of concurrent DASD format operations to
            # MAX_DASD_FMT.
            if len(running_tasks) > MAX_DASD_FMT:
                raise InvalidOperation(
                    "GINDASD0014E", {
                        'max_dasd_fmt': str(MAX_DASD_FMT)})

            taskid = add_task(u'/dasddevs/%s/blksize/%s' % (name, blk_size),
                              self._format_task, self.objstore, task_params)
        except OperationFailed:
            woklock.release()
            wok_log.error("Formatting of DASD device %s failed" % bus_id)
            raise OperationFailed("GINDASD0008E", {'name': name})
        finally:
            woklock.release()

        return self.task.lookup(taskid)
예제 #4
0
    def format(self, bus_id, blk_size):
        tasks = []
        dasd_utils.validate_bus_id(bus_id)
        woklock = threading.Lock()
        name = self.dev_details['name']
        dasd_name_list = dasd_utils._get_dasd_names()
        if name not in dasd_name_list:
            raise NotFoundError('GINDASD0007E')
        task_params = {'blk_size': blk_size, 'name': name}
        try:
            woklock.acquire()
            with self.objstore as session:
                tasks = session.get_list('task')

            running_tasks = []
            for task in tasks:
                with self.objstore as session:
                    current_task = session.get('task', str(task))
                    if (current_task['target_uri'].startswith('/dasddevs')
                            and current_task['status']) == 'running':
                        running_tasks.append(current_task)

            # Limit the number of concurrent DASD format operations to
            # MAX_DASD_FMT.
            if len(running_tasks) > MAX_DASD_FMT:
                raise InvalidOperation("GINDASD0014E",
                                       {'max_dasd_fmt': str(MAX_DASD_FMT)})

            taskid = AsyncTask(u'/dasddevs/%s/blksize/%s' % (name, blk_size),
                               self._format_task, task_params).id
        except OperationFailed:
            woklock.release()
            raise OperationFailed("GINDASD0008E", {'name': name})
        finally:
            woklock.release()

        return self.task.lookup(taskid)