Пример #1
0
class Vminfo(object):
    def __init__(self):
        self.__helper = MySqlHelper()

    def Get_Dict(self):
        sql = "select * from vminfo"
        return self.__helper.Get_Dict(sql)

    def Get_routerinfo_Dict(self):
        sql = "select * from routerinfo"
        return self.__helper.Get_routerinfo_Dict(sql)

    def Get_access_network_Dict(self):
        sql = "select * from routetable"
        return self.__helper.Get_access_network_Dict(sql)

    def Insert_vm_info(self, name, instance_name, ip, mac):
        sql = "insert into vminfo(name,instance_name,ip,mac) values('%s','%s','%s','%s')" % (
            name, instance_name, ip, mac)
        return self.__helper.Insert_vm_info(sql)

    def Insert_router_info(self, name, iplist):
        sql = 'insert into routerinfo(name,iplist) values("%s","%s")' % (
            name, iplist)
        return self.__helper.Insert_router_info(sql)
Пример #2
0
class Vminfo(object):
    def __init__(self):
        self.__helper = MySqlHelper()

    def Get_Dict(self):
        sql = "select * from vminfo"
        return self.__helper.Get_Dict(sql)

    def Insert_vm_info(self, name, instance_name, ip, mac):
        sql = "insert into vminfo(name,instance_name,ip,mac) values('%s','%s','%s','%s')" % (
            name, instance_name, ip, mac)
        return self.__helper.Insert_vm_info(sql)
Пример #3
0
class Userinfo(object):
    def __init__(self):
        self.__helper = MySqlHelper()

    def Get_One(self, id):
        sql = 'select * from userinfo where id=%s'
        params = (id, )
        return self.__helper.Get_One(sql, params)

    def CheckValidate(self, username, password):
        sql = 'select * from userinfo where username=%s and password=%s'
        params = (username, password)
        return self.__helper.Get_One(sql, params)
Пример #4
0
class Chatlog(object):  # Table chatlog
    def __init__(self):
        self.__helper = MySqlHelper()

    def View_log(self):
        sql = 'SELECT * FROM chatlog'
        params = ()
        return self.__helper.Get_Dict(sql, params)

    def Insert_Log(self, ls):
        sql = 'INSERT INTO chatlog (cnt) VALUES (%s)'  # postvalues parentheses!
        params = ls
        return self.__helper.Insert_List(sql, params)
Пример #5
0
class Admin(object):
    def __init__(self):
        self.__helper = MySqlHelper()

    def GetOne(self, idr):
        sql = 'select * from admin where id=%s'
        params = (idr, )
        return self.__helper.GetOne(sql, params)

    def CheckValidate(self, username, password):
        sql = 'select * from admin where username=%s and password=%s'
        params = username, password
        result = self.__helper.GetDict(sql, params)
        return result
Пример #6
0
class Admin():
    def __init__(self):
        self.__helper = MySqlHelper()

    def CheckValidate(self, username, password):
        sql = "select * from admin where username=%s and password=%s"
        params = (username, password)
        return self.__helper.getOne(sql, params)
Пример #7
0
class Vminfo(object):
    def __init__(self):
        self.__helper = MySqlHelper()

    def Get_Dict(self):
        sql = "select * from vminfo"
        return self.__helper.Get_Dict(sql)

    def Get_routerinfo_Dict(self):
        sql = "select * from routerinfo"
        return self.__helper.Get_routerinfo_Dict(sql)

    def Get_access_network_Dict(self):
        sql = "select * from routetable"
        return self.__helper.Get_access_network_Dict(sql)

    def Insert_vm_info(self, name, instance_name, ip, mac):
        sql = "insert into vminfo(name,instance_name,ip,mac) values('%s','%s','%s','%s')" % (
            name, instance_name, ip, mac)
        return self.__helper.Insert_vm_info(sql)

    def Insert_router_info(self, name, iplist):
        sql = 'insert into routerinfo(name,iplist) values("%s","%s")' % (
            name, iplist)
        return self.__helper.Insert_router_info(sql)

    def Delete_all_in_routerinfo(self):
        sql = 'delete from routerinfo'
        return self.__helper.Delete_all(sql)

    def Delete_all_in_routetable(self):
        sql = 'delete from routetable'
        return self.__helper.Delete_all(sql)

    def Delete_all_in_vminfo(self):
        sql = 'delete from vminfo'
        return self.__helper.Delete_all(sql)

    def Get_network_info_Dict(self):
        sql = "select ports.id,subnets.network_id,subnets.cidr from ports inner join subnets on ports.network_id=subnets.network_id and subnets.name not like '%ipv6%'"
        return self.__helper.Get_network_info_Dict(sql)

    def Insert_routetable_network(self, network):
        sql = "insert into routetable(network) values ('%s')" % network
        return self.__helper.Insert_routetable_network(sql)
Пример #8
0
 def __init__(self):
     self.__helper = MySqlHelper()