Repository: softlayer/softlayer-python
Pull request #1899 (2023-04-04 17:08:19)

slcli firewall detail multiVlan:14109 --credentials
[#issue1821](https://github.com/softlayer/softlayer-python/issues/1821)


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index abee1bea..784a3f3b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,10 +1,5 @@
 # Change Log
 
-## [6.1.6] - 2023-03-27
-
-From now on changes will be published only on GitHub https://github.com/softlayer/softlayer-python/releases
-
-
 ## [6.1.3] - 2022-11-30
 
 #### What's Changed
diff --git a/SoftLayer/CLI/account/hook_delete.py b/SoftLayer/CLI/account/hook_delete.py
deleted file mode 100644
index c4eda42b..00000000
--- a/SoftLayer/CLI/account/hook_delete.py
+++ /dev/null
@@ -1,24 +0,0 @@
-"""Delete a provisioning script"""
-# :license: MIT, see LICENSE for more details.
-
-import click
-import SoftLayer
-
-from SoftLayer.CLI.command import SLCommand as SLCommand
-from SoftLayer.CLI import environment
-from SoftLayer.managers.account import AccountManager as AccountManager
-
-
-@click.command(cls=SLCommand)
-@click.argument('identifier')
-@environment.pass_env
-def cli(env, identifier):
-    """Delete a provisioning script"""
-
-    manager = AccountManager(env.client)
-
-    try:
-        manager.delete_provisioning(identifier)
-        click.secho("%s deleted successfully" % identifier, fg='green')
-    except SoftLayer.SoftLayerAPIError as ex:
-        click.secho("Failed to delete %s\n%s" % (identifier, ex), fg='red')
diff --git a/SoftLayer/CLI/event_log/get.py b/SoftLayer/CLI/event_log/get.py
index 9f5ddc6a..2ef96888 100644
--- a/SoftLayer/CLI/event_log/get.py
+++ b/SoftLayer/CLI/event_log/get.py
@@ -5,7 +5,6 @@
 
 import SoftLayer
 from SoftLayer.CLI import environment
-from SoftLayer.CLI import exceptions
 from SoftLayer import utils
 
 
@@ -57,11 +56,8 @@ def cli(env, date_min, date_max, obj_event, obj_id, obj_type, utc_offset, metada
         if user == "CUSTOMER":
             username = user_data.get(log['userId'])
             if username is None:
-                try:
-                    username = user_mgr.get_user(log['userId'], "mask[username]")['username']
-                    user_data[log['userId']] = username
-                except exceptions.SoftLayerAPIError:
-                    username = log['userId']
+                username = user_mgr.get_user(log['userId'], "mask[username]")['username']
+                user_data[log['userId']] = username
             user = username
 
         if metadata:
diff --git a/SoftLayer/CLI/firewall/detail.py b/SoftLayer/CLI/firewall/detail.py
index aa0b4fa6..c07695d2 100644
--- a/SoftLayer/CLI/firewall/detail.py
+++ b/SoftLayer/CLI/firewall/detail.py
@@ -12,10 +12,10 @@
 
 @click.command(cls=SoftLayer.CLI.command.SLCommand, )
 @click.argument('identifier')
-@click.option('--credentials', type=click.BOOL,
+@click.option('--password', is_flag=True,
               help="Display FortiGate username and FortiGate password to multi vlans.")
 @environment.pass_env
-def cli(env, identifier, credentials):
+def cli(env, identifier, password):
     """Detail firewall.
 
     EXAMPLES:
@@ -63,7 +63,7 @@ def cli(env, identifier, credentials):
             table.add_row(['private vlan', utils.lookup(_firewall, 'networkGateway', 'privateVlan', 'vlanNumber')])
             table.add_row(['type', _firewall.get('firewallType')])
 
-            if credentials:
+            if password:
                 table.add_row(['fortiGate username', utils.lookup(_firewall, 'managementCredentials', 'username')])
                 table.add_row(['fortiGate password', utils.lookup(_firewall, 'managementCredentials', 'password')])
 
diff --git a/SoftLayer/CLI/hardware/create_credential.py b/SoftLayer/CLI/hardware/create_credential.py
index 6d43501b..40bf14f6 100644
--- a/SoftLayer/CLI/hardware/create_credential.py
+++ b/SoftLayer/CLI/hardware/create_credential.py
@@ -14,37 +14,44 @@
 @click.option('--username', '-U', required=True, help="The username part of the username/password pair")
 @click.option('--password', '-P', required=True, help="The password part of the username/password pair.")
 @click.option('--notes', '-n', help="A note string stored for this username/password pair.")
-@click.option('--software', required=True, help="The name of this specific piece of software.")
+@click.option('--system', required=True, help="The name of this specific piece of software.")
 @environment.pass_env
-def cli(env, identifier, username, password, notes, software):
+def cli(env, identifier, username, password, notes, system):
     """Create a password for a software component."""
 
     mgr = SoftLayer.HardwareManager(env.client)
 
-    software_components = mgr.get_software_components(identifier)
-    software_id = ''
+    software = mgr.get_software_components(identifier)
+    sw_id = ''
     try:
-        for software_component in software_components:
-            if software_component['softwareLicense']['softwareDescription']['name'].lower() == software.lower():
-                software_id = software_component['id']
+        for sw_instance in software:
+            if (sw_instance['softwareLicense']['softwareDescription']['name']).lower() == system:
+                sw_id = sw_instance['id']
     except KeyError as ex:
-        raise exceptions.CLIAbort('Software not found') from ex
+        raise exceptions.CLIAbort('System id not found') from ex
 
     template = {
         "notes": notes,
         "password": password,
-        "softwareId": software_id,
-        "username": username
-    }
+        "softwareId": sw_id,
+        "username": username,
+        "software": {
+            "hardwareId": identifier,
+            "softwareLicense": {
+                "softwareDescription": {
+                    "name": system
+                }
+            }
+        }}
 
     result = mgr.create_credential(template)
 
-    table = formatting.KeyValueTable(['Name', 'Value'])
-    table.align['Name'] = 'r'
-    table.align['Value'] = 'l'
-    table.add_row(['Software Credential Id', result['id']])
+    table = formatting.KeyValueTable(['name', 'value'])
+    table.align['name'] = 'r'
+    table.align['value'] = 'l'
+    table.add_row(['Software Id', result['id']])
     table.add_row(['Created', result['createDate']])
     table.add_row(['Username', result['username']])
     table.add_row(['Password', result['password']])
-    table.add_row(['Notes', result.get('notes') or formatting.blank()])
+    table.add_row(['Notes', result['notes']])
     env.fout(table)
diff --git a/SoftLayer/CLI/routes.py b/SoftLayer/CLI/routes.py
index 921ad247..09a7c54a 100644
--- a/SoftLayer/CLI/routes.py
+++ b/SoftLayer/CLI/routes.py
@@ -26,7 +26,6 @@
     ('account:bandwidth-pools', 'SoftLayer.CLI.account.bandwidth_pools:cli'),
     ('account:hooks', 'SoftLayer.CLI.account.hooks:cli'),
     ('account:hook-create', 'SoftLayer.CLI.account.hook_create:cli'),
-    ('account:hook-delete', 'SoftLayer.CLI.account.hook_delete:cli'),
 
     ('virtual', 'SoftLayer.CLI.virt'),
     ('virtual:bandwidth', 'SoftLayer.CLI.virt.bandwidth:cli'),
diff --git a/SoftLayer/consts.py b/SoftLayer/consts.py
index fa640e04..fb235f96 100644
--- a/SoftLayer/consts.py
+++ b/SoftLayer/consts.py
@@ -5,7 +5,7 @@
 
     :license: MIT, see LICENSE for more details.
 """
-VERSION = 'v6.1.6'
+VERSION = 'v6.1.5'
 API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3.1/'
 API_PRIVATE_ENDPOINT = 'https://api.service.softlayer.com/xmlrpc/v3.1/'
 API_PUBLIC_ENDPOINT_REST = 'https://api.softlayer.com/rest/v3.1/'
diff --git a/SoftLayer/fixtures/SoftLayer_Provisioning_Hook.py b/SoftLayer/fixtures/SoftLayer_Provisioning_Hook.py
index 86c5756d..452a1585 100644
--- a/SoftLayer/fixtures/SoftLayer_Provisioning_Hook.py
+++ b/SoftLayer/fixtures/SoftLayer_Provisioning_Hook.py
@@ -5,4 +5,3 @@
                 'uri': 'http://slclitest.com',
                 'hookType': {}
 }
-deleteObject = True
diff --git a/SoftLayer/managers/account.py b/SoftLayer/managers/account.py
index 7de4db36..c2386a83 100644
--- a/SoftLayer/managers/account.py
+++ b/SoftLayer/managers/account.py
@@ -407,12 +407,3 @@ def create_provisioning(self, name, uri):
             'uri': uri
         }
         return self.client.call('SoftLayer_Provisioning_Hook', 'createObject', template)
-
-    def delete_provisioning(self, identifier):
-        """Delete a provisioning script
-
-        param: identifier provisioning script identifier
-
-        Returns: boolean
-        """
-        return self.client.call("SoftLayer_Provisioning_Hook", "deleteObject", id=identifier)
diff --git a/docs/cli/account.rst b/docs/cli/account.rst
index 248525cb..c2ac4900 100644
--- a/docs/cli/account.rst
+++ b/docs/cli/account.rst
@@ -59,7 +59,3 @@ Account Commands
 .. click:: SoftLayer.CLI.account.hook_create:cli
     :prog: account hook-create
     :show-nested:
-
-.. click:: SoftLayer.CLI.account.hook_delete:cli
-    :prog: account hook-delete
-    :show-nested:
diff --git a/setup.py b/setup.py
index c151f723..075750c1 100644
--- a/setup.py
+++ b/setup.py
@@ -16,7 +16,7 @@
 
 setup(
     name='SoftLayer',
-    version='6.1.6',
+    version='6.1.5',
     description=DESCRIPTION,
     long_description=LONG_DESCRIPTION,
     long_description_content_type='text/x-rst',
@@ -40,7 +40,7 @@
         'prompt_toolkit >= 2',
         'pygments >= 2.0.0',
         'urllib3 >= 1.24',
-        'rich == 13.3.3'
+        'rich == 13.3.2'
     ],
     keywords=['softlayer', 'cloud', 'slcli'],
     classifiers=[
diff --git a/tools/requirements.txt b/tools/requirements.txt
index 50dd0d5f..0446899b 100644
--- a/tools/requirements.txt
+++ b/tools/requirements.txt
@@ -4,6 +4,6 @@ requests >= 2.20.0
 prompt_toolkit >= 2
 pygments >= 2.0.0
 urllib3 >= 1.24
-rich == 13.3.3
+rich == 13.3.2
 # only used for soap transport
 # softlayer-zeep >= 5.0.0


Test patch:
diff --git a/tests/CLI/modules/account_tests.py b/tests/CLI/modules/account_tests.py
index 71a4ad71..60a572b7 100644
--- a/tests/CLI/modules/account_tests.py
+++ b/tests/CLI/modules/account_tests.py
@@ -169,8 +169,3 @@ def test_created_provisioning_hook(self):
         result = self.run_command(['account', 'hook-create', '--name', 'testslcli', '--uri', 'http://slclitest.com'])
         self.assert_no_fail(result)
         self.assert_called_with('SoftLayer_Provisioning_Hook', 'createObject')
-
-    def test_delete_provisioning_hook(self):
-        result = self.run_command(['account', 'hook-delete', '123456'])
-        self.assert_no_fail(result)
-        self.assert_called_with('SoftLayer_Provisioning_Hook', 'deleteObject')
diff --git a/tests/CLI/modules/firewall_tests.py b/tests/CLI/modules/firewall_tests.py
index 3ccc2c59..79d23969 100644
--- a/tests/CLI/modules/firewall_tests.py
+++ b/tests/CLI/modules/firewall_tests.py
@@ -73,7 +73,7 @@ def test_detail_vlan_firewall(self):
                                      'src_mask': '0.0.0.0'}]})
 
     def test_detail_multi_vlan_firewall(self):
-        result = self.run_command(['firewall', 'detail', 'multiVlan:1234', '--credentials', 'true'])
+        result = self.run_command(['firewall', 'detail', 'multiVlan:1234', '--password'])
         self.assert_no_fail(result)
         json_result = json.loads(result.output)
         self.assertEqual(json_result['rules'][0]['action'], 'permit')
diff --git a/tests/CLI/modules/server_tests.py b/tests/CLI/modules/server_tests.py
index 1f17e0c2..d0a0d8ba 100644
--- a/tests/CLI/modules/server_tests.py
+++ b/tests/CLI/modules/server_tests.py
@@ -1055,7 +1055,7 @@ def test_notification_delete(self):
     def test_create_credential(self):
         result = self.run_command(['hw', 'create-credential', '123456',
                                    '--username', 'testslcli', '--password', 'test-123456',
-                                   '--notes', 'test slcli', '--software', 'system'])
+                                   '--notes', 'test slcli', '--system', 'system'])
         self.assert_no_fail(result)
 
     def test_list_hw_search_noargs(self):
diff --git a/tests/managers/account_tests.py b/tests/managers/account_tests.py
index a1a9f483..3fa796b2 100644
--- a/tests/managers/account_tests.py
+++ b/tests/managers/account_tests.py
@@ -184,7 +184,3 @@ def test_get_provisioning_scripts(self):
     def test_create_provisioning_scripts(self):
         self.manager.create_provisioning('testslcli', 'http://slclitest.com')
         self.assert_called_with('SoftLayer_Provisioning_Hook', 'createObject')
-
-    def test_delete_provisioning_scripts(self):
-        self.manager.delete_provisioning(123456)
-        self.assert_called_with("SoftLayer_Provisioning_Hook", "deleteObject")