Skip to content

Commit fefb704

Browse files
committedApr 22, 2024·
merged in master
2 parents de9319e + f796629 commit fefb704

21 files changed

+217
-124
lines changed
 

‎.github/workflows/tests.yml

+19-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v4
18+
uses: actions/setup-python@v5
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121
- name: Install dependencies
@@ -29,7 +29,7 @@ jobs:
2929
steps:
3030
- uses: actions/checkout@v4
3131
- name: Set up Python
32-
uses: actions/setup-python@v4
32+
uses: actions/setup-python@v5
3333
with:
3434
python-version: 3.12
3535
- name: Install dependencies
@@ -43,7 +43,7 @@ jobs:
4343
steps:
4444
- uses: actions/checkout@v4
4545
- name: Set up Python
46-
uses: actions/setup-python@v4
46+
uses: actions/setup-python@v5
4747
with:
4848
python-version: 3.12
4949
- name: Install dependencies
@@ -52,3 +52,19 @@ jobs:
5252
pip install -r tools/test-requirements.txt
5353
- name: Tox Analysis
5454
run: tox -e analysis
55+
detectsecrets:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
- name: Set up Python
60+
uses: actions/setup-python/@v5
61+
with:
62+
python-version: 3.11
63+
- name: Install Detect Secrets
64+
run: |
65+
python -m pip install --upgrade pip
66+
pip install --upgrade "git+https://github.com/ibm/detect-secrets.git@master#egg=detect-secrets"
67+
- name: Detect Secrets
68+
run: |
69+
detect-secrets scan --update .secrets.baseline
70+
detect-secrets audit .secrets.baseline --report --fail-on-unaudited --omit-instructions

‎.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
# You are encouraged to use static refs such as tags, instead of branch name
1111
#
1212
# Running "pre-commit autoupdate" automatically updates rev to latest tag
13-
rev: 0.13.1+ibm.61.dss
13+
rev: 0.13.1+ibm.62.dss
1414
hooks:
1515
- id: detect-secrets # pragma: whitelist secret
1616
# Add options for detect-secrets-hook binary. You can run `detect-secrets-hook --help` to list out all possible options.

‎.secrets.baseline

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2023-10-13T20:28:05Z",
6+
"generated_at": "2024-04-18T01:09:09Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -532,6 +532,7 @@
532532
"tests/CLI/modules/hardware/hardware_basic_tests.py": [
533533
{
534534
"hashed_secret": "6367c48dd193d56ea7b0baad25b19455e529f5ee",
535+
"is_secret": false,
535536
"is_verified": false,
536537
"line_number": 57,
537538
"type": "Secret Keyword",
@@ -573,7 +574,7 @@
573574
"hashed_secret": "a4c805a62a0387010cd172cfed6f6772eb92a5d6",
574575
"is_secret": false,
575576
"is_verified": false,
576-
"line_number": 33,
577+
"line_number": 32,
577578
"type": "Secret Keyword",
578579
"verified_result": null
579580
}
@@ -761,7 +762,7 @@
761762
}
762763
]
763764
},
764-
"version": "0.13.1+ibm.61.dss",
765+
"version": "0.13.1+ibm.62.dss",
765766
"word_list": {
766767
"file": null,
767768
"hash": null

‎README.rst

-7
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,12 @@ SoftLayer API Python Client
22
===========================
33
.. image:: https://github.com/softlayer/softlayer-python/workflows/Tests/badge.svg
44
:target: https://github.com/softlayer/softlayer-python/actions?query=workflow%3ATests
5-
65
.. image:: https://github.com/softlayer/softlayer-python/workflows/documentation/badge.svg
76
:target: https://github.com/softlayer/softlayer-python/actions?query=workflow%3Adocumentation
8-
9-
.. image:: https://landscape.io/github/softlayer/softlayer-python/master/landscape.svg
10-
:target: https://landscape.io/github/softlayer/softlayer-python/master
11-
127
.. image:: https://badge.fury.io/py/SoftLayer.svg
138
:target: http://badge.fury.io/py/SoftLayer
14-
159
.. image:: https://coveralls.io/repos/github/softlayer/softlayer-python/badge.svg?branch=master
1610
:target: https://coveralls.io/github/softlayer/softlayer-python?branch=master
17-
1811
.. image:: https://snapcraft.io//slcli/badge.svg
1912
:target: https://snapcraft.io/slcli
2013

‎SoftLayer/CLI/block/limit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def cli(env, sortby, datacenter):
2323
Example::
2424
slcli block volume-limits
2525
This command lists the storage limits per datacenter for this account.
26-
"""
26+
"""
2727

2828
block_manager = SoftLayer.BlockStorageManager(env.client)
2929
block_volumes = block_manager.list_block_volume_limit()

‎SoftLayer/CLI/block/modify.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,21 @@
2020
@click.option('--new-iops', '-i',
2121
type=int,
2222
help='Performance Storage IOPS, between 100 and 6000 in multiples of 100 [only for performance volumes] '
23-
'***If no IOPS value is specified, the original IOPS value of the volume will be used.***\n'
24-
'Requirements: [If original IOPS/GB for the volume is less than 0.3, new IOPS/GB must also be '
25-
'less than 0.3. If original IOPS/GB for the volume is greater than or equal to 0.3, new IOPS/GB '
26-
'for the volume must also be greater than or equal to 0.3.]')
23+
'***If no IOPS value is specified, the original IOPS value of the volume will be used.***')
2724
@click.option('--new-tier', '-t',
28-
help='Endurance Storage Tier (IOPS per GB) [only for endurance volumes] '
29-
'***If no tier is specified, the original tier of the volume will be used.***\n'
30-
'Requirements: [If original IOPS/GB for the volume is 0.25, new IOPS/GB for the volume must also '
31-
'be 0.25. If original IOPS/GB for the volume is greater than 0.25, new IOPS/GB for the volume '
32-
'must also be greater than 0.25.]',
25+
help='Endurance Storage Tier (IOPS per GB) [only for endurance volumes] Classic Choices: '
26+
'***If no tier is specified, the original tier of the volume will be used.***',
3327
type=click.Choice(['0.25', '2', '4', '10']))
3428
@environment.pass_env
3529
def cli(env, volume_id, new_size, new_iops, new_tier):
36-
"""Modify an existing block storage volume.
30+
"""Modify an existing block storage volume. Choices.
31+
32+
Valid size and iops options can be found here:
33+
https://cloud.ibm.com/docs/BlockStorage/index.html#provisioning-considerations
34+
https://cloud.ibm.com/docs/BlockStorage?topic=BlockStorage-orderingBlockStorage&interface=cli
3735
3836
Example::
37+
3938
slcli block volume-modify 12345678 --new-size 1000 --new-iops 4000
4039
This command modify a volume 12345678 with size is 1000GB, IOPS is 4000.
4140

‎SoftLayer/CLI/command.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class OptionHighlighter(RegexHighlighter):
2828
r"(?P<option>\-\-[\w\-]+)", # long options like --verbose
2929
r"(?P<default_option>\[[^\]]+\])", # anything between [], usually default options
3030
r"(?P<option_choices>Choices: )",
31+
r"(?P<example_block>Example::)",
32+
r"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)"
3133
r"(?P<args_keyword>^[A-Z]+$)",
3234
]
3335

@@ -91,7 +93,7 @@ def format_help_text(self, ctx: click.Context, formatter: click.formatting.HelpF
9193

9294
if text:
9395
text = inspect.cleandoc(text).partition("\f")[0]
94-
self.console.print(f"\n\t{text}\n")
96+
self.console.print(f"\n\t{text}\n", highlight=True)
9597

9698
def format_epilog(self, ctx: click.Context, formatter: click.formatting.HelpFormatter) -> None:
9799
"""Writes the epilog if it exists, then prints out any sub-commands if they exist."""
@@ -191,9 +193,10 @@ def format_help_text(self, ctx: click.Context, formatter: click.formatting.HelpF
191193
text = f"(Deprecated) {text}"
192194

193195
if text:
194-
text = inspect.cleandoc(text)
196+
text = f"\n\t{inspect.cleandoc(text)}\n"
195197

196-
self.console.print(f"\n\t{text}\n", highlight=False)
198+
# Can't use F-string here because it messes with highlights
199+
self.console.print(self.highlighter(text))
197200

198201
def format_epilog(self, ctx: click.Context, formatter: click.formatting.HelpFormatter) -> None:
199202
"""Writes the epilog if it exists, then prints out any sub-commands if they exist."""

‎SoftLayer/CLI/file/modify.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,22 @@
2121
@click.option('--new-iops', '-i',
2222
type=int,
2323
help='Performance Storage IOPS, between 100 and 6000 in multiples of 100 [only for performance volumes] '
24-
'***If no IOPS value is specified, the original IOPS value of the volume will be used.***\n'
25-
'Requirements: [If original IOPS/GB for the volume is less than 0.3, new IOPS/GB must also be '
26-
'less than 0.3. If original IOPS/GB for the volume is greater than or equal to 0.3, new IOPS/GB '
27-
'for the volume must also be greater than or equal to 0.3.]')
24+
'***If no IOPS value is specified, the original IOPS value of the volume will be used.***')
2825
@click.option('--new-tier', '-t',
2926
help='Endurance Storage Tier (IOPS per GB) [only for endurance volumes] '
30-
'***If no tier is specified, the original tier of the volume will be used.***\n'
31-
'Requirements: [If original IOPS/GB for the volume is 0.25, new IOPS/GB for the volume must also '
32-
'be 0.25. If original IOPS/GB for the volume is greater than 0.25, new IOPS/GB for the volume '
33-
'must also be greater than 0.25.]',
27+
'***If no tier is specified, the original tier of the volume will be used.***',
3428
type=click.Choice(['0.25', '2', '4', '10']))
3529
@click.option('--force', default=False, is_flag=True, help="Force modify")
3630
@environment.pass_env
3731
def cli(env, volume_id, new_size, new_iops, new_tier, force):
3832
"""Modify an existing file storage volume.
3933
34+
Valid size and iops options can be found here:
35+
https://cloud.ibm.com/docs/FileStorage/index.html#provisioning-considerations
36+
https://cloud.ibm.com/docs/FileStorage?topic=FileStorage-orderingFileStorage&interface=cli
37+
4038
Example::
39+
4140
slcli file volume-modify 12345678 --new-size 1000 --new-iops 400
4241
"""
4342
if not force:

‎SoftLayer/CLI/formatting.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ def no_going_back(confirmation):
259259
if not confirmation:
260260
confirmation = 'yes'
261261

262-
prompt = ('This action cannot be undone! Type "%s" or press Enter '
263-
'to abort' % confirmation)
262+
prompt = f"This action cannot be undone! Type '{confirmation}' or press Enter to abort"
264263

265264
ans = click.prompt(prompt, default='', show_default=False)
266265
if ans.lower() == str(confirmation):

‎SoftLayer/CLI/hardware/update_firmware.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,23 @@
1212

1313
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1414
@click.argument('identifier')
15+
@click.option('-i', '--ipmi', is_flag=True, help="Update IPMI firmware")
16+
@click.option('-r', '--raid', is_flag=True, help="Update RAID firmware")
17+
@click.option('-b', '--bios', is_flag=True, help="Update BIOS firmware")
18+
@click.option('-d', '--harddrive', is_flag=True, help="Update Hard Drives firmware")
19+
@click.option('-n', '--network', is_flag=True, help="Update Network Card firmware")
1520
@environment.pass_env
16-
def cli(env, identifier):
17-
"""Update server firmware."""
21+
def cli(env, identifier, ipmi, raid, bios, harddrive, network):
22+
"""Update server firmware. By default will update all available server components."""
1823

1924
mgr = SoftLayer.HardwareManager(env.client)
2025
hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')
21-
if not (env.skip_confirmations or
22-
formatting.confirm('This will power off the server with id %s and '
23-
'update device firmware. Continue?' % hw_id)):
26+
confirm_message = f"This will power off the server with id {hw_id} and update device firmware. Continue?"
27+
if not (env.skip_confirmations or formatting.confirm(confirm_message)):
2428
raise exceptions.CLIAbort('Aborted.')
2529

26-
mgr.update_firmware(hw_id)
30+
# If no options were specified, set them all to enabled.
31+
if not any([ipmi, raid, bios, harddrive, network]):
32+
ipmi = raid = bios = harddrive = network = 1
33+
mgr.update_firmware(hw_id, ipmi, raid, bios, harddrive, network)
34+
env.fout(f"[green]Firmware update for {identifier} started")

‎SoftLayer/CLI/security/cert_add.py

+8-14
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,10 @@
88

99

1010
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
11-
@click.option('--crt',
12-
type=click.Path(exists=True),
13-
help="Certificate file")
14-
@click.option('--csr',
15-
type=click.Path(exists=True),
16-
help="Certificate Signing Request file")
17-
@click.option('--icc',
18-
type=click.Path(exists=True),
19-
help="Intermediate Certificate file")
20-
@click.option('--key', type=click.Path(exists=True), help="Private Key file")
11+
@click.option('--crt', required=True, type=click.Path(exists=True), help="Certificate file")
12+
@click.option('--key', type=click.Path(exists=True), required=True, help="Private Key file")
13+
@click.option('--csr', type=click.Path(exists=True), help="Certificate Signing Request file")
14+
@click.option('--icc', type=click.Path(exists=True), help="Intermediate Certificate file")
2115
@click.option('--notes', help="Additional notes")
2216
@environment.pass_env
2317
def cli(env, crt, csr, icc, key, notes):
@@ -32,13 +26,13 @@ def cli(env, crt, csr, icc, key, notes):
3226
template['certificate'] = file_crt.read()
3327
with open(key, encoding="utf-8") as file_key:
3428
template['privateKey'] = file_key.read()
35-
with open(csr, encoding="utf-8") as file_csr:
36-
if csr:
29+
if csr:
30+
with open(csr, encoding="utf-8") as file_csr:
3731
body = file_csr.read()
3832
template['certificateSigningRequest'] = body
3933

40-
with open(icc, encoding="utf-8") as file_icc:
41-
if icc:
34+
if icc:
35+
with open(icc, encoding="utf-8") as file_icc:
4236
body = file_icc.read()
4337
template['intermediateCertificate'] = body
4438

‎SoftLayer/managers/hardware.py

+19-17
Original file line numberDiff line numberDiff line change
@@ -723,44 +723,46 @@ def edit(self, hardware_id, userdata=None, hostname=None, domain=None,
723723

724724
return self.hardware.editObject(obj, id=hardware_id)
725725

726-
def update_firmware(self,
727-
hardware_id,
728-
ipmi=True,
729-
raid_controller=True,
730-
bios=True,
731-
hard_drive=True):
726+
def update_firmware(self, hardware_id: int,
727+
ipmi: bool = True,
728+
raid_controller: bool = True,
729+
bios: bool = True,
730+
hard_drive: bool = True,
731+
network: bool = True):
732732
"""Update hardware firmware.
733733
734734
This will cause the server to be unavailable for ~20 minutes.
735+
https://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/createFirmwareUpdateTransaction/
735736
736-
:param int hardware_id: The ID of the hardware to have its firmware
737-
updated.
737+
:param int hardware_id: The ID of the hardware to have its firmware updated.
738738
:param bool ipmi: Update the ipmi firmware.
739739
:param bool raid_controller: Update the raid controller firmware.
740740
:param bool bios: Update the bios firmware.
741741
:param bool hard_drive: Update the hard drive firmware.
742+
:param bool network: Update the network card firmware
742743
743744
Example::
744745
745746
# Check the servers active transactions to see progress
746747
result = mgr.update_firmware(hardware_id=1234)
747748
"""
748749

749-
return self.hardware.createFirmwareUpdateTransaction(
750-
bool(ipmi), bool(raid_controller), bool(bios), bool(hard_drive), id=hardware_id)
750+
return self.client.call(
751+
'SoftLayer_Hardware_Server', 'createFirmwareUpdateTransaction',
752+
bool(ipmi), bool(raid_controller), bool(bios), bool(hard_drive), bool(network), id=hardware_id
753+
)
751754

752-
def reflash_firmware(self,
753-
hardware_id,
754-
ipmi=True,
755-
raid_controller=True,
756-
bios=True):
755+
def reflash_firmware(self, hardware_id: int,
756+
ipmi: bool = True,
757+
raid_controller: bool = True,
758+
bios: bool = True,):
757759
"""Reflash hardware firmware.
758760
759761
This will cause the server to be unavailable for ~60 minutes.
760762
The firmware will not be upgraded but rather reflashed to the version installed.
763+
https://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/createFirmwareReflashTransaction/
761764
762-
:param int hardware_id: The ID of the hardware to have its firmware
763-
reflashed.
765+
:param int hardware_id: The ID of the hardware to have its firmware reflashed.
764766
:param bool ipmi: Reflash the ipmi firmware.
765767
:param bool raid_controller: Reflash the raid controller firmware.
766768
:param bool bios: Reflash the bios firmware.

‎SoftLayer/managers/storage.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,7 @@ def order_duplicate_volume(self,
313313

314314
return self.client.call('Product_Order', 'placeOrder', order)
315315

316-
def order_modified_volume(self,
317-
volume_id,
318-
new_size=None,
319-
new_iops=None,
320-
new_tier_level=None):
316+
def order_modified_volume(self, volume_id, new_size=None, new_iops=None, new_tier_level=None):
321317
"""Places an order for modifying an existing block volume.
322318
323319
:param volume_id: The ID of the volume to be modified

‎SoftLayer/managers/storage_utils.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ def find_snapshot_schedule_id(volume, snapshot_schedule_keyname):
419419
if schedule['type']['keyname'] == snapshot_schedule_keyname:
420420
return schedule['id']
421421

422-
raise ValueError("The given snapshot schedule ID was not found for "
423-
"the given storage volume")
422+
raise ValueError("The given snapshot schedule ID was not found for the given storage volume")
424423

425424

426425
def prepare_snapshot_order_object(manager, volume, capacity, tier, upgrade, iops):
@@ -436,8 +435,7 @@ def prepare_snapshot_order_object(manager, volume, capacity, tier, upgrade, iops
436435
"""
437436
# Ensure the storage volume has not been cancelled
438437
if 'billingItem' not in volume:
439-
raise exceptions.SoftLayerError(
440-
'This volume has been cancelled; unable to order snapshot space')
438+
raise exceptions.SoftLayerError('This volume has been cancelled; unable to order snapshot space')
441439

442440
# Determine and validate the storage volume's billing item category
443441
billing_item_category_code = volume['billingItem']['categoryCode']

0 commit comments

Comments
 (0)