server/serverctl.py
changeset 2476 1294a6bdf3bf
parent 2473 490f88fb99b6
child 2493 9806571ea790
--- a/server/serverctl.py	Fri Jul 24 13:50:59 2009 +0200
+++ b/server/serverctl.py	Fri Jul 24 14:33:37 2009 +0200
@@ -58,10 +58,10 @@
 
 def system_source_cnx(source, dbms_system_base=False,
                       special_privs='CREATE/DROP DATABASE', verbose=True):
-    """shortcut to get a connextion to the application system database
+    """shortcut to get a connextion to the instance system database
     defined in the given config. If <dbms_system_base> is True,
     connect to the dbms system database instead (for task such as
-    create/drop the application database)
+    create/drop the instance database)
     """
     if dbms_system_base:
         from logilab.common.adbh import get_adv_func_helper
@@ -119,7 +119,7 @@
     cfgname = 'repository'
 
     def bootstrap(self, cubes, inputlevel=0):
-        """create an application by copying files from the given cube and by
+        """create an instance by copying files from the given cube and by
         asking information necessary to build required configuration files
         """
         config = self.config
@@ -182,7 +182,7 @@
     cfgname = 'repository'
 
     def cleanup(self):
-        """remove application's configuration and database"""
+        """remove instance's configuration and database"""
         from logilab.common.adbh import get_adv_func_helper
         source = self.config.sources()['system']
         dbname = source['db-name']
@@ -231,19 +231,19 @@
 
 
 # repository specific commands ################################################
-class CreateApplicationDBCommand(Command):
-    """Create the system database of an application (run after 'create').
+class CreateInstanceDBCommand(Command):
+    """Create the system database of an instance (run after 'create').
 
     You will be prompted for a login / password to use to connect to
     the system database.  The given user should have almost all rights
     on the database (ie a super user on the dbms allowed to create
     database, users, languages...).
 
-    <application>
-      the identifier of the application to initialize.
+    <instance>
+      the identifier of the instance to initialize.
     """
     name = 'db-create'
-    arguments = '<application>'
+    arguments = '<instance>'
 
     options = (
         ("create-db",
@@ -262,7 +262,7 @@
         from logilab.common.adbh import get_adv_func_helper
         from indexer import get_indexer
         verbose = self.get('verbose')
-        appid = pop_arg(args, msg="No application specified !")
+        appid = pop_arg(args, msg="No instance specified !")
         config = ServerConfiguration.config_for(appid)
         create_db = self.config.create_db
         source = config.sources()['system']
@@ -308,7 +308,7 @@
                 helper.create_language(cursor, extlang)
         cursor.close()
         cnx.commit()
-        print '-> database for application %s created and necessary extensions installed.' % appid
+        print '-> database for instance %s created and necessary extensions installed.' % appid
         print
         if confirm('Do you want to run db-init to initialize the "system database" ?'):
             cmd_run('db-init', config.appid)
@@ -317,18 +317,18 @@
                    '"cubicweb-ctl db-init %s".' % self.config.appid)
 
 
-class InitApplicationCommand(Command):
-    """Initialize the system database of an application (run after 'db-create').
+class InitInstanceCommand(Command):
+    """Initialize the system database of an instance (run after 'db-create').
 
     You will be prompted for a login / password to use to connect to
     the system database.  The given user should have the create tables,
     and grant permissions.
 
-    <application>
-      the identifier of the application to initialize.
+    <instance>
+      the identifier of the instance to initialize.
     """
     name = 'db-init'
-    arguments = '<application>'
+    arguments = '<instance>'
 
     options = (
         ("drop",
@@ -341,21 +341,21 @@
     def run(self, args):
         print '\n'+underline_title('Initializing the "system database"')
         from cubicweb.server import init_repository
-        appid = pop_arg(args, msg="No application specified !")
+        appid = pop_arg(args, msg="No instance specified !")
         config = ServerConfiguration.config_for(appid)
         init_repository(config, drop=self.config.drop)
 
 
-class GrantUserOnApplicationCommand(Command):
+class GrantUserOnInstanceCommand(Command):
     """Grant a database user on a repository system database.
 
-    <application>
-      the identifier of the application
+    <instance>
+      the identifier of the instance
     <user>
       the database's user requiring grant access
     """
     name = 'db-grant-user'
-    arguments = '<application> <user>'
+    arguments = '<instance> <user>'
 
     options = (
         ("set-owner",
@@ -367,7 +367,7 @@
     def run(self, args):
         """run the command with its specific arguments"""
         from cubicweb.server.sqlutils import sqlexec, sqlgrants
-        appid = pop_arg(args, 1, msg="No application specified !")
+        appid = pop_arg(args, 1, msg="No instance specified !")
         user = pop_arg(args, msg="No user specified !")
         config = ServerConfiguration.config_for(appid)
         source = config.sources()['system']
@@ -385,22 +385,22 @@
             print '-> an error occured:', ex
         else:
             cnx.commit()
-            print '-> rights granted to %s on application %s.' % (appid, user)
+            print '-> rights granted to %s on instance %s.' % (appid, user)
 
 class ResetAdminPasswordCommand(Command):
     """Reset the administrator password.
 
-    <application>
-      the identifier of the application
+    <instance>
+      the identifier of the instance
     """
     name = 'reset-admin-pwd'
-    arguments = '<application>'
+    arguments = '<instance>'
 
     def run(self, args):
         """run the command with its specific arguments"""
         from cubicweb.server.sqlutils import sqlexec, SQL_PREFIX
         from cubicweb.server.utils import crypt_password, manager_userpasswd
-        appid = pop_arg(args, 1, msg="No application specified !")
+        appid = pop_arg(args, 1, msg="No instance specified !")
         config = ServerConfiguration.config_for(appid)
         sourcescfg = config.read_sources_file()
         try:
@@ -433,15 +433,15 @@
 
 
 class StartRepositoryCommand(Command):
-    """Start an CubicWeb RQL server for a given application.
+    """Start an CubicWeb RQL server for a given instance.
 
     The server will be accessible through pyro
 
-    <application>
-      the identifier of the application to initialize.
+    <instance>
+      the identifier of the instance to initialize.
     """
     name = 'start-repository'
-    arguments = '<application>'
+    arguments = '<instance>'
 
     options = (
         ("debug",
@@ -451,7 +451,7 @@
 
     def run(self, args):
         from cubicweb.server.server import RepositoryServer
-        appid = pop_arg(args, msg="No application specified !")
+        appid = pop_arg(args, msg="No instance specified !")
         config = ServerConfiguration.config_for(appid)
         debug = self.config.debug
         # create the server
@@ -514,7 +514,7 @@
         return
     # version of installed software
     eversion = dbversions['cubicweb']
-    status = application_status(config, eversion, dbversions)
+    status = instance_status(config, eversion, dbversions)
     # * database version > installed software
     if status == 'needsoftupgrade':
         print "database is using some earlier version than installed software!"
@@ -532,7 +532,7 @@
     #   ok!
 
 
-def application_status(config, cubicwebapplversion, vcconf):
+def instance_status(config, cubicwebapplversion, vcconf):
     cubicwebversion = config.cubicweb_version()
     if cubicwebapplversion > cubicwebversion:
         return 'needsoftupgrade'
@@ -559,14 +559,14 @@
 
 
 class DBDumpCommand(Command):
-    """Backup the system database of an application.
+    """Backup the system database of an instance.
 
-    <application>
-      the identifier of the application to backup
+    <instance>
+      the identifier of the instance to backup
       format [[user@]host:]appname
     """
     name = 'db-dump'
-    arguments = '<application>'
+    arguments = '<instance>'
 
     options = (
         ("output",
@@ -582,7 +582,7 @@
         )
 
     def run(self, args):
-        appid = pop_arg(args, 1, msg="No application specified !")
+        appid = pop_arg(args, 1, msg="No instance specified !")
         if ':' in appid:
             host, appid = appid.split(':')
             _remote_dump(host, appid, self.config.output, self.config.sudo)
@@ -591,13 +591,13 @@
 
 
 class DBRestoreCommand(Command):
-    """Restore the system database of an application.
+    """Restore the system database of an instance.
 
-    <application>
-      the identifier of the application to restore
+    <instance>
+      the identifier of the instance to restore
     """
     name = 'db-restore'
-    arguments = '<application> <backupfile>'
+    arguments = '<instance> <backupfile>'
 
     options = (
         ("no-drop",
@@ -609,23 +609,23 @@
         )
 
     def run(self, args):
-        appid = pop_arg(args, 1, msg="No application specified !")
+        appid = pop_arg(args, 1, msg="No instance specified !")
         backupfile = pop_arg(args, msg="No backup file specified !")
         _local_restore(appid, backupfile, not self.config.no_drop)
 
 
 class DBCopyCommand(Command):
-    """Copy the system database of an application (backup and restore).
+    """Copy the system database of an instance (backup and restore).
 
-    <src-application>
-      the identifier of the application to backup
+    <src-instance>
+      the identifier of the instance to backup
       format [[user@]host:]appname
 
-    <dest-application>
-      the identifier of the application to restore
+    <dest-instance>
+      the identifier of the instance to restore
     """
     name = 'db-copy'
-    arguments = '<src-application> <dest-application>'
+    arguments = '<src-instance> <dest-instance>'
 
     options = (
         ("no-drop",
@@ -648,8 +648,8 @@
 
     def run(self, args):
         import tempfile
-        srcappid = pop_arg(args, 1, msg="No source application specified !")
-        destappid = pop_arg(args, msg="No destination application specified !")
+        srcappid = pop_arg(args, 1, msg="No source instance specified !")
+        destappid = pop_arg(args, msg="No destination instance specified !")
         _, output = tempfile.mkstemp()
         if ':' in srcappid:
             host, srcappid = srcappid.split(':')
@@ -664,13 +664,13 @@
 
 
 class CheckRepositoryCommand(Command):
-    """Check integrity of the system database of an application.
+    """Check integrity of the system database of an instance.
 
-    <application>
-      the identifier of the application to check
+    <instance>
+      the identifier of the instance to check
     """
     name = 'db-check'
-    arguments = '<application>'
+    arguments = '<instance>'
 
     options = (
         ("checks",
@@ -702,7 +702,7 @@
 
     def run(self, args):
         from cubicweb.server.checkintegrity import check
-        appid = pop_arg(args, 1, msg="No application specified !")
+        appid = pop_arg(args, 1, msg="No instance specified !")
         config = ServerConfiguration.config_for(appid)
         config.repairing = self.config.force
         repo, cnx = repo_cnx(config)
@@ -711,19 +711,19 @@
 
 
 class RebuildFTICommand(Command):
-    """Rebuild the full-text index of the system database of an application.
+    """Rebuild the full-text index of the system database of an instance.
 
-    <application>
-      the identifier of the application to rebuild
+    <instance>
+      the identifier of the instance to rebuild
     """
     name = 'db-rebuild-fti'
-    arguments = '<application>'
+    arguments = '<instance>'
 
     options = ()
 
     def run(self, args):
         from cubicweb.server.checkintegrity import reindex_entities
-        appid = pop_arg(args, 1, msg="No application specified !")
+        appid = pop_arg(args, 1, msg="No instance specified !")
         config = ServerConfiguration.config_for(appid)
         repo, cnx = repo_cnx(config)
         session = repo._get_session(cnx.sessionid, setpool=True)
@@ -731,28 +731,28 @@
         cnx.commit()
 
 
-class SynchronizeApplicationSchemaCommand(Command):
+class SynchronizeInstanceSchemaCommand(Command):
     """Synchronize persistent schema with cube schema.
 
     Will synchronize common stuff between the cube schema and the
     actual persistent schema, but will not add/remove any entity or relation.
 
-    <application>
-      the identifier of the application to synchronize.
+    <instance>
+      the identifier of the instance to synchronize.
     """
     name = 'schema-sync'
-    arguments = '<application>'
+    arguments = '<instance>'
 
     def run(self, args):
-        appid = pop_arg(args, msg="No application specified !")
+        appid = pop_arg(args, msg="No instance specified !")
         config = ServerConfiguration.config_for(appid)
         mih = config.migration_handler()
         mih.cmd_synchronize_schema()
 
 
-register_commands( (CreateApplicationDBCommand,
-                    InitApplicationCommand,
-                    GrantUserOnApplicationCommand,
+register_commands( (CreateInstanceDBCommand,
+                    InitInstanceCommand,
+                    GrantUserOnInstanceCommand,
                     ResetAdminPasswordCommand,
                     StartRepositoryCommand,
                     DBDumpCommand,
@@ -760,5 +760,5 @@
                     DBCopyCommand,
                     CheckRepositoryCommand,
                     RebuildFTICommand,
-                    SynchronizeApplicationSchemaCommand,
+                    SynchronizeInstanceSchemaCommand,
                     ) )