Пример #1
0
 def update_lv_info(self, lv_name, lv_name_config):
     update_data_sql = "update lv set name='{0}' where name='{1}'".\
         format(lv_name_config, lv_name)
     cursor = conn.cursor()
     cursor.execute(update_data_sql)
     cursor.close()
     conn.commit()
Пример #2
0
 def __init__(self):
     cursor = conn.cursor()
     create_table = 'create table if not exists lv ' \
                    '(name varchar(60), lv_type varchar(30))'
     cursor.execute(create_table)
     cursor.close()
     conn.commit()
Пример #3
0
 def save_lv_info(self, lv_name, lv_type):
     insert_data_sql = "insert into lv values ('{0}','{1}')".\
         format(lv_name, lv_type)
     cursor = conn.cursor()
     cursor.execute(insert_data_sql)
     cursor.close()
     conn.commit()
 def delete_raid_id_name(vir_drv_id):
     delete_data = "delete from raid_id_name where vd = '{0}'".\
         format(vir_drv_id)
     cursor = conn.cursor()
     cursor.execute(delete_data)
     cursor.close()
     conn.commit()
 def save_raid_info(self, vir_drv_id, tag):
     insert_data_sql = "insert into raid values ('{0}','{1}')".\
         format(vir_drv_id, tag)
     cursor = conn.cursor()
     cursor.execute(insert_data_sql)
     cursor.close()
     conn.commit()
 def save_raid_id_name(vir_drv_id, raid_name):
     insert_data = "insert into raid_id_name values ('{0}', '{1}')".\
         format(vir_drv_id, raid_name)
     cursor = conn.cursor()
     cursor.execute(insert_data)
     cursor.close()
     conn.commit()
 def delete_raid_cache(self, vir_drv_id):
     delete_data = "delete from raid_config where vd = '{0}'".\
         format(vir_drv_id)
     cursor = conn.cursor()
     cursor.execute(delete_data)
     cursor.close()
     conn.commit()
    def get_raid_cache(self, vir_drv_id):
        query_data = "select raid_name, raid_level, raid_capacity, physdrvs, " \
                     "stripsz from raid_config where vd='{0}'".format(vir_drv_id)
        cursor = conn.cursor()
        result = cursor.execute(query_data).fetchall()
        cursor.close()
        conn.commit()
        raid_name = None
        raid_level = None
        raid_capacity = None
        physdrvs = None
        stripsz = None

        if result:
            raid_name = result[0][0]
            raid_level = result[0][1]
            raid_capacity = result[0][2]
            physdrvs = re.findall('[0-9]+', result[0][3])
            stripsz = result[0][4]

        return {
            'raid_name': raid_name,
            'raid_level': raid_level,
            'raid_capacity': raid_capacity,
            'physdrvs': physdrvs,
            'stripsz': stripsz
        }
    def get_raid_tag_by_vd(self, vir_drv_id):
        if vir_drv_id not in ARRaidManager.get_raid_id():
            raise ARRaidException(RaidStatusPool.ID_RAID_NOT_FOUND)

        raid_tag = None
        query_sql = "select tag from raid where vd='{0}'".format(vir_drv_id)
        cursor = conn.cursor()
        result = cursor.execute(query_sql).fetchall()
        cursor.close()
        conn.commit()

        if result:
            raid_tag = result[0][0]

        return {'raid_tag': raid_tag}
 def __init__(self):
     self._megacli = Megacli()
     cursor = conn.cursor()
     create_table = 'create table if not exists raid' \
                    '(vd varchar(5), tag varchar(10))'
     create_table2 = 'create table if not exists raid_config ' \
                     '(vd varchar(5), raid_name varchar(30), ' \
                     'raid_level varchar(10), raid_capacity varchar(10), ' \
                     'physdrvs varchar(20), stripsz varchar(10))'
     create_table3 = 'create table if not exists raid_id_name ' \
                     '(vd varchar(5), raid_name varchar(30))'
     cursor.execute(create_table)
     cursor.execute(create_table2)
     cursor.execute(create_table3)
     cursor.close()
     conn.commit()
    def save_raid_cache(self, vir_drv_id):
        name_level_capacity_stripsz = self.get_raid_name_level_capacity_stripsz(
            vir_drv_id)
        physdrvs = self.get_one_raid_level_and_physdrvs(vir_drv_id)['physdrvs']
        insert_data = "insert into raid_config values ('{0}','{1}','{2}','{3}'," \
                      "\"{4}\",'{5}')".\
            format(vir_drv_id,
                   name_level_capacity_stripsz['raid_name'],
                   name_level_capacity_stripsz['raid_level'],
                   name_level_capacity_stripsz['raid_capacity'],
                   physdrvs,
                   name_level_capacity_stripsz['stripsz'])

        cursor = conn.cursor()
        cursor.execute(insert_data)
        cursor.close()
        conn.commit()
    def get_raid_id_by_name(self, raid_name):
        """
            通过缓存获取数据
        """
        query_data = "select vd, raid_name from raid_id_name"
        cursor = conn.cursor()
        vals = cursor.execute(query_data).fetchall()
        cursor.close()
        conn.commit()
        vir_drv_id = None

        if vals:
            for val in vals:
                if raid_name in val:
                    vir_drv_id = val[0]
                break

        return {'vir_drv_id': vir_drv_id}
    def get_raid_id():
        """
            成功创建raid,同时将raid的ID写入缓存中。
            同样,通过缓存来获取raid的ID。这样,系统raid
            的ID号不会被写入缓存中,即间接过滤掉了系统raid。
        """
        query_data = 'select vd from raid_id_name'
        cursor = conn.cursor()
        result = cursor.execute(query_data).fetchall()
        cursor.close()
        conn.commit()
        raid_ids = []

        if result:
            for val in result:
                raid_ids.append(val[0])

        return raid_ids
Пример #14
0
    def get_lvtype_by_name(self, lv_name):
        lv_names = ARLvManager.get_lv_names()
        if lv_name not in lv_names:
            raise ARLvException(LvStatusPool.ID_LV_NOT_FOUND)

        lv_type = None
        query_sql = "select lv_type from lv where name='{0}'".\
            format(lv_name)
        cursor = conn.cursor()
        result = cursor.execute(query_sql).fetchall()
        cursor.close()
        conn.commit()

        if result:
            lv_type = result[0][0]

        return {
            'lv_type': lv_type,
        }
Пример #15
0
 def delete_lv_info(self, lv_name):
     delete_data_sql = "delete from lv where name='{0}'".format(lv_name)
     cursor = conn.cursor()
     cursor.execute(delete_data_sql)
     cursor.close()
     conn.commit()
 def delete_raid_info(self, vir_drv_id):
     delete_data_sql = "delete from raid where vd='{0}'".format(vir_drv_id)
     cursor = conn.cursor()
     cursor.execute(delete_data_sql)
     cursor.close()
     conn.commit()