Пример #1
0
 def delete_storage_class_from_db(self, storage_class):
     rlt = StorageClassDB.instance().delete_storage_class(self.cluster_name, storage_class)
     if rlt.success:
         LogDel(3,  self.operator, u'从集群[%s]删除共享卷[%s]成功'%(self.cluster_name, storage_class))
     else:
         Log(1, 'DeleteStorageNodeWork.delete_storage_class delete_storage_class[%s][%s] from etcd[%s]fail,as[%s]'%(self.cluster_name, storage_class, rlt.message))
     return rlt
Пример #2
0
 def get_sc_by_group(self, group):
     rlt = StorageClassDB.instance().get_sc_by_group(group)
     if not rlt.success:
         Log(
             1, 'Storage.get_sc_by_group [%s]fail,as[%s]' %
             (group, rlt.message))
     return rlt
Пример #3
0
 def storageclasses(self, cluster, group=''):
     rlt = StorageClassDB.instance().read_storage_class_list(cluster, group)
     if not rlt.success:
         Log(
             1, 'Storage read_storage_class_list[%s][%s]fail,as[%s]' %
             (cluster, group, rlt.message))
     return rlt
Пример #4
0
 def delete_storage_class_info(self):
     rlt = StorageClassDB.instance().delete_storage_class(
         self.cluster_name, self.storage_class_name)
     if not rlt.success:
         Log(
             1,
             'AddStorageClassWork.delete_pv delete_storage_class[%s][%s]fail,as[%s]'
             % (self.cluster_name, self.storage_class_name, rlt.message))
     return rlt
Пример #5
0
 def is_volume_exist(self):
     if StorageClassDB.instance().is_storage_class_exist(
             self.cluster_name, self.storage_class_name):
         return True
     else:
         Log(
             1, 'The storage class[%s][%s] lost' %
             (self.cluster_name, self.storage_class_name))
         raise InternalException("storage_class_name deleted.",
                                 TASK_CANCEL_ERR)
Пример #6
0
 def delete_storage_classes(self):
     rlt = StorageClassDB.instance().get_sc_by_mount_ip(self.cluster_name, self.ip)
     if not rlt.success:
         Log(1, 'DeleteStorageNodeWork get_sc_by_mount_ip[%s][%s] fail,as[%s]'%(self.cluster_name, self.ip, rlt.message))
         return Result('fail')
     
     for sc in rlt.content:
         if 'storage_class_name' in sc and sc['storage_class_name']:
             self.delete_storage_class(self.cluster_name, sc, self.operator)
             
     return Result(len(rlt.content))
Пример #7
0
    def save_storage_class_info(self):
        if not self.volume_id:
            Log(
                1,
                'AddStorageClassWork.save_storage_class_info fail,as[the volume_id invalid]'
            )
            return Result('', INVALID_PARAM_ERR, 'the volume_id invalid')

        info = {
            'volume_id': self.volume_id,
            'access_path': self.storage_access_path,
            'data_volume_server': self.data_volume_server,
            'data_volume_path': self.data_volume_path,
            'status': self.volume_status
        }
        rlt = StorageClassDB.instance().update_storage_class(
            self.cluster_name, self.storage_class_name, info)
        if not rlt.success:
            Log(
                1,
                'AddStorageClassWork.save_storage_class_info update_storage_class[%s][%s]fail,as[%s]'
                % (self.cluster_name, self.storage_class_name, rlt.message))
        return rlt
Пример #8
0
        if 'capacity' not in data or not data['capacity']:
            return Result('', INVALID_PARAM_ERR, 'capacity is invalid',
                          http.BAD_REQUEST)

        capacity = Parse2Float(data['capacity'])
        if capacity < 1:
            return Result('', INVALID_PARAM_ERR,
                          'capacity must be equal or greater than 1',
                          http.BAD_REQUEST)

#         if 'volume_type' not in data or data['volume_type'] not in [STORAGE_SHARE_TYPE_NFS, STORAGE_SHARE_TYPE_ISCSI]:
#             return Result('',INVALID_PARAM_ERR, 'volume type is invalid', http.BAD_REQUEST)

        data['volume_type'] = STORAGE_SHARE_TYPE_NFS

        if StorageClassDB.instance().is_storage_class_exist(
                data['cluster_name'], data['storage_class_name']):
            return Result('', INVALID_PARAM_ERR,
                          'storage class name is repeat', http.BAD_REQUEST)

        if VolumeDB.instance().is_volume_exist(data['cluster_name'],
                                               data['volume_name']):
            return Result('', INVALID_PARAM_ERR, 'volume name is repeat',
                          http.BAD_REQUEST)

        _calc = self.calc_cluster_info(data['cluster_name'])
        if (_calc['free'] >> 20) < capacity * 1024 * 2:
            return Result('', CAPACITY_LESS_THAN_REQUEST_ERR,
                          'Insufficient disk space')

        data['creator'] = args.get('passport', {}).get('username', '')
        rlt = StorageMgr.instance().create_storage_class(data)