Skip to content

Commit 9fa63ac

Browse files
Merge branch 'master' into issue1613
2 parents 1e5e998 + 4b5d9c0 commit 9fa63ac

File tree

17 files changed

+98
-38
lines changed

17 files changed

+98
-38
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# Change Log
22

33

4+
## [6.0.2] - 2022-03-30
5+
6+
## What's Changed
7+
* New Command slcli hardware|virtual monitoring by @caberos in https://github.com/softlayer/softlayer-python/pull/1593
8+
* When listing datacenters/pods, mark those that are closing soon. by @caberos in https://github.com/softlayer/softlayer-python/pull/1597
9+
10+
11+
**Full Changelog**: https://github.com/softlayer/softlayer-python/compare/v6.0.1...v6.0.2
12+
413
## [6.0.1] - 2022-03-11
514

615

SoftLayer/CLI/account/event_detail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ def update_table(event):
6565
"""Formats a basic event update table"""
6666
update_number = 0
6767
for update in event.get('updates', []):
68+
update_number = update_number + 1
6869
header = "======= Update #%s on %s =======" % (update_number, utils.clean_time(update.get('startDate')))
6970
click.secho(header, fg='green')
70-
update_number = update_number + 1
7171
text = update.get('contents')
7272
# deals with all the \r\n from the API
7373
click.secho(utils.clean_splitlines(text))

SoftLayer/CLI/account/events.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@
1111
@click.command()
1212
@click.option('--ack-all', is_flag=True, default=False,
1313
help="Acknowledge every upcoming event. Doing so will turn off the popup in the control portal")
14+
@click.option('--planned', is_flag=True, default=False,
15+
help="Show only planned events")
16+
@click.option('--unplanned', is_flag=True, default=False,
17+
help="Show only unplanned events")
18+
@click.option('--announcement', is_flag=True, default=False,
19+
help="Show only announcement events")
1420
@environment.pass_env
15-
def cli(env, ack_all):
21+
def cli(env, ack_all, planned, unplanned, announcement):
1622
"""Summary and acknowledgement of upcoming and ongoing maintenance events"""
1723

1824
manager = AccountManager(env.client)
@@ -21,13 +27,22 @@ def cli(env, ack_all):
2127
announcement_events = manager.get_upcoming_events("ANNOUNCEMENT")
2228

2329
add_ack_flag(planned_events, manager, ack_all)
24-
env.fout(planned_event_table(planned_events))
25-
2630
add_ack_flag(unplanned_events, manager, ack_all)
27-
env.fout(unplanned_event_table(unplanned_events))
28-
2931
add_ack_flag(announcement_events, manager, ack_all)
30-
env.fout(announcement_event_table(announcement_events))
32+
33+
if planned:
34+
env.fout(planned_event_table(planned_events))
35+
36+
if unplanned:
37+
env.fout(unplanned_event_table(unplanned_events))
38+
39+
if announcement:
40+
env.fout(announcement_event_table(announcement_events))
41+
42+
if not planned and not unplanned and not announcement:
43+
env.fout(planned_event_table(planned_events))
44+
env.fout(unplanned_event_table(unplanned_events))
45+
env.fout(announcement_event_table(announcement_events))
3146

3247

3348
def add_ack_flag(events, manager, ack_all):

SoftLayer/CLI/globalip/assign.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@
55

66
import SoftLayer
77
from SoftLayer.CLI import environment
8-
from SoftLayer.CLI import helpers
98

9+
target_types = {'vlan': 'SoftLayer_Network_Vlan',
10+
'ip': 'SoftLayer_Network_Subnet_IpAddress',
11+
'hardware': 'SoftLayer_Hardware_Server',
12+
'vsi': 'SoftLayer_Virtual_Guest'}
1013

11-
@click.command()
14+
15+
@click.command(epilog="More information about types and identifiers "
16+
"on https://sldn.softlayer.com/reference/services/SoftLayer_Network_Subnet/route/")
1217
@click.argument('identifier')
13-
@click.argument('target')
18+
@click.option('--target', type=click.Choice(['vlan', 'ip', 'hardware', 'vsi']),
19+
help='choose the type. vlan, ip, hardware, vsi')
20+
@click.option('--target-id', help='The identifier for the destination resource to route this subnet to. ')
1421
@environment.pass_env
15-
def cli(env, identifier, target):
16-
"""Assigns the global IP to a target."""
22+
def cli(env, identifier, target, target_id):
23+
"""Assigns the subnet to a target."""
1724

1825
mgr = SoftLayer.NetworkManager(env.client)
19-
global_ip_id = helpers.resolve_id(mgr.resolve_global_ip_ids, identifier,
20-
name='global ip')
21-
mgr.assign_global_ip(global_ip_id, target)
26+
mgr.route(identifier, target_types.get(target), target_id)

SoftLayer/CLI/hardware/create.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
def cli(env, **args):
4242
"""Order/create a dedicated server."""
4343
mgr = SoftLayer.HardwareManager(env.client)
44+
network = SoftLayer.NetworkManager(env.client)
45+
46+
pods = network.get_closed_pods()
47+
closure = []
4448

4549
# Get the SSH keys
4650
ssh_keys = []
@@ -99,6 +103,10 @@ def cli(env, **args):
99103
return
100104

101105
if do_create:
106+
for pod in pods:
107+
if args.get('datacenter') in str(pod['name']):
108+
closure.append(pod['name'])
109+
click.secho(click.style('Warning: Closed soon: %s' % (', '.join(closure)), fg='yellow'))
102110
if not (env.skip_confirmations or formatting.confirm(
103111
"This action will incur charges on your account. Continue?")):
104112
raise exceptions.CLIAbort('Aborting dedicated server order.')

SoftLayer/CLI/licenses/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"""VMware licenses."""
2+
# :license: MIT, see LICENSE for more details.

SoftLayer/CLI/order/place.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from SoftLayer.CLI import environment
99
from SoftLayer.CLI import exceptions
1010
from SoftLayer.CLI import formatting
11+
from SoftLayer.managers import NetworkManager
1112
from SoftLayer.managers import ordering
1213

1314
COLUMNS = ['keyName',
@@ -64,6 +65,10 @@ def cli(env, package_keyname, location, preset, verify, billing, complex_type,
6465
6566
"""
6667
manager = ordering.OrderingManager(env.client)
68+
network = NetworkManager(env.client)
69+
70+
pods = network.get_closed_pods()
71+
closure = []
6772

6873
if extras:
6974
try:
@@ -90,6 +95,9 @@ def cli(env, package_keyname, location, preset, verify, billing, complex_type,
9095
])
9196

9297
else:
98+
for pod in pods:
99+
closure.append(pod['name'])
100+
click.secho(click.style('Warning: Closed soon: %s' % (', '.join(closure)), fg='yellow'))
93101
if not (env.skip_confirmations or formatting.confirm(
94102
"This action will incur charges on your account. Continue?")):
95103
raise exceptions.CLIAbort("Aborting order.")

SoftLayer/CLI/virt/create.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,16 @@ def cli(env, **args):
218218
create_args = _parse_create_args(env.client, args)
219219
test = args.get('test', False)
220220
do_create = not (args.get('export') or test)
221+
network = SoftLayer.NetworkManager(env.client)
222+
223+
pods = network.get_closed_pods()
224+
closure = []
221225

222226
if do_create:
227+
for pod in pods:
228+
if args.get('datacenter') in str(pod['name']):
229+
closure.append(pod['name'])
230+
click.secho(click.style('Warning: Closed soon: %s' % (', '.join(closure)), fg='yellow'))
223231
if not (env.skip_confirmations or formatting.confirm(
224232
"This action will incur charges on your account. Continue?")):
225233
raise exceptions.CLIAbort('Aborting virtual server order.')

SoftLayer/consts.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-
VERSION = 'v6.0.1'
8+
VERSION = 'v6.0.2'
99
API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3.1/'
1010
API_PRIVATE_ENDPOINT = 'https://api.service.softlayer.com/xmlrpc/v3.1/'
1111
API_PUBLIC_ENDPOINT_REST = 'https://api.softlayer.com/rest/v3.1/'

SoftLayer/managers/network.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def list_subnets(self, identifier=None, datacenter=None, version=0,
506506
kwargs['iter'] = True
507507
return self.client.call('Account', 'getSubnets', **kwargs)
508508

509-
def list_vlans(self, datacenter=None, vlan_number=None, name=None, **kwargs):
509+
def list_vlans(self, datacenter=None, vlan_number=None, name=None, limit=100, **kwargs):
510510
"""Display a list of all VLANs on the account.
511511
512512
This provides a quick overview of all VLANs including information about
@@ -523,6 +523,8 @@ def list_vlans(self, datacenter=None, vlan_number=None, name=None, **kwargs):
523523
"""
524524
_filter = utils.NestedDict(kwargs.get('filter') or {})
525525

526+
_filter['networkVlans']['id'] = utils.query_filter_orderby()
527+
526528
if vlan_number:
527529
_filter['networkVlans']['vlanNumber'] = (
528530
utils.query_filter(vlan_number))
@@ -540,7 +542,10 @@ def list_vlans(self, datacenter=None, vlan_number=None, name=None, **kwargs):
540542
kwargs['mask'] = DEFAULT_VLAN_MASK
541543

542544
kwargs['iter'] = True
543-
return self.account.getNetworkVlans(**kwargs)
545+
if limit > 0:
546+
return self.account.getNetworkVlans(mask=kwargs['mask'], filter=_filter.to_dict(), limit=limit)
547+
else:
548+
return self.account.getNetworkVlans(mask=kwargs['mask'], filter=_filter.to_dict(), iter=True)
544549

545550
def list_securitygroups(self, **kwargs):
546551
"""List security groups."""

0 commit comments

Comments
 (0)