[cwctl] remove support for startorder file in /etc/cubicweb.d (closes #5618947)
authorDavid Douard <david.douard@logilab.fr>
Mon, 06 Jul 2015 11:04:42 +0200
changeset 11104 269317987dc6
parent 11103 d1798710f922
child 11105 2a8884f3be3d
[cwctl] remove support for startorder file in /etc/cubicweb.d (closes #5618947) It's now useless.
cwctl.py
doc/changes/3.22.rst
misc/migration/3.22.1_Any.py
--- a/cwctl.py	Wed Feb 10 14:43:05 2016 +0100
+++ b/cwctl.py	Mon Jul 06 11:04:42 2015 +0200
@@ -43,6 +43,7 @@
 from logilab.common.clcommands import CommandLine
 from logilab.common.shellutils import ASK
 from logilab.common.configuration import merge_options
+from logilab.common.deprecation import deprecated
 
 from cubicweb import ConfigurationError, ExecutionError, BadCommandUsage
 from cubicweb.utils import support_args
@@ -103,38 +104,19 @@
         )
     actionverb = None
 
+    @deprecated('[3.22] startorder is not used any more')
     def ordered_instances(self):
-        """return instances in the order in which they should be started,
-        considering $REGISTRY_DIR/startorder file if it exists (useful when
-        some instances depends on another as external source).
-
-        Instance used by another one should appears first in the file (one
-        instance per line)
+        """return list of known instances
         """
         regdir = cwcfg.instances_dir()
-        _allinstances = list_instances(regdir)
-        if isfile(join(regdir, 'startorder')):
-            allinstances = []
-            for line in open(join(regdir, 'startorder')):
-                line = line.strip()
-                if line and not line.startswith('#'):
-                    try:
-                        _allinstances.remove(line)
-                        allinstances.append(line)
-                    except ValueError:
-                        print('ERROR: startorder file contains unexistant '
-                              'instance %s' % line)
-            allinstances += _allinstances
-        else:
-            allinstances = _allinstances
-        return allinstances
+        return list_instances(regdir)
 
     def run(self, args):
         """run the <command>_method on each argument (a list of instance
         identifiers)
         """
         if not args:
-            args = self.ordered_instances()
+            args = list_instances(cwcfg.instances_dir())
             try:
                 askconfirm = not self.config.force
             except AttributeError:
@@ -572,11 +554,6 @@
     name = 'stop'
     actionverb = 'stopped'
 
-    def ordered_instances(self):
-        instances = super(StopInstanceCommand, self).ordered_instances()
-        instances.reverse()
-        return instances
-
     def stop_instance(self, appid):
         """stop the instance's server"""
         config = cwcfg.config_for(appid)
@@ -621,29 +598,6 @@
     name = 'restart'
     actionverb = 'restarted'
 
-    def run_args(self, args, askconfirm):
-        regdir = cwcfg.instances_dir()
-        if not isfile(join(regdir, 'startorder')) or len(args) <= 1:
-            # no specific startorder
-            super(RestartInstanceCommand, self).run_args(args, askconfirm)
-            return
-        print ('some specific start order is specified, will first stop all '
-               'instances then restart them.')
-        # get instances in startorder
-        for appid in args:
-            if askconfirm:
-                print('*'*72)
-                if not ASK.confirm('%s instance %r ?' % (self.name, appid)):
-                    continue
-            StopInstanceCommand(self.logger).stop_instance(appid)
-        forkcmd = [w for w in sys.argv if not w in args]
-        forkcmd[1] = 'start'
-        forkcmd = ' '.join(forkcmd)
-        for appid in reversed(args):
-            status = system('%s %s' % (forkcmd, appid))
-            if status:
-                sys.exit(status)
-
     def restart_instance(self, appid):
         StopInstanceCommand(self.logger).stop_instance(appid)
         self.start_instance(appid)
--- a/doc/changes/3.22.rst	Wed Feb 10 14:43:05 2016 +0100
+++ b/doc/changes/3.22.rst	Mon Jul 06 11:04:42 2015 +0200
@@ -89,3 +89,6 @@
 * the ``Repository.pinfo()`` method was removed
 
 * the ``cubicweb.utils.SizeConstrainedList`` class was removed
+
+* the 'startorder' file in configuration directory is no longer honored
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/migration/3.22.1_Any.py	Mon Jul 06 11:04:42 2015 +0200
@@ -0,0 +1,12 @@
+from os import unlink
+from os.path import isfile, join
+from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
+
+regdir = cwcfg.instances_dir()
+
+if isfile(join(regdir, 'startorder')):
+    if confirm('The startorder file is not used anymore in Cubicweb 3.22. '
+               'Should I delete it?',
+               shell=False, pdb=False):
+        unlink(join(regdir, 'startorder'))
+