def _create_database(self, db_name): LOG.debug("Creating database %s." % db_name) sys_pwd = service.new_oracle_password() self.ora_config.root_password = sys_pwd try: run_sys_command( ("dbca -silent -createDatabase " "-templateName %(template)s " "-gdbName %(gdbname)s " "-sid %(sid)s " "-sysPassword %(pswd)s " "-systemPassword %(pswd)s " "-storageType FS " "-characterSet %(db_charset)s " "-memoryPercentage %(db_ram)s" % {'gdbname': db_name, 'sid': db_name, 'pswd': sys_pwd, 'db_charset': CONF.get(MANAGER).db_charset, 'db_ram': CONF.get(MANAGER).db_ram, 'template': CONF.get(MANAGER).template})) except exception.ProcessExecutionError: LOG.exception(_( "There was an error creating database: %s.") % db_name) raise # Create the Trove admin user admin_pwd = self.ora_config.admin_password if not admin_pwd: admin_pwd = service.new_oracle_password() self.ora_config.admin_password = admin_pwd with self.cursor(db_name, user_id='sys', password=sys_pwd) as sys_cursor: sys_cursor.execute(str(sql_query.CreateTablespace( ADMIN_USER_NAME))) sys_cursor.execute(str(sql_query.CreateUser(ADMIN_USER_NAME, admin_pwd))) sys_cursor.execute(str( sql_query.Grant(ADMIN_USER_NAME, ['SYSDBA', 'SYSOPER']))) LOG.debug("Successfully created database.")
def _create_database(self, db_name): LOG.debug("Creating pluggable database %s." % db_name) if not re.match(r'[a-zA-Z0-9]\w{,63}$', db_name): raise exception.BadRequest( _('Database name %(name)s is not valid. Oracle pluggable ' 'database names restrictions: limit of 64 characters, use ' 'only alphanumerics and underscores, cannot start with an ' 'underscore.') % {'name': db_name}) with self.cursor(self.ora_config.cdb_name) as cursor: cursor.execute(str( sql_query.CreatePDB( db_name, self.root_user_name, service.new_oracle_password()))) cursor.execute(str(sql_query.AlterPDB(db_name, 'OPEN'))) LOG.debug("Successfully created pluggable database")
def _create_database(self, db_name): LOG.debug("Creating database %s." % db_name) sys_pwd = service.new_oracle_password() self.ora_config.root_password = sys_pwd try: run_sys_command(("dbca -silent -createDatabase " "-templateName %(template)s " "-gdbName %(gdbname)s " "-sid %(sid)s " "-sysPassword %(pswd)s " "-systemPassword %(pswd)s " "-storageType FS " "-characterSet %(db_charset)s " "-memoryPercentage %(db_ram)s" % { 'gdbname': db_name, 'sid': db_name, 'pswd': sys_pwd, 'db_charset': CONF.get(MANAGER).db_charset, 'db_ram': CONF.get(MANAGER).db_ram, 'template': CONF.get(MANAGER).template })) except exception.ProcessExecutionError: LOG.exception( _("There was an error creating database: %s.") % db_name) raise # Create the Trove admin user admin_pwd = self.ora_config.admin_password if not admin_pwd: admin_pwd = service.new_oracle_password() self.ora_config.admin_password = admin_pwd with self.cursor(db_name, user_id='sys', password=sys_pwd) as sys_cursor: sys_cursor.execute( str(sql_query.CreateUser(ADMIN_USER_NAME, admin_pwd))) sys_cursor.execute( str(sql_query.Grant(ADMIN_USER_NAME, ['SYSDBA', 'SYSOPER']))) LOG.debug("Successfully created database.")