@添加数据库
(self, args)
| 104 | return self.ModifyBaseCloudServer(args) |
| 105 | |
| 106 | def AddDatabase(self, args): |
| 107 | """ |
| 108 | @添加数据库 |
| 109 | |
| 110 | """ |
| 111 | dtype = "sqlserver" |
| 112 | res = self.add_base_database(args, dtype) |
| 113 | if not res['status']: return res |
| 114 | |
| 115 | data_name = res['data_name'] |
| 116 | username = res['username'] |
| 117 | password = res['data_pwd'] |
| 118 | |
| 119 | if re.match("^\d+", data_name): |
| 120 | return public.returnMsg(False, 'SQLServer数据库不能以数字开头!') |
| 121 | |
| 122 | reg_count = 0 |
| 123 | regs = ['[a-z]', '[A-Z]', '\W', '[0-9]'] |
| 124 | for x in regs: |
| 125 | if re.search(x, password): reg_count += 1 |
| 126 | |
| 127 | if len(password) < 8 or len(password) > 128 or reg_count < 3: |
| 128 | return public.returnMsg(False, 'SQLServer密码复杂性策略不匹配,应为8-128位,并包含大写,小写,数字,特殊符号其中任何3项!') |
| 129 | |
| 130 | try: |
| 131 | self.sid = int(args['sid']) |
| 132 | except: |
| 133 | self.sid = 0 |
| 134 | |
| 135 | dtype = 'SQLServer' |
| 136 | # 添加SQLServer |
| 137 | mssql_obj = self.get_mssql_obj_by_sid(self.sid) |
| 138 | result = mssql_obj.execute("CREATE DATABASE %s" % data_name) |
| 139 | isError = self.IsSqlError(result) |
| 140 | if isError != None: return isError |
| 141 | |
| 142 | mssql_obj.execute("DROP LOGIN %s" % username) |
| 143 | |
| 144 | # 添加用户 |
| 145 | self.__CreateUsers(data_name, username, password, '127.0.0.1') |
| 146 | |
| 147 | if not hasattr(args, 'ps'): args['ps'] = public.getMsg('INPUT_PS') |
| 148 | addTime = time.strftime('%Y-%m-%d %X', time.localtime()) |
| 149 | |
| 150 | pid = 0 |
| 151 | if hasattr(args, 'pid'): pid = args.pid |
| 152 | |
| 153 | if hasattr(args, 'contact'): |
| 154 | site = public.M('sites').where("id=?", (args.contact,)).field('id,name').find() |
| 155 | if site: |
| 156 | pid = int(args.contact) |
| 157 | args['ps'] = site['name'] |
| 158 | |
| 159 | db_type = 0 |
| 160 | if self.sid: db_type = 2 |
| 161 | |
| 162 | public.set_module_logs('linux_sqlserver', 'AddDatabase', 1) |
| 163 | # 添加入SQLITE |
nothing calls this directly
no test coverage detected