Beispiel #1
0
    def create_app_table(self):
        ""

        app_conf = self.conf.get_app_conf()
        app_db = app_conf['db_path']
        sql_tools = SqliteTools(app_db)

        # 1 服务表
        create_app_table_sql = '''CREATE TABLE `%s` (
                            `instanceId`     varchar(128) NOT NULL,
                            `appName`        varchar(128) default NULL,
                            `appType`        varchar(128) NOT NULL,
                            `serviceId`      varchar(128) NOT NULL,
                            
                            `vmName`         varchar(128) NOT NULL,
                            `domain`         varchar(128) default NULL,
                            `listenPort`     int(10) default 0,
                            `param`          text  default NULL,
                             
                            `status`     varchar(12) NOT NULL, 
                            
                            `createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                            `remark`     varchar(1024) DEFAULT NULL,
                             PRIMARY KEY (`instanceId`)
                        )''' % APPTABLE

        sql_tools.create_table(create_app_table_sql)
Beispiel #2
0
    def create_lvm_table(self):
        ""

        create_table_sql = '''CREATE TABLE `lvm` (
                            `lvmName` varchar(64) NOT NULL,
                            `vgName` varchar(200) NOT NULL,
                            `lvmSize` double(24) NOT NULL,
                            `lvmDir`  varchar(128) DEFAULT NULL,
                            `mountDir`  varchar(128) DEFAULT NULL,
                            `lvmMkfs`  varchar(32) DEFAULT NULL,
                            `lvmType`  varchar(32) DEFAULT NULL,
                            `createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                            `remark` varchar(1024) DEFAULT NULL,
                             PRIMARY KEY (`lvmName`)
                        )'''

        storage_conf = self.conf.get_storage_conf()
        storage_db = storage_conf['db_path']
        sql_tools = SqliteTools(storage_db)
        sql_tools.create_table(create_table_sql)
Beispiel #3
0
 def create_images_table(self):
     ""
     
     create_table_sql = '''CREATE TABLE `images` (
                         `imageId` varchar(64) NOT NULL,
                         `name` varchar(200) DEFAULT NULL,
                         `system` varchar(64) DEFAULT NULL,
                         `version` varchar(64) DEFAULT NULL,
                         `arch` varchar(64) DEFAULT NULL,
                         `machine`  varchar(64) DEFAULT NULL,
                         `size` double(24) DEFAULT NULL,
                         `savepath` varchar(64) DEFAULT NULL,
                         `ext` varchar(64) DEFAULT NULL,
                         `status` int(1) DEFAULT 0,
                         `vtype` varchar(64) DEFAULT NULL,
                         `createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                         `remark` varchar(1024) DEFAULT NULL,
                          PRIMARY KEY (`imageId`)
                     )'''
     
     image_conf = self.conf.get_image_conf()
     images_db = image_conf['db_path']
     sql_tools = SqliteTools(images_db)
     sql_tools.create_table(create_table_sql)
Beispiel #4
0
    def create_network_table(self):
        '''
        create sqlite table
        '''
        '''
            id, 主键ID uuid
            groupName,  对应的桥名称
            macAddress, 虚拟的mack地址
            ipAddress,  虚拟的静态IP
            hostname,   虚拟机主机名
            ifName      虚拟机网口的名
        '''
        create_dhcp_table_sql = '''CREATE TABLE `dhcp` (
                            `id` varchar(64) PRIMARY KEY NOT NULL,
                            `groupName` varchar(64) NOT NULL,
                            `macAddress` varchar(64) NOT NULL,
                            `ipAddress` varchar(64) NOT NULL,
                            `hostname` varchar(256) NOT NULL,
                            `ifName` varchar(64) NOT NULL
                        )'''
        '''
            id,主键ID uuid
            groupName, 对应的桥名称
            dip, 通过groupName从配置中取得,外网IP 
            dPort, 对外端口
            tIp,  虚拟机IP
            tPort 虚拟机端口
        '''
        create_proxyPort_table_sql = '''CREATE TABLE `proxyPort` (
                            `id` varchar(64) PRIMARY KEY NOT NULL,
                            `groupName` varchar(64),
                            `dip` varchar(64) NOT NULL,
                            `dPort` int,
                            `tIp` varchar(64) NOT NULL,
                            `tPort` varchar(64) NOT NULL
                        )'''
        '''
            id,主键ID uuid
            pType, 1:vnc端口,2:其它业务端口
        '''
        create_businessPort_table_sql = '''CREATE TABLE `businessPort` (
                            `id` varchar(64) PRIMARY KEY NOT NULL,
                            `pType` varchar(5) NOT NULL,
                            `dPort` int
                        )'''

        network_conf = self.conf.get_network_conf()
        network_db = network_conf['db_path']
        sql_tools = SqliteTools(network_db)
        sql_tools.create_table(create_dhcp_table_sql)
        sql_tools.create_table(create_proxyPort_table_sql)
        sql_tools.create_table(create_businessPort_table_sql)
Beispiel #5
0
    def create_vm_table(self):
        ""

        virtual_conf = self.conf.get_virtual_conf()
        virtual_db = virtual_conf['db_path']
        sql_tools = SqliteTools(virtual_db)

        # 1 虚拟机表
        create_vm_table_sql = '''CREATE TABLE `%s` (
                            `vmName`     varchar(128) NOT NULL,
                            `vmFile`     varchar(128) NOT NULL,
                            
                            `imageName`  varchar(128) NOT NULL,
                            `imageFile`  varchar(128) NOT NULL,
                            
                            `vmSize`     double(24)  NOT NULL,
                            `memSize`    int(10)  NOT NULL,
                            `vcpus`      int(2)  NOT NULL,

                            `vncPort`    int(4) NOT NULL,
                            `vncPasswd`  int(4) NOT NULL,
                            
                            `interfaces` varchar(256) NOT NULL,
                            `ip`         varchar(128) NOT NULL,
                            
                            `createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                            `remark`     varchar(1024) DEFAULT NULL,
                             PRIMARY KEY (`vmName`)
                        )''' % VMTABLE

        sql_tools.create_table(create_vm_table_sql)

        # 2 虚拟机硬盘表
        create_vmdisk_table_sql = '''CREATE TABLE `%s` (
                            `vmName`     varchar(128) NOT NULL,
                            
                            `diskSize`   int(10)  NOT NULL,
                            `diskName`   varchar(128) NOT NULL,
                            `diskTarget` varchar(128) NOT NULL,
                            `diskFile`   varchar(128) NOT NULL,
                            `diskType`   varchar(128) NOT NULL,

                            `createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                            `remark`     varchar(1024) DEFAULT NULL
                        )''' % DISKTABLE

        sql_tools.create_table(create_vmdisk_table_sql)

        # 3 虚拟机端口表
        create_vmproxy_table_sql = '''CREATE TABLE `%s` (
                            `vmName`     varchar(128) NOT NULL,
                            
                            `ip`   varchar(128)  NOT NULL,
                            `port`   int(10) NOT NULL,
                            `proxyIp` varchar(128) NOT NULL,
                            `proxyPort`   int(10) NOT NULL,
                            
                            `createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                            `remark`     varchar(1024) DEFAULT NULL
                        )''' % VMPROXY

        sql_tools.create_table(create_vmproxy_table_sql)