Exemple #1
0
    def _tgt_masks(self):
        """
        Return a list of tgt_mask:
            {
                'pool_name': pool_name,
                'vol_name': vol_name,
                'ag_id': lsm_ag.id,
                'h_lun_id': h_lun_id,
            }
        """
        tgt_masks = []
        for tgt_exp in self._jsonrequest("export_list"):
            tgt_masks.append({
                'ag_id':
                "%s%s" % (TargetdStorage._FAKE_AG_PREFIX,
                          md5(tgt_exp['initiator_wwn'])),
                'vol_name':
                tgt_exp['vol_name'],
                'pool_name':
                tgt_exp['pool'],
                'h_lun_id':
                tgt_exp['lun'],
            })
        if self._flag_ag_support:
            for tgt_ag_map in self._jsonrequest("access_group_map_list"):
                tgt_masks.append({
                    'ag_id': tgt_ag_map['ag_name'],
                    'vol_name': tgt_ag_map['vol_name'],
                    'pool_name': tgt_ag_map['pool_name'],
                    'h_lun_id': tgt_ag_map['h_lun_id'],
                })

        return tgt_masks
Exemple #2
0
    def _tgt_masks(self):
        """
        Return a list of tgt_mask:
            {
                'pool_name': pool_name,
                'vol_name': vol_name,
                'ag_id': lsm_ag.id,
                'h_lun_id': h_lun_id,
            }
        """
        tgt_masks = []
        for tgt_exp in self._jsonrequest("export_list"):
            tgt_masks.append({
                'ag_id': "%s%s" % (
                    TargetdStorage._FAKE_AG_PREFIX,
                    md5(tgt_exp['initiator_wwn'])),
                'vol_name': tgt_exp['vol_name'],
                'pool_name': tgt_exp['pool'],
                'h_lun_id': tgt_exp['lun'],
            })
        if self._flag_ag_support:
            for tgt_ag_map in self._jsonrequest("access_group_map_list"):
                tgt_masks.append({
                    'ag_id': tgt_ag_map['ag_name'],
                    'vol_name': tgt_ag_map['vol_name'],
                    'pool_name': tgt_ag_map['pool_name'],
                    'h_lun_id': tgt_ag_map['h_lun_id'],
                })

        return tgt_masks
Exemple #3
0
    def export_fs(self, fs_id, export_path, root_list, rw_list, ro_list,
                  anon_uid, anon_gid, auth_type, options, flags=0):
        """
        Exports a filesystem as specified in the export
        """
        if export_path is None:
            raise LsmError(ErrorNumber.INVALID_ARGUMENT,
                           "Export path is required")

        md5_id = md5(export_path)
        fs_dict = {'auth_type': 'sys', 'anonymous': 'false'}
        if ro_list:
            fs_dict['read_only'] = ','.join(ro_list)
        if rw_list:
            fs_dict['read_write'] = ','.join(rw_list)
        if anon_uid or anon_gid:
            fs_dict['anonymous'] = 'true'
        if root_list:
            fs_dict['root'] = ','.join(root_list)
        if auth_type:
            fs_dict['auth_type'] = str(auth_type)
        if '*' in rw_list:
            fs_dict['anonymous'] = 'true'
        if options:
            fs_dict['extra_options'] = str(options)

        result = self._request("share_folder", "netstorsvc",
                               ['svc:/network/nfs/server:default',
                                fs_id, fs_dict])
        return NfsExport(md5_id, fs_id, export_path, auth_type, root_list,
                         rw_list, ro_list, anon_uid, anon_gid, options)
Exemple #4
0
    def export_fs(self, fs_id, export_path, root_list, rw_list, ro_list,
                  anon_uid, anon_gid, auth_type, options, flags=0):
        """
        Exports a filesystem as specified in the export
        """
        if export_path is None:
            raise LsmError(ErrorNumber.INVALID_ARGUMENT,
                           "Export path is required")

        md5_id = md5(export_path)
        fs_dict = {'auth_type': 'sys', 'anonymous': 'false'}
        if ro_list:
            fs_dict['read_only'] = ','.join(ro_list)
        if rw_list:
            fs_dict['read_write'] = ','.join(rw_list)
        if anon_uid or anon_gid:
            fs_dict['anonymous'] = 'true'
        if root_list:
            fs_dict['root'] = ','.join(root_list)
        if auth_type:
            fs_dict['auth_type'] = str(auth_type)
        if '*' in rw_list:
            fs_dict['anonymous'] = 'true'
        if options:
            fs_dict['extra_options'] = str(options)

        self._request("share_folder", "netstorsvc",
                      ['svc:/network/nfs/server:default', fs_id, fs_dict])
        return NfsExport(md5_id, fs_id, export_path, auth_type, root_list,
                         rw_list, ro_list, anon_uid, anon_gid, options)
def _disk_id_of_cim_disk(cim_disk):
    if 'SystemName' not in cim_disk or \
       'DeviceID' not in cim_disk:
        raise LsmError(
            ErrorNumber.PLUGIN_BUG,
            "_disk_id_of_cim_disk(): Got cim_disk with no "
            "SystemName or DeviceID property: %s, %s" %
            (cim_disk.path, cim_disk.items()))

    return md5("%s%s" % (cim_disk['SystemName'], cim_disk['DeviceID']))
Exemple #6
0
def _disk_id_of_cim_disk(cim_disk):
    if 'SystemName' not in cim_disk or \
       'DeviceID' not in cim_disk:
        raise LsmError(
            ErrorNumber.PLUGIN_BUG,
            "_disk_id_of_cim_disk(): Got cim_disk with no "
            "SystemName or DeviceID property: %s, %s" %
            (cim_disk.path, list(cim_disk.items())))

    return md5("%s%s" % (cim_disk['SystemName'], cim_disk['DeviceID']))
Exemple #7
0
def vol_id_of_cim_vol(cim_vol):
    """
    Get lsm.Volume.id from CIM_StorageVolume['DeviceID'] and ['SystemName']
    """
    if 'SystemName' not in cim_vol or 'DeviceID' not in cim_vol:
        raise LsmError(
            ErrorNumber.PLUGIN_BUG, "vol_id_of_cim_vol(): Got cim_vol with no "
            "SystemName or DeviceID property: %s, %s" %
            (cim_vol.path, list(cim_vol.items())))

    return md5("%s%s" % (cim_vol['SystemName'], cim_vol['DeviceID']))
 def _job_id_of_cim_job(cim_job, retrieve_data, method_data):
     """
     Return the MD5 has of CIM_ConcreteJob['InstanceID'] in conjunction
     with '@%s' % retrieve_data
     retrieve_data should be SmisCommon.JOB_RETRIEVE_NONE or
     SmisCommon.JOB_RETRIEVE_VOLUME or etc
     method_data is any string a method would like store for error
     handling by job_status().
     """
     return "%s@%d@%s" % (
         md5(cim_job['InstanceID']), int(retrieve_data), str(method_data))
Exemple #9
0
def cim_spc_to_lsm_ag(smis_common, cim_spc, system_id):
    """
    Convert CIM_SCSIProtocolController to lsm.AccessGroup
    """
    ag_id = md5(cim_spc['DeviceID'])
    ag_name = cim_spc['ElementName']
    cim_inits = cim_init_of_cim_spc_path(smis_common, cim_spc.path)
    (init_ids, init_type) = _init_id_and_type_of(cim_inits)
    plugin_data = cim_path_to_path_str(cim_spc.path)
    return AccessGroup(
        ag_id, ag_name, init_ids, init_type, system_id, plugin_data)
 def _job_id_of_cim_job(cim_job, retrieve_data, method_data):
     """
     Return the MD5 has of CIM_ConcreteJob['InstanceID'] in conjunction
     with '@%s' % retrieve_data
     retrieve_data should be SmisCommon.JOB_RETRIEVE_NONE or
     SmisCommon.JOB_RETRIEVE_VOLUME or etc
     method_data is any string a method would like store for error
     handling by job_status().
     """
     return "%s@%d@%s" % (
         md5(cim_job['InstanceID']), int(retrieve_data), str(method_data))
Exemple #11
0
def cim_init_mg_to_lsm_ag(smis_common, cim_init_mg, system_id):
    """
    Convert CIM_InitiatorMaskingGroup to lsm.AccessGroup
    """
    ag_name = cim_init_mg['ElementName']
    ag_id = md5(cim_init_mg['InstanceID'])
    cim_inits = cim_init_of_cim_init_mg_path(smis_common, cim_init_mg.path)
    (init_ids, init_type) = _init_id_and_type_of(cim_inits)
    plugin_data = cim_path_to_path_str(cim_init_mg.path)
    return AccessGroup(
        ag_id, ag_name, init_ids, init_type, system_id, plugin_data)
Exemple #12
0
def cim_spc_to_lsm_ag(smis_common, cim_spc, system_id):
    """
    Convert CIM_SCSIProtocolController to lsm.AccessGroup
    """
    ag_id = md5(cim_spc['DeviceID'])
    ag_name = cim_spc['ElementName']
    cim_inits = cim_init_of_cim_spc_path(smis_common, cim_spc.path)
    (init_ids, init_type) = _init_id_and_type_of(cim_inits)
    plugin_data = cim_path_to_path_str(cim_spc.path)
    return AccessGroup(ag_id, ag_name, init_ids, init_type, system_id,
                       plugin_data)
Exemple #13
0
def cim_init_mg_to_lsm_ag(smis_common, cim_init_mg, system_id):
    """
    Convert CIM_InitiatorMaskingGroup to lsm.AccessGroup
    """
    ag_name = cim_init_mg['ElementName']
    ag_id = md5(cim_init_mg['InstanceID'])
    cim_inits = cim_init_of_cim_init_mg_path(smis_common, cim_init_mg.path)
    (init_ids, init_type) = _init_id_and_type_of(cim_inits)
    plugin_data = cim_path_to_path_str(cim_init_mg.path)
    return AccessGroup(ag_id, ag_name, init_ids, init_type, system_id,
                       plugin_data)
Exemple #14
0
def vol_id_of_cim_vol(cim_vol):
    """
    Get lsm.Volume.id from CIM_StorageVolume['DeviceID'] and ['SystemName']
    """
    if 'SystemName' not in cim_vol or 'DeviceID' not in cim_vol:
        raise LsmError(
            ErrorNumber.PLUGIN_BUG,
            "vol_id_of_cim_vol(): Got cim_vol with no "
            "SystemName or DeviceID property: %s, %s" %
            (cim_vol.path, cim_vol.items()))

    return md5("%s%s" % (cim_vol['SystemName'], cim_vol['DeviceID']))
Exemple #15
0
    def exports(self, search_key=None, search_value=None, flags=0):
        """
        Get a list of all exported file systems on the controller.
        """
        exp_list = self._request("get_shared_folders", "netstorsvc",
                                 ['svc:/network/nfs/server:default', ''])

        exports = []
        for e in exp_list:
            opts = self._request("get_shareopts", "netstorsvc",
                                 ['svc:/network/nfs/server:default', e])
            exports.append(NfsExport(md5(opts['name']), e, opts['name'],
                                     opts['auth_type'], opts['root'],
                                     opts['read_write'], opts['read_only'],
                                     'N/A', 'N/A', opts['extra_options']))

        return search_property(exports, search_key, search_value)
Exemple #16
0
    def exports(self, search_key=None, search_value=None, flags=0):
        """
        Get a list of all exported file systems on the controller.
        """
        exp_list = self._request("get_shared_folders", "netstorsvc",
                                 ['svc:/network/nfs/server:default', ''])

        exports = []
        for e in exp_list:
            opts = self._request("get_shareopts", "netstorsvc",
                                 ['svc:/network/nfs/server:default', e])
            exports.append(NfsExport(md5(opts['name']), e, opts['name'],
                                     opts['auth_type'], opts['root'],
                                     opts['read_write'], opts['read_only'],
                                     'N/A', 'N/A', opts['extra_options']))

        return search_property(exports, search_key, search_value)
Exemple #17
0
    def fs_clone(self, src_fs, dest_fs_name, snapshot=None, flags=0):
        folder = src_fs.name.split('/')[0]
        dest = folder + '/' + dest_fs_name

        if snapshot is None:
            # User did not supply a snapshot, so we will create one for them
            name = src_fs.name.split('/')[0]
            snapshot = self.fs_snapshot_create(
                src_fs, name + "_clone_ss_" + md5(time.ctime()))[1]

        self._request("clone", "folder", [snapshot.name, dest])
        pool_id = NexentaStor._get_pool_id(dest)
        pool_info = self._request("get_child_props", "volume", [pool_id, ""])
        fs = FileSystem(dest, dest, NexentaStor._to_bytes(pool_info['size']),
                        NexentaStor._to_bytes(pool_info['available']), pool_id,
                        self.system.id)
        return None, fs
Exemple #18
0
    def fs_clone(self, src_fs, dest_fs_name, snapshot=None, flags=0):
        folder = src_fs.name.split('/')[0]
        dest = folder + '/' + dest_fs_name

        if snapshot is None:
            # User did not supply a snapshot, so we will create one for them
            name = src_fs.name.split('/')[0]
            snapshot = self.fs_snapshot_create(
                src_fs, name + "_clone_ss_" + md5(time.ctime()))[1]

        self._request("clone", "folder", [snapshot.name, dest])
        pool_id = NexentaStor._get_pool_id(dest)
        pool_info = self._request("get_child_props", "volume", [pool_id, ""])
        fs = FileSystem(dest, dest, NexentaStor._to_bytes(pool_info['size']),
                        NexentaStor._to_bytes(pool_info['available']), pool_id,
                        self.system.id)
        return None, fs
Exemple #19
0
    def cim_job_of_job_id(self, job_id, property_list=None):
        """
        Return CIM_ConcreteJob for given job_id.
        """
        if property_list is None:
            property_list = SmisCommon.cim_job_pros()
        else:
            property_list = merge_list(property_list,
                                       SmisCommon.cim_job_pros())

        cim_jobs = self.EnumerateInstances('CIM_ConcreteJob',
                                           PropertyList=property_list)
        real_job_id = SmisCommon.parse_job_id(job_id)[0]
        for cim_job in cim_jobs:
            if md5(cim_job['InstanceID']) == real_job_id:
                return cim_job

        raise LsmError(ErrorNumber.NOT_FOUND_JOB, "Job %s not found" % job_id)
    def cim_job_of_job_id(self, job_id, property_list=None):
        """
        Return CIM_ConcreteJob for given job_id.
        """
        if property_list is None:
            property_list = SmisCommon.cim_job_pros()
        else:
            property_list = merge_list(
                property_list, SmisCommon.cim_job_pros())

        cim_jobs = self.EnumerateInstances(
            'CIM_ConcreteJob',
            PropertyList=property_list)
        real_job_id = SmisCommon.parse_job_id(job_id)[0]
        for cim_job in cim_jobs:
            if md5(cim_job['InstanceID']) == real_job_id:
                return cim_job

        raise LsmError(
            ErrorNumber.NOT_FOUND_JOB,
            "Job %s not found" % job_id)
Exemple #21
0
 def _calc_group(name):
     return 'lsm_' + md5(name)[0:8]
Exemple #22
0
 def _calc_group(name):
     return 'lsm_' + md5(name)[0:8]
Exemple #23
0
 def _calculate_export_md5(export_path, options):
     opts = TargetdStorage._option_string(options)
     return md5(export_path + opts)
Exemple #24
0
 def _tgt_init_to_lsm(tgt_init, sys_id):
     return AccessGroup(
         "%s%s" % (
             TargetdStorage._FAKE_AG_PREFIX, md5(tgt_init['init_id'])),
         'N/A', [tgt_init['init_id']], AccessGroup.INIT_TYPE_ISCSI_IQN,
         sys_id)
Exemple #25
0
 def _tgt_init_to_lsm(tgt_init, sys_id):
     return AccessGroup(
         "%s%s" %
         (TargetdStorage._FAKE_AG_PREFIX, md5(tgt_init['init_id'])), 'N/A',
         [tgt_init['init_id']], AccessGroup.INIT_TYPE_ISCSI_IQN, sys_id)
Exemple #26
0
 def _calculate_export_md5(export_path, options):
     opts = TargetdStorage._option_string(options)
     return md5(export_path + opts)