def create(self, params): if 'blk_dev' not in params: raise MissingParameter("GINFS00009E") blk_dev = params['blk_dev'] if 'mount_point' not in params: raise MissingParameter("GINFS00010E") mount_point = params['mount_point'] if 'persistent' not in params: raise MissingParameter("GINFS00011E") persistent = params['persistent'] if type(persistent) != bool: if persistent == u'True': persistent = True elif persistent == u'False': persistent = False else: raise InvalidParameter("GINFS00014E") fs_utils._mount_a_blk_device(blk_dev, mount_point) if persistent: fs_utils.make_persist(blk_dev, mount_point) return mount_point
def create(self, params): if not params.get('type'): raise MissingParameter("GINFS00016E") if params['type'] == 'local': if not params.get('blk_dev'): raise MissingParameter("GINFS00009E") blk_dev = params['blk_dev'] if not params.get('mount_point'): raise MissingParameter("GINFS00010E") mount_point = params['mount_point'] mount_options = params.get('mount_options', '') try: fs_utils._mount_a_blk_device(blk_dev, mount_point, mount_options) fs_utils.make_persist(blk_dev, mount_point, mount_options) except Exception: raise InvalidParameter("GINFS00007E") return mount_point elif params['type'] == 'nfs': if not params.get('server'): raise MissingParameter("GINFS00014E") server = params['server'] if not params.get('share'): raise MissingParameter("GINFS00015E") share = params['share'] if not params.get('mount_point'): raise MissingParameter("GINFS00010E") mount_point = params['mount_point'] mount_options = params.get('mount_options', '') try: fs_utils.nfsmount(server, share, mount_point, mount_options) dev_info = server + ':' + share fs_utils.make_persist(dev_info, mount_point, mount_options) except Exception as e: raise InvalidParameter("GINFS00018E", {"err": e}) return mount_point else: raise InvalidParameter("GINFS00017E")
def create(self, params): if not params.get('type'): raise MissingParameter("GINFS00016E") if params['type'] == 'local': if not params.get('blk_dev'): raise MissingParameter("GINFS00009E") blk_dev = params['blk_dev'] if not params.get('mount_point'): raise MissingParameter("GINFS00010E") mount_point = params['mount_point'] mount_options = params.get('mount_options', '') try: fs_utils._mount_a_blk_device(blk_dev, mount_point, mount_options) fs_utils.make_persist(blk_dev, mount_point, mount_options) except Exception as e: raise InvalidParameter("GINFS00007E", {"err": e.message}) return mount_point elif params['type'] == 'nfs': if not params.get('server'): raise MissingParameter("GINFS00014E") server = params['server'] if not params.get('share'): raise MissingParameter("GINFS00015E") share = params['share'] if not params.get('mount_point'): raise MissingParameter("GINFS00010E") mount_point = params['mount_point'] mount_options = params.get('mount_options', '') try: fs_utils.nfsmount(server, share, mount_point, mount_options) dev_info = server + ':' + share fs_utils.make_persist(dev_info, mount_point, mount_options) except Exception as e: raise InvalidParameter("GINFS00018E", {"err": e}) return mount_point else: raise InvalidParameter("GINFS00017E")
def create(self, params): if 'type' not in params: raise MissingParameter("GINFS00016E") if params['type'] == 'local': if 'blk_dev' not in params: raise MissingParameter("GINFS00009E") blk_dev = params['blk_dev'] if 'mount_point' not in params: raise MissingParameter("GINFS00010E") mount_point = params['mount_point'] try: fs_utils._mount_a_blk_device(blk_dev, mount_point) fs_utils.make_persist(blk_dev, mount_point) except Exception: raise InvalidParameter("GINFS00007E") return mount_point elif params['type'] == 'nfs': if 'server' not in params: raise MissingParameter("GINFS00014E") server = params['server'] if 'share' not in params: raise MissingParameter("GINFS00015E") share = params['share'] if 'mount_point' not in params: raise MissingParameter("GINFS00010E") mount_point = params['mount_point'] fs_utils.nfsmount(server, share, mount_point) dev_info = server + ':' + share fs_utils.make_persist(dev_info, mount_point) return mount_point else: raise InvalidParameter("GINFS00017E")
def create(self, params): if not params.get('type'): raise MissingParameter("GINFS00016E") if params['type'] == 'local': if not params.get('blk_dev'): raise MissingParameter("GINFS00009E") blk_dev = params['blk_dev'] if not params.get('mount_point'): raise MissingParameter("GINFS00010E") mount_point = params['mount_point'].strip() if mount_point != '/': mount_point = mount_point.rstrip('/') mount_options = params.get('mount_options', '') try: with RollbackContext() as rollback: fs_utils._mount_a_blk_device(blk_dev, mount_point, mount_options) rollback.prependDefer(fs_utils._umount_partition, mount_point) fs_utils.make_persist(blk_dev, mount_point, mount_options) rollback.commitAll() except OperationFailed: raise except InvalidParameter: raise except Exception as e: raise InvalidParameter("GINFS00007E", {"err": e.__str__()}) return mount_point elif params['type'] == 'nfs': if not params.get('server'): raise MissingParameter("GINFS00014E") server = params['server'] if not params.get('share'): raise MissingParameter("GINFS00015E") share = params['share'] if not params.get('mount_point'): raise MissingParameter("GINFS00010E") mount_point = params['mount_point'].strip() if mount_point != '/': mount_point = mount_point.rstrip('/') mount_options = params.get('mount_options', '') try: with RollbackContext() as rollback: fs_utils.nfsmount(server, share, mount_point, mount_options) rollback.prependDefer(fs_utils._umount_partition, mount_point) dev_info = server + ':' + share fs_utils.make_persist(dev_info, mount_point, mount_options) rollback.commitAll() except OperationFailed: raise except InvalidParameter: raise except Exception as e: raise InvalidParameter("GINFS00018E", {"err": e}) return mount_point else: raise InvalidParameter("GINFS00017E")
def create(self, params): if not params.get('type'): raise MissingParameter("GINFS00016E") if params['type'] == 'local': if not params.get('blk_dev'): raise MissingParameter("GINFS00009E") blk_dev = params['blk_dev'] if not params.get('mount_point'): raise MissingParameter("GINFS00010E") mount_point = params['mount_point'].strip() if mount_point != '/': mount_point = mount_point.rstrip('/') mount_options = params.get('mount_options', '') try: with RollbackContext() as rollback: fs_utils._mount_a_blk_device(blk_dev, mount_point, mount_options) rollback.prependDefer( fs_utils._umount_partition, mount_point) fs_utils.make_persist(blk_dev, mount_point, mount_options) rollback.commitAll() except OperationFailed: raise except InvalidParameter: raise except Exception as e: raise InvalidParameter("GINFS00007E", {"err": e.__str__()}) return mount_point elif params['type'] == 'nfs': if not params.get('server'): raise MissingParameter("GINFS00014E") server = params['server'] if not params.get('share'): raise MissingParameter("GINFS00015E") share = params['share'] if not params.get('mount_point'): raise MissingParameter("GINFS00010E") mount_point = params['mount_point'].strip() if mount_point != '/': mount_point = mount_point.rstrip('/') mount_options = params.get('mount_options', '') try: with RollbackContext() as rollback: fs_utils.nfsmount( server, share, mount_point, mount_options) rollback.prependDefer( fs_utils._umount_partition, mount_point) dev_info = server + ':' + share fs_utils.make_persist( dev_info, mount_point, mount_options) rollback.commitAll() except OperationFailed: raise except InvalidParameter: raise except Exception as e: raise InvalidParameter("GINFS00018E", {"err": e}) return mount_point else: raise InvalidParameter("GINFS00017E")