Skip to content

Commit 4229641

Browse files
caberoscaberos
authored andcommitted
fix the some problems and update the branch
2 parents bb5baab + 182c390 commit 4229641

34 files changed

+469
-62
lines changed

README.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,16 @@ If you are using the library directly in python, you can do something like this.
153153
154154
System Requirements
155155
-------------------
156-
* Python 3.5, 3.6, 3.7, 3.8, or 3.9.
156+
* Python 3.8, 3.9, or 3.10.
157157
* A valid SoftLayer API username and key.
158158
* A connection to SoftLayer's private network is required to use
159159
our private network API endpoints.
160160

161+
Python 3.6 Support
162+
------------------
163+
As of version 6.0.0 SoftLayer-Python will no longer support python3.6, which is `End of Life as of 2022 <https://endoflife.date/python>`_.
164+
If you cannot install python 3.8+ for some reason, you will need to use a version of softlayer-python <= 6.0.0
165+
161166
Python 2.7 Support
162167
------------------
163168
As of version 5.8.0 SoftLayer-Python will no longer support python2.7, which is `End Of Life as of 2020 <https://www.python.org/dev/peps/pep-0373/>`_ .
@@ -167,12 +172,15 @@ If you cannot install python 3.6+ for some reason, you will need to use a versio
167172

168173
Python Packages
169174
---------------
170-
* prettytable >= 2.0.0
171-
* click >= 7
175+
* prettytable >= 2.5.0
176+
* click >= 8.0.4
172177
* requests >= 2.20.0
173178
* prompt_toolkit >= 2
174179
* pygments >= 2.0.0
175180
* urllib3 >= 1.24
181+
* rich == 12.3.0
182+
183+
*NOTE* If `ptable` (not prettytable) is installed, this will cause issues rendering tables.
176184

177185
Copyright
178186
---------
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""Get status for split or move completed percentage of a given block duplicate volume."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.CLI import formatting
8+
9+
10+
@click.command(cls=SoftLayer.CLI.command.SLCommand,
11+
epilog="""Get status for split or move completed percentage of a given block duplicate volume.""")
12+
@click.argument('volume-id')
13+
@environment.pass_env
14+
def cli(env, volume_id):
15+
"""Get status for split or move completed percentage of a given block duplicate volume."""
16+
table = formatting.Table(['Username', 'Active Conversion Start Timestamp', 'Completed Percentage'])
17+
18+
block_manager = SoftLayer.BlockStorageManager(env.client)
19+
20+
value = block_manager.convert_dupe_status(volume_id)
21+
22+
table.add_row(
23+
[
24+
value['volumeUsername'],
25+
value['activeConversionStartTime'],
26+
value['deDuplicateConversionPercentage']
27+
]
28+
)
29+
30+
env.fout(table)

SoftLayer/CLI/environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from SoftLayer.CLI import formatting
1818
from SoftLayer.CLI import routes
1919

20-
# pylint: disable=too-many-instance-attributes, invalid-name, no-self-use
20+
# pylint: disable=too-many-instance-attributes, invalid-name
2121

2222
# Calling pkg_resources.iter_entry_points shows a false-positive
2323
# pylint: disable=no-member
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""Get status for split or move completed percentage of a given file duplicate volume."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.CLI import formatting
8+
9+
10+
@click.command(cls=SoftLayer.CLI.command.SLCommand,
11+
epilog="""Get status for split or move completed percentage of a given file duplicate volume.""")
12+
@click.argument('volume-id')
13+
@environment.pass_env
14+
def cli(env, volume_id):
15+
"""Get status for split or move completed percentage of a given file duplicate volume."""
16+
table = formatting.Table(['Username', 'Active Conversion Start Timestamp', 'Completed Percentage'])
17+
18+
file_manager = SoftLayer.FileStorageManager(env.client)
19+
20+
value = file_manager.convert_dupe_status(volume_id)
21+
22+
table.add_row(
23+
[
24+
value['volumeUsername'],
25+
value['activeConversionStartTime'],
26+
value['deDuplicateConversionPercentage']
27+
]
28+
)
29+
30+
env.fout(table)

SoftLayer/CLI/firewall/detail.py

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,77 @@
1212

1313
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1414
@click.argument('identifier')
15+
@click.option('--credentials', type=click.BOOL,
16+
help="Display FortiGate username and FortiGate password to multi vlans.")
1517
@environment.pass_env
16-
def cli(env, identifier):
17-
"""Detail firewall."""
18+
def cli(env, identifier, credentials):
19+
"""Detail firewall.
20+
21+
EXAMPLES:
22+
23+
slcli firewall detail vs:12345
24+
25+
slcli firewall detail --credentials true multiVlan:456789
26+
"""
1827

1928
mgr = SoftLayer.FirewallManager(env.client)
2029

2130
firewall_type, firewall_id = firewall.parse_id(identifier)
22-
_firewall = mgr.get_instance(firewall_id)
2331

24-
table = formatting.KeyValueTable(['name', 'value'])
25-
table.align['name'] = 'r'
26-
table.align['value'] = 'l'
32+
if firewall_type in ('vs', 'server', 'vlan', 'multiVlan'):
33+
34+
if firewall_type == 'vlan':
35+
_firewall = mgr.get_instance(firewall_id)
36+
37+
table = formatting.KeyValueTable(['name', 'value'])
38+
table.align['name'] = 'r'
39+
table.align['value'] = 'l'
40+
41+
table.add_row(['id', _firewall.get('id')])
42+
table.add_row(['primaryIpAddress', _firewall.get('primaryIpAddress')])
43+
table.add_row(['datacenter', utils.lookup(_firewall, 'datacenter', 'longName')])
44+
table.add_row(['networkVlan', utils.lookup(_firewall, 'networkVlan', 'name')])
45+
table.add_row(['networkVlaniD', utils.lookup(_firewall, 'networkVlan', 'id')])
46+
47+
rules = mgr.get_dedicated_fwl_rules(firewall_id)
48+
table.add_row(['rules', get_rules_table(rules)])
49+
50+
if firewall_type == 'multiVlan':
51+
_firewall = mgr.get_instance(firewall_id)
52+
53+
table = formatting.KeyValueTable(['name', 'value'])
54+
table.align['name'] = 'r'
55+
table.align['value'] = 'l'
56+
57+
table.add_row(['name', utils.lookup(_firewall, 'networkGateway', 'name')])
58+
table.add_row(['datacenter', utils.lookup(_firewall, 'datacenter', 'longName')])
59+
table.add_row(['public ip', utils.lookup(_firewall, 'networkGateway', 'publicIpAddress', 'ipAddress')])
60+
table.add_row(['private ip', utils.lookup(_firewall, 'networkGateway', 'privateIpAddress', 'ipAddress')])
61+
table.add_row(['public ipv6', utils.lookup(_firewall, 'networkGateway', 'publicIpv6Address', 'ipAddress')])
62+
table.add_row(['public vlan', utils.lookup(_firewall, 'networkGateway', 'publicVlan', 'vlanNumber')])
63+
table.add_row(['private vlan', utils.lookup(_firewall, 'networkGateway', 'privateVlan', 'vlanNumber')])
64+
table.add_row(['type', _firewall.get('firewallType')])
65+
66+
if credentials:
67+
table.add_row(['fortiGate username', utils.lookup(_firewall, 'managementCredentials', 'username')])
68+
table.add_row(['fortiGate password', utils.lookup(_firewall, 'managementCredentials', 'password')])
69+
70+
rules = mgr.get_dedicated_fwl_rules(firewall_id)
71+
if len(rules) != 0:
72+
table.add_row(['rules', get_rules_table(rules)])
73+
else:
74+
table.add_row(['rules', '-'])
75+
76+
if firewall_type == 'vs' or firewall_type == 'server':
77+
rules = mgr.get_standard_fwl_rules(firewall_id)
78+
table = get_rules_table(rules)
2779

28-
table.add_row(['id', _firewall.get('id')])
29-
table.add_row(['primaryIpAddress', _firewall.get('primaryIpAddress')])
30-
table.add_row(['datacenter', utils.lookup(_firewall, 'datacenter', 'longName')])
31-
table.add_row(['networkVlan', utils.lookup(_firewall, 'networkVlan', 'name')])
32-
table.add_row(['networkVlaniD', utils.lookup(_firewall, 'networkVlan', 'id')])
80+
env.fout(table)
3381

34-
if firewall_type == 'vlan':
35-
rules = mgr.get_dedicated_fwl_rules(firewall_id)
3682
else:
37-
rules = mgr.get_standard_fwl_rules(firewall_id)
38-
table.add_row(['rules', get_rules_table(rules)])
39-
env.fout(table)
83+
click.secho('Invalid firewall type %s: firewall type should be either vlan, multiVlan, vs or server.'
84+
% firewall_type, fg='red')
85+
return
4086

4187

4288
def get_rules_table(rules):

SoftLayer/CLI/firewall/list.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def cli(env):
1818
table = formatting.Table(['firewall id',
1919
'type',
2020
'features',
21-
'server/vlan id'])
21+
'server/vlan id'], title='Single Server Firewalls')
2222
fwvlans = mgr.get_firewalls()
2323
dedicated_firewalls = [firewall for firewall in fwvlans
2424
if firewall['dedicatedFirewallFlag']]
@@ -70,7 +70,27 @@ def cli(env):
7070
'hardwareId')
7171
])
7272

73+
table_gatewalls = formatting.Table(['Id',
74+
'firewall',
75+
'type',
76+
'Hostname',
77+
'Location',
78+
'Public Ip',
79+
'Private Ip',
80+
'Associated vlan',
81+
'status'], title='Multi Vlan Firewall')
82+
fw_gatewwalls = mgr.get_firewalls_gatewalls()
83+
84+
for gatewalls in fw_gatewwalls:
85+
table_gatewalls.add_row([gatewalls['networkFirewall']['id'], gatewalls.get('name'),
86+
gatewalls['networkFirewall']['firewallType'],
87+
gatewalls['members'][0]['hardware']['hostname'],
88+
gatewalls['networkFirewall']['datacenter']['name'],
89+
gatewalls['publicIpAddress']['ipAddress'],
90+
gatewalls['privateIpAddress']['ipAddress'],
91+
len(gatewalls['insideVlans']), gatewalls['status']['keyName']])
7392
env.fout(table)
93+
env.fout(table_gatewalls)
7494

7595

7696
def has_firewall_component(server):

SoftLayer/CLI/licenses/cancel.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ def cli(env, key, immediate):
1616

1717
licenses = SoftLayer.LicensesManager(env.client)
1818

19-
env.fout(licenses.cancel_item(key, immediate))
19+
item = licenses.cancel_item(key, immediate)
20+
21+
if item:
22+
env.fout("License key: {} was cancelled.".format(key))

SoftLayer/CLI/report/dc_closures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def cli(env):
1313
"""Report on Resources in closing datacenters
1414
1515
Displays a list of Datacenters soon to be shutdown, and any resources on the account
16-
in those locations
16+
in those locations
1717
"""
1818

1919
closing_filter = {

SoftLayer/CLI/routes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
('block:access-list', 'SoftLayer.CLI.block.access.list:cli'),
9494
('block:access-revoke', 'SoftLayer.CLI.block.access.revoke:cli'),
9595
('block:access-password', 'SoftLayer.CLI.block.access.password:cli'),
96+
('block:duplicate-convert-status', 'SoftLayer.CLI.block.duplicate_convert_status:cli'),
9697
('block:subnets-list', 'SoftLayer.CLI.block.subnets.list:cli'),
9798
('block:subnets-assign', 'SoftLayer.CLI.block.subnets.assign:cli'),
9899
('block:subnets-remove', 'SoftLayer.CLI.block.subnets.remove:cli'),
@@ -143,6 +144,7 @@
143144
('file:access-authorize', 'SoftLayer.CLI.file.access.authorize:cli'),
144145
('file:access-list', 'SoftLayer.CLI.file.access.list:cli'),
145146
('file:access-revoke', 'SoftLayer.CLI.file.access.revoke:cli'),
147+
('file:duplicate-convert-status', 'SoftLayer.CLI.file.duplicate_convert_status:cli'),
146148
('file:replica-failback', 'SoftLayer.CLI.file.replication.failback:cli'),
147149
('file:replica-failover', 'SoftLayer.CLI.file.replication.failover:cli'),
148150
('file:disaster-recovery-failover', 'SoftLayer.CLI.file.replication.disaster_recovery_failover:cli'),

SoftLayer/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
:license: MIT, see LICENSE for more details.
77
"""
8-
# pylint: disable=no-self-use
8+
99

1010
__all__ = [
1111
'BasicAuthentication',

0 commit comments

Comments
 (0)