Skip to content

Commit 026f5d8

Browse files
Merge branch 'master' into master
2 parents 8971fa8 + e9b174c commit 026f5d8

26 files changed

+1229
-498
lines changed

CHANGELOG.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
# Change Log
22

3+
4+
## [5.4.4] - 2018-04-18
5+
- Changes: https://github.com/softlayer/softlayer-python/compare/v5.4.3...master
6+
7+
- fixed hw list not showing transactions
8+
- Re-factored RestTransport and XMLRPCTransport, logging is now only done in the DebugTransport
9+
- Added print_reproduceable to XMLRPCTransport and RestTransport, which should be very useful in printing out pure API calls.
10+
- Fixed an issue with RestTransport and locationGroupId
11+
12+
13+
## [5.4.3] - 2018-03-30
14+
- Changes: https://github.com/softlayer/softlayer-python/compare/v5.4.2...v5.4.3
15+
16+
- Corrected to current create-options output
17+
- Allow ordering of account restricted presets
18+
- Added lookup function for datacenter names and ability to use `slcli order` with short DC names
19+
- Changed locatoinGroupId to check for None instead of empty string
20+
- Added a way to try to cancel montly bare metal immediately. THis is done by automatically updating the cancellation request. A human still needs to read the ticket and process it for the reclaim to complete.
21+
322
## [5.4.2] - 2018-02-22
4-
- Changes: https://github.com/softlayer/softlayer-python/compare/v5.4.1...master
23+
- Changes: https://github.com/softlayer/softlayer-python/compare/v5.4.1...v5.4.2
524

625
- add GPU to the virtual create-options table
726
- Remove 'virtual' from the hardware ready command.

SoftLayer/CLI/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,5 @@
66
:license: MIT, see LICENSE for more details.
77
"""
88
# pylint: disable=w0401, invalid-name
9-
import logging
109

1110
from SoftLayer.CLI.helpers import * # NOQA
12-
13-
logger = logging.getLogger()
14-
logger.addHandler(logging.StreamHandler())
15-
logger.setLevel(logging.INFO)

SoftLayer/CLI/core.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ def get_command(self, ctx, name):
8888
help="Config file location",
8989
type=click.Path(resolve_path=True))
9090
@click.option('--verbose', '-v',
91-
help="Sets the debug noise level, specify multiple times "
92-
"for more verbosity.",
91+
help="Sets the debug noise level, specify multiple times for more verbosity.",
9392
type=click.IntRange(0, 3, clamp=True),
9493
count=True)
9594
@click.option('--proxy',
@@ -115,10 +114,9 @@ def cli(env,
115114
**kwargs):
116115
"""Main click CLI entry-point."""
117116

118-
if verbose > 0:
119-
logger = logging.getLogger()
120-
logger.addHandler(logging.StreamHandler())
121-
logger.setLevel(DEBUG_LOGGING_MAP.get(verbose, logging.DEBUG))
117+
logger = logging.getLogger()
118+
logger.addHandler(logging.StreamHandler())
119+
logger.setLevel(DEBUG_LOGGING_MAP.get(verbose, logging.DEBUG))
122120

123121
# Populate environement with client and set it as the context object
124122
env.skip_confirmations = really
@@ -127,7 +125,7 @@ def cli(env,
127125
env.ensure_client(config_file=config, is_demo=demo, proxy=proxy)
128126

129127
env.vars['_start'] = time.time()
130-
env.vars['_timings'] = SoftLayer.TimingTransport(env.client.transport)
128+
env.vars['_timings'] = SoftLayer.DebugTransport(env.client.transport)
131129
env.client.transport = env.vars['_timings']
132130

133131

@@ -138,22 +136,37 @@ def output_diagnostics(env, verbose=0, **kwargs):
138136

139137
if verbose > 0:
140138
diagnostic_table = formatting.Table(['name', 'value'])
141-
diagnostic_table.add_row(['execution_time',
142-
'%fs' % (time.time() - START_TIME)])
139+
diagnostic_table.add_row(['execution_time', '%fs' % (time.time() - START_TIME)])
143140

144141
api_call_value = []
145-
for call, _, duration in env.vars['_timings'].get_last_calls():
146-
api_call_value.append(
147-
"%s::%s (%fs)" % (call.service, call.method, duration))
142+
for call in env.client.transport.get_last_calls():
143+
api_call_value.append("%s::%s (%fs)" % (call.service, call.method, call.end_time - call.start_time))
148144

149145
diagnostic_table.add_row(['api_calls', api_call_value])
150146
diagnostic_table.add_row(['version', consts.USER_AGENT])
151147
diagnostic_table.add_row(['python_version', sys.version])
152-
diagnostic_table.add_row(['library_location',
153-
os.path.dirname(SoftLayer.__file__)])
148+
diagnostic_table.add_row(['library_location', os.path.dirname(SoftLayer.__file__)])
154149

155150
env.err(env.fmt(diagnostic_table))
156151

152+
if verbose > 1:
153+
for call in env.client.transport.get_last_calls():
154+
call_table = formatting.Table(['', '{}::{}'.format(call.service, call.method)])
155+
nice_mask = ''
156+
if call.mask is not None:
157+
nice_mask = call.mask
158+
159+
call_table.add_row(['id', call.identifier])
160+
call_table.add_row(['mask', nice_mask])
161+
call_table.add_row(['filter', call.filter])
162+
call_table.add_row(['limit', call.limit])
163+
call_table.add_row(['offset', call.offset])
164+
env.err(env.fmt(call_table))
165+
166+
if verbose > 2:
167+
for call in env.client.transport.get_last_calls():
168+
env.err(env.client.transport.print_reproduceable(call))
169+
157170

158171
def main(reraise_exceptions=False, **kwargs):
159172
"""Main program. Catches several common errors and displays them nicely."""
@@ -163,8 +176,7 @@ def main(reraise_exceptions=False, **kwargs):
163176
cli.main(**kwargs)
164177
except SoftLayer.SoftLayerAPIError as ex:
165178
if 'invalid api token' in ex.faultString.lower():
166-
print("Authentication Failed: To update your credentials,"
167-
" use 'slcli config setup'")
179+
print("Authentication Failed: To update your credentials, use 'slcli config setup'")
168180
exit_status = 1
169181
else:
170182
print(str(ex))
@@ -184,6 +196,7 @@ def main(reraise_exceptions=False, **kwargs):
184196
print(str(traceback.format_exc()))
185197
print("Feel free to report this error as it is likely a bug:")
186198
print(" https://github.com/softlayer/softlayer-python/issues")
199+
print("The following snippet should be able to reproduce the error")
187200
exit_status = 1
188201

189202
sys.exit(exit_status)

SoftLayer/CLI/hardware/cancel.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
@click.option('--immediate',
1616
is_flag=True,
1717
default=False,
18-
help="""Cancels the server immediately (instead of on the billing
19-
anniversary)""")
18+
help="Cancels the server immediately (instead of on the billing anniversary)")
2019
@click.option('--comment',
2120
help="An optional comment to add to the cancellation ticket")
2221
@click.option('--reason',
23-
help="""An optional cancellation reason. See cancel-reasons for
24-
a list of available options""")
22+
help="An optional cancellation reason. See cancel-reasons for a list of available options")
2523
@environment.pass_env
2624
def cli(env, identifier, immediate, comment, reason):
2725
"""Cancel a dedicated server."""

SoftLayer/CLI/hardware/list.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
column_helper.Column(
2121
'action',
2222
lambda server: formatting.active_txn(server),
23-
mask='''
24-
mask(SoftLayer_Hardware_Server)[activeTransaction[
25-
id,transactionStatus[name,friendlyName]
26-
]]'''),
23+
mask='activeTransaction[id, transactionStatus[name, friendlyName]]'),
2724
column_helper.Column('power_state', ('powerState', 'name')),
2825
column_helper.Column(
2926
'created_by',
@@ -52,30 +49,25 @@
5249
@click.option('--memory', '-m', help='Filter by memory in gigabytes')
5350
@click.option('--network', '-n', help='Filter by network port speed in Mbps')
5451
@helpers.multi_option('--tag', help='Filter by tags')
55-
@click.option('--sortby', help='Column to sort by',
56-
default='hostname',
57-
show_default=True)
52+
@click.option('--sortby', help='Column to sort by', default='hostname', show_default=True)
5853
@click.option('--columns',
5954
callback=column_helper.get_formatter(COLUMNS),
60-
help='Columns to display. [options: %s]'
61-
% ', '.join(column.name for column in COLUMNS),
55+
help='Columns to display. [options: %s]' % ', '.join(column.name for column in COLUMNS),
6256
default=','.join(DEFAULT_COLUMNS),
6357
show_default=True)
6458
@environment.pass_env
65-
def cli(env, sortby, cpu, domain, datacenter, hostname, memory, network, tag,
66-
columns):
59+
def cli(env, sortby, cpu, domain, datacenter, hostname, memory, network, tag, columns):
6760
"""List hardware servers."""
6861

6962
manager = SoftLayer.HardwareManager(env.client)
70-
7163
servers = manager.list_hardware(hostname=hostname,
7264
domain=domain,
7365
cpus=cpu,
7466
memory=memory,
7567
datacenter=datacenter,
7668
nic_speed=network,
7769
tags=tag,
78-
mask=columns.mask())
70+
mask="mask(SoftLayer_Hardware_Server)[%s]" % columns.mask())
7971

8072
table = formatting.Table(columns.columns)
8173
table.sortby = sortby

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 = 'v5.4.2'
8+
VERSION = 'v5.4.4'
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/fixtures/SoftLayer_Location.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
"longName": "San Jose 1",
1010
"name": "sjc01"
1111
}]
12+
getDatacenters = [{'id': 1854895, 'name': 'dal13', 'regions': [{'keyname': 'DALLAS13'}]}]

SoftLayer/fixtures/SoftLayer_Location_Datacenter.py

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
getObject = {'primaryRouter': {'datacenter': {'id': 1234}}}
1+
getObject = {
2+
'primaryRouter': {
3+
'datacenter': {'id': 1234, 'longName': 'TestDC'},
4+
'fullyQualifiedDomainName': 'fcr01.TestDC'
5+
},
6+
'id': 1234,
7+
'vlanNumber': 4444,
8+
'firewallInterfaces': None
9+
}

SoftLayer/fixtures/SoftLayer_Product_Package.py

Lines changed: 104 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -666,15 +666,111 @@
666666
]
667667
}
668668

669+
670+
SAAS_REST_PACKAGE = {
671+
'categories': [
672+
{'categoryCode': 'storage_as_a_service'}
673+
],
674+
'id': 759,
675+
'name': 'Storage As A Service (StaaS)',
676+
'items': [
677+
{
678+
'capacity': '0',
679+
'keyName': '',
680+
'prices': [
681+
{
682+
'id': 189433,
683+
'categories': [
684+
{'categoryCode': 'storage_as_a_service'}
685+
],
686+
'locationGroupId': None
687+
}
688+
]
689+
}, {
690+
'capacity': '20',
691+
'keyName': '',
692+
'prices': [
693+
{
694+
'capacityRestrictionMaximum': '200',
695+
'capacityRestrictionMinimum': '200',
696+
'capacityRestrictionType': 'STORAGE_TIER_LEVEL',
697+
'categories': [
698+
{'categoryCode': 'storage_snapshot_space'}
699+
],
700+
'id': 193853,
701+
'locationGroupId': None
702+
}
703+
]
704+
}, {
705+
'capacity': '0',
706+
'capacityMaximum': '1999',
707+
'capacityMinimum': '1000',
708+
'itemCategory': {'categoryCode': 'performance_storage_space'},
709+
'keyName': '1000_1999_GBS',
710+
'prices': [
711+
{
712+
'id': 190113,
713+
'categories': [
714+
{'categoryCode': 'performance_storage_space'}
715+
],
716+
'locationGroupId': None
717+
}
718+
]
719+
}, {
720+
'capacity': '0',
721+
'capacityMaximum': '20000',
722+
'capacityMinimum': '100',
723+
'keyName': '',
724+
'itemCategory': {'categoryCode': 'performance_storage_iops'},
725+
'prices': [
726+
{
727+
'capacityRestrictionMaximum': '1999',
728+
'capacityRestrictionMinimum': '1000',
729+
'capacityRestrictionType': 'STORAGE_SPACE',
730+
'categories': [
731+
{'categoryCode': 'performance_storage_iops'}
732+
],
733+
'id': 190173,
734+
'locationGroupId': None
735+
}
736+
]
737+
}, {
738+
'capacity': '0',
739+
'keyName': '',
740+
'prices': [
741+
{
742+
'categories': [
743+
{'categoryCode': 'storage_file'}
744+
],
745+
'id': 189453,
746+
'locationGroupId': None
747+
}
748+
]
749+
}
750+
]
751+
}
752+
753+
activePreset1 = {
754+
'description': 'Single Xeon 1270, 8GB Ram, 2x1TB SATA disks, Non-RAID',
755+
'id': 64,
756+
'isActive': '1',
757+
'keyName': 'S1270_8GB_2X1TBSATA_NORAID',
758+
'name': 'S1270 8GB 2X1TBSATA NORAID',
759+
'packageId': 200
760+
}
761+
762+
activePreset2 = {
763+
'description': 'Dual Xeon Gold, 384GB Ram, 4x960GB SSD, RAID 10',
764+
'id': 65,
765+
'isActive': '1',
766+
'keyName': 'DGOLD_6140_384GB_4X960GB_SSD_SED_RAID_10',
767+
'name': 'DGOLD 6140 384GB 4X960GB SSD SED RAID 10',
768+
'packageId': 200
769+
}
770+
669771
getAllObjects = [{
670-
'activePresets': [{
671-
'description': 'Single Xeon 1270, 8GB Ram, 2x1TB SATA disks, Non-RAID',
672-
'id': 64,
673-
'isActive': '1',
674-
'keyName': 'S1270_8GB_2X1TBSATA_NORAID',
675-
'name': 'S1270 8GB 2X1TBSATA NORAID',
676-
'packageId': 200
677-
}],
772+
'activePresets': [activePreset1],
773+
'accountRestrictedActivePresets': [activePreset2],
678774
'description': 'Bare Metal Server',
679775
'firstOrderStepId': 1,
680776
'id': 200,

0 commit comments

Comments
 (0)