[cw-ctl] add command versions to list versions of cubes used by an instance (closes #508052)
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Wed, 29 Jun 2011 16:29:15 +0200
changeset 7591 cb6ece9cdb78
parent 7590 a9aad6c25836
child 7595 83872394b5d9
[cw-ctl] add command versions to list versions of cubes used by an instance (closes #508052)
cwctl.py
--- a/cwctl.py	Thu Jun 30 16:26:37 2011 +0200
+++ b/cwctl.py	Wed Jun 29 16:29:15 2011 +0200
@@ -799,6 +799,28 @@
                 return False
         return True
 
+
+class ListVersionsInstanceCommand(InstanceCommand):
+    """List versions used by an instance.
+
+    <instance>...
+      identifiers of the instances to list versions for.
+    """
+    name = 'versions'
+
+    def versions_instance(self, appid):
+        from logilab.common.changelog import Version
+        config = cwcfg.config_for(appid)
+        # should not raise error if db versions don't match fs versions
+        config.repairing = True
+        if hasattr(config, 'set_sources_mode'):
+            config.set_sources_mode(('migration',))
+        repo = config.migration_handler().repo_connect()
+        vcconf = repo.get_versions()
+        for key in sorted(vcconf):
+            print key+': %s.%s.%s' % vcconf[key]
+
+
 class ShellCommand(Command):
     """Run an interactive migration shell on an instance. This is a python shell
     with enhanced migration commands predefined in the namespace. An additional
@@ -961,6 +983,7 @@
                StartInstanceCommand, StopInstanceCommand, RestartInstanceCommand,
                ReloadConfigurationCommand, StatusCommand,
                UpgradeInstanceCommand,
+               ListVersionsInstanceCommand,
                ShellCommand,
                RecompileInstanceCatalogsCommand,
                ListInstancesCommand, ListCubesCommand,