Repository: softlayer/softlayer-python
Pull request #670 (2015-12-19 02:27:31)

Prefer 'virtual' and 'hardware' CLI command names over 'vs' and 'server'


Patch:
diff --git a/SoftLayer/CLI/server/__init__.py b/SoftLayer/CLI/hardware/__init__.py
similarity index 100%
rename from SoftLayer/CLI/server/__init__.py
rename to SoftLayer/CLI/hardware/__init__.py
diff --git a/SoftLayer/CLI/server/cancel.py b/SoftLayer/CLI/hardware/cancel.py
similarity index 100%
rename from SoftLayer/CLI/server/cancel.py
rename to SoftLayer/CLI/hardware/cancel.py
diff --git a/SoftLayer/CLI/server/cancel_reasons.py b/SoftLayer/CLI/hardware/cancel_reasons.py
similarity index 100%
rename from SoftLayer/CLI/server/cancel_reasons.py
rename to SoftLayer/CLI/hardware/cancel_reasons.py
diff --git a/SoftLayer/CLI/server/create.py b/SoftLayer/CLI/hardware/create.py
similarity index 100%
rename from SoftLayer/CLI/server/create.py
rename to SoftLayer/CLI/hardware/create.py
diff --git a/SoftLayer/CLI/server/create_options.py b/SoftLayer/CLI/hardware/create_options.py
similarity index 100%
rename from SoftLayer/CLI/server/create_options.py
rename to SoftLayer/CLI/hardware/create_options.py
diff --git a/SoftLayer/CLI/server/credentials.py b/SoftLayer/CLI/hardware/credentials.py
similarity index 100%
rename from SoftLayer/CLI/server/credentials.py
rename to SoftLayer/CLI/hardware/credentials.py
diff --git a/SoftLayer/CLI/server/detail.py b/SoftLayer/CLI/hardware/detail.py
similarity index 100%
rename from SoftLayer/CLI/server/detail.py
rename to SoftLayer/CLI/hardware/detail.py
diff --git a/SoftLayer/CLI/server/edit.py b/SoftLayer/CLI/hardware/edit.py
similarity index 100%
rename from SoftLayer/CLI/server/edit.py
rename to SoftLayer/CLI/hardware/edit.py
diff --git a/SoftLayer/CLI/server/list.py b/SoftLayer/CLI/hardware/list.py
similarity index 100%
rename from SoftLayer/CLI/server/list.py
rename to SoftLayer/CLI/hardware/list.py
diff --git a/SoftLayer/CLI/server/nic_edit.py b/SoftLayer/CLI/hardware/nic_edit.py
similarity index 100%
rename from SoftLayer/CLI/server/nic_edit.py
rename to SoftLayer/CLI/hardware/nic_edit.py
diff --git a/SoftLayer/CLI/server/power.py b/SoftLayer/CLI/hardware/power.py
similarity index 100%
rename from SoftLayer/CLI/server/power.py
rename to SoftLayer/CLI/hardware/power.py
diff --git a/SoftLayer/CLI/server/reload.py b/SoftLayer/CLI/hardware/reload.py
similarity index 100%
rename from SoftLayer/CLI/server/reload.py
rename to SoftLayer/CLI/hardware/reload.py
diff --git a/SoftLayer/CLI/server/rescue.py b/SoftLayer/CLI/hardware/rescue.py
similarity index 100%
rename from SoftLayer/CLI/server/rescue.py
rename to SoftLayer/CLI/hardware/rescue.py
diff --git a/SoftLayer/CLI/server/update_firmware.py b/SoftLayer/CLI/hardware/update_firmware.py
similarity index 100%
rename from SoftLayer/CLI/server/update_firmware.py
rename to SoftLayer/CLI/hardware/update_firmware.py
diff --git a/SoftLayer/CLI/routes.py b/SoftLayer/CLI/routes.py
index 3a0fe51e..5dad8632 100644
--- a/SoftLayer/CLI/routes.py
+++ b/SoftLayer/CLI/routes.py
@@ -11,26 +11,26 @@
 
     ('call-api', 'SoftLayer.CLI.call_api:cli'),
 
-    ('vs', 'SoftLayer.CLI.virt'),
-    ('vs:cancel', 'SoftLayer.CLI.virt.cancel:cli'),
-    ('vs:capture', 'SoftLayer.CLI.virt.capture:cli'),
-    ('vs:create', 'SoftLayer.CLI.virt.create:cli'),
-    ('vs:create-options', 'SoftLayer.CLI.virt.create_options:cli'),
-    ('vs:detail', 'SoftLayer.CLI.virt.detail:cli'),
-    ('vs:dns-sync', 'SoftLayer.CLI.virt.dns:cli'),
-    ('vs:edit', 'SoftLayer.CLI.virt.edit:cli'),
-    ('vs:list', 'SoftLayer.CLI.virt.list:cli'),
-    ('vs:network', 'SoftLayer.CLI.virt.network:cli'),
-    ('vs:pause', 'SoftLayer.CLI.virt.power:pause'),
-    ('vs:power_off', 'SoftLayer.CLI.virt.power:power_off'),
-    ('vs:power_on', 'SoftLayer.CLI.virt.power:power_on'),
-    ('vs:rescue', 'SoftLayer.CLI.virt.power:rescue'),
-    ('vs:resume', 'SoftLayer.CLI.virt.power:resume'),
-    ('vs:ready', 'SoftLayer.CLI.virt.ready:cli'),
-    ('vs:reboot', 'SoftLayer.CLI.virt.power:reboot'),
-    ('vs:reload', 'SoftLayer.CLI.virt.reload:cli'),
-    ('vs:upgrade', 'SoftLayer.CLI.virt.upgrade:cli'),
-    ('vs:credentials', 'SoftLayer.CLI.virt.credentials:cli'),
+    ('virtual', 'SoftLayer.CLI.virt'),
+    ('virtual:cancel', 'SoftLayer.CLI.virt.cancel:cli'),
+    ('virtual:capture', 'SoftLayer.CLI.virt.capture:cli'),
+    ('virtual:create', 'SoftLayer.CLI.virt.create:cli'),
+    ('virtual:create-options', 'SoftLayer.CLI.virt.create_options:cli'),
+    ('virtual:detail', 'SoftLayer.CLI.virt.detail:cli'),
+    ('virtual:dns-sync', 'SoftLayer.CLI.virt.dns:cli'),
+    ('virtual:edit', 'SoftLayer.CLI.virt.edit:cli'),
+    ('virtual:list', 'SoftLayer.CLI.virt.list:cli'),
+    ('virtual:network', 'SoftLayer.CLI.virt.network:cli'),
+    ('virtual:pause', 'SoftLayer.CLI.virt.power:pause'),
+    ('virtual:power_off', 'SoftLayer.CLI.virt.power:power_off'),
+    ('virtual:power_on', 'SoftLayer.CLI.virt.power:power_on'),
+    ('virtual:rescue', 'SoftLayer.CLI.virt.power:rescue'),
+    ('virtual:resume', 'SoftLayer.CLI.virt.power:resume'),
+    ('virtual:ready', 'SoftLayer.CLI.virt.ready:cli'),
+    ('virtual:reboot', 'SoftLayer.CLI.virt.power:reboot'),
+    ('virtual:reload', 'SoftLayer.CLI.virt.reload:cli'),
+    ('virtual:upgrade', 'SoftLayer.CLI.virt.upgrade:cli'),
+    ('virtual:credentials', 'SoftLayer.CLI.virt.credentials:cli'),
 
     ('cdn', 'SoftLayer.CLI.cdn'),
     ('cdn:detail', 'SoftLayer.CLI.cdn.detail:cli'),
@@ -138,22 +138,22 @@
     ('rwhois:edit', 'SoftLayer.CLI.rwhois.edit:cli'),
     ('rwhois:show', 'SoftLayer.CLI.rwhois.show:cli'),
 
-    ('server', 'SoftLayer.CLI.server'),
-    ('server:cancel', 'SoftLayer.CLI.server.cancel:cli'),
-    ('server:cancel-reasons', 'SoftLayer.CLI.server.cancel_reasons:cli'),
-    ('server:create', 'SoftLayer.CLI.server.create:cli'),
-    ('server:create-options', 'SoftLayer.CLI.server.create_options:cli'),
-    ('server:detail', 'SoftLayer.CLI.server.detail:cli'),
-    ('server:edit', 'SoftLayer.CLI.server.edit:cli'),
-    ('server:list', 'SoftLayer.CLI.server.list:cli'),
-    ('server:nic-edit', 'SoftLayer.CLI.server.nic_edit:cli'),
-    ('server:power-cycle', 'SoftLayer.CLI.server.power:power_cycle'),
-    ('server:power-off', 'SoftLayer.CLI.server.power:power_off'),
-    ('server:power-on', 'SoftLayer.CLI.server.power:power_on'),
-    ('server:reboot', 'SoftLayer.CLI.server.power:reboot'),
-    ('server:reload', 'SoftLayer.CLI.server.reload:cli'),
-    ('server:credentials', 'SoftLayer.CLI.server.credentials:cli'),
-    ('server:update-firmware', 'SoftLayer.CLI.server.update_firmware:cli'),
+    ('hardware', 'SoftLayer.CLI.hardware'),
+    ('hardware:cancel', 'SoftLayer.CLI.hardware.cancel:cli'),
+    ('hardware:cancel-reasons', 'SoftLayer.CLI.hardware.cancel_reasons:cli'),
+    ('hardware:create', 'SoftLayer.CLI.hardware.create:cli'),
+    ('hardware:create-options', 'SoftLayer.CLI.hardware.create_options:cli'),
+    ('hardware:detail', 'SoftLayer.CLI.hardware.detail:cli'),
+    ('hardware:edit', 'SoftLayer.CLI.hardware.edit:cli'),
+    ('hardware:list', 'SoftLayer.CLI.hardware.list:cli'),
+    ('hardware:nic-edit', 'SoftLayer.CLI.hardware.nic_edit:cli'),
+    ('hardware:power-cycle', 'SoftLayer.CLI.hardware.power:power_cycle'),
+    ('hardware:power-off', 'SoftLayer.CLI.hardware.power:power_off'),
+    ('hardware:power-on', 'SoftLayer.CLI.hardware.power:power_on'),
+    ('hardware:reboot', 'SoftLayer.CLI.hardware.power:reboot'),
+    ('hardware:reload', 'SoftLayer.CLI.hardware.reload:cli'),
+    ('hardware:credentials', 'SoftLayer.CLI.hardware.credentials:cli'),
+    ('hardware:update-firmware', 'SoftLayer.CLI.hardware.update_firmware:cli'),
 
     ('snapshot', 'SoftLayer.CLI.snapshot'),
     ('snapshot:cancel', 'SoftLayer.CLI.snapshot.cancel:cli'),
@@ -199,11 +199,11 @@
 ]
 
 ALL_ALIASES = {
+    'hw': 'hardware',
+    'lb': 'loadbal',
     'meta': 'metadata',
     'my': 'metadata',
-    'vm': 'vs',
-    'hardware': 'server',
-    'hw': 'server',
-    'virtual': 'vs',
-    'lb': 'loadbal',
+    'server': 'hardware',
+    'vm': 'virtual',
+    'vs': 'virtual',
 }


Test patch:
diff --git a/tests/CLI/core_tests.py b/tests/CLI/core_tests.py
index 75e4a07c..8acab212 100644
--- a/tests/CLI/core_tests.py
+++ b/tests/CLI/core_tests.py
@@ -106,6 +106,9 @@ def recursive_subcommand_loader(root, current_path=''):
         new_path = '%s:%s' % (current_path, command)
         logging.info("loading %s", new_path)
         new_root = root.get_command(ctx, command)
+        if new_root is None:
+            raise Exception('Could not load command: %s' % command)
+
         for path, cmd in recursive_subcommand_loader(new_root,
                                                      current_path=new_path):
             yield path, cmd
diff --git a/tests/CLI/environment_tests.py b/tests/CLI/environment_tests.py
index 320b5f89..5d04e153 100644
--- a/tests/CLI/environment_tests.py
+++ b/tests/CLI/environment_tests.py
@@ -25,7 +25,7 @@ def set_up(self):
     def test_list_commands(self):
         self.env.load()
         actions = self.env.list_commands()
-        self.assertIn('vs', actions)
+        self.assertIn('virtual', actions)
         self.assertIn('dns', actions)
 
     def test_get_command_invalid(self):