Skip to content

Commit 4a1ca0a

Browse files
author
Ian Sutton
committed
Merge remote-tracking branch 'cgallo/issues1233-fbRefactor' into vdr-integration
2 parents 030bb5a + c64c058 commit 4a1ca0a

File tree

17 files changed

+736
-995
lines changed

17 files changed

+736
-995
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# https://docs.travis-ci.com/user/languages/python/#python-37-and-higher
2-
dist: xenial
2+
dist: bionic
33
language: python
44
sudo: false
55
matrix:
@@ -12,7 +12,7 @@ matrix:
1212
env: TOX_ENV=py37
1313
- python: "3.8"
1414
env: TOX_ENV=py38
15-
- python: "pypy3.5"
15+
- python: "pypy3"
1616
env: TOX_ENV=pypy3
1717
- python: "3.6"
1818
env: TOX_ENV=analysis

SoftLayer/CLI/block/detail.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import SoftLayer
66
from SoftLayer.CLI import environment
77
from SoftLayer.CLI import formatting
8+
from SoftLayer.CLI import helpers
89
from SoftLayer import utils
910

1011

@@ -14,7 +15,8 @@
1415
def cli(env, volume_id):
1516
"""Display details for a specified volume."""
1617
block_manager = SoftLayer.BlockStorageManager(env.client)
17-
block_volume = block_manager.get_block_volume_details(volume_id)
18+
block_volume_id = helpers.resolve_id(block_manager.resolve_ids, volume_id, 'Block Volume')
19+
block_volume = block_manager.get_block_volume_details(block_volume_id)
1820
block_volume = utils.NestedDict(block_volume)
1921

2022
table = formatting.KeyValueTable(['Name', 'Value'])

SoftLayer/CLI/core.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import click
1616

17+
import requests
1718
import SoftLayer
1819
from SoftLayer.CLI import environment
1920
from SoftLayer.CLI import exceptions
@@ -31,6 +32,7 @@
3132
3: logging.DEBUG
3233
}
3334

35+
PROG_NAME = "slcli (SoftLayer Command-line)"
3436
VALID_FORMATS = ['table', 'raw', 'json', 'jsonraw']
3537
DEFAULT_FORMAT = 'raw'
3638
if sys.stdout.isatty():
@@ -69,6 +71,28 @@ def get_command(self, ctx, name):
6971
return module
7072

7173

74+
def get_latest_version():
75+
"""Gets the latest version of the Softlayer library."""
76+
try:
77+
result = requests.get('https://pypi.org/pypi/SoftLayer/json')
78+
json_result = result.json()
79+
latest = 'v{}'.format(json_result['info']['version'])
80+
except Exception:
81+
latest = "Unable to get version from pypi."
82+
return latest
83+
84+
85+
def get_version_message(ctx, param, value):
86+
"""Gets current and latest release versions message."""
87+
if not value or ctx.resilient_parsing:
88+
return
89+
current = SoftLayer.consts.VERSION
90+
latest = get_latest_version()
91+
click.secho("Current: {prog} {current}\nLatest: {prog} {latest}".format(
92+
prog=PROG_NAME, current=current, latest=latest))
93+
ctx.exit()
94+
95+
7296
@click.group(help="SoftLayer Command-line Client",
7397
epilog="""To use most commands your SoftLayer
7498
username and api_key need to be configured. The easiest way to do that is to
@@ -103,7 +127,8 @@ def get_command(self, ctx, name):
103127
is_flag=True,
104128
required=False,
105129
help="Use demo data instead of actually making API calls")
106-
@click.version_option(prog_name="slcli (SoftLayer Command-line)")
130+
@click.option('--version', is_flag=True, expose_value=False, is_eager=True, callback=get_version_message,
131+
help="Show version information.")
107132
@environment.pass_env
108133
def cli(env,
109134
format='table',

SoftLayer/CLI/file/detail.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import SoftLayer
66
from SoftLayer.CLI import environment
77
from SoftLayer.CLI import formatting
8+
from SoftLayer.CLI import helpers
89
from SoftLayer import utils
910

1011

@@ -14,7 +15,8 @@
1415
def cli(env, volume_id):
1516
"""Display details for a specified volume."""
1617
file_manager = SoftLayer.FileStorageManager(env.client)
17-
file_volume = file_manager.get_file_volume_details(volume_id)
18+
file_volume_id = helpers.resolve_id(file_manager.resolve_ids, volume_id, 'File Storage')
19+
file_volume = file_manager.get_file_volume_details(file_volume_id)
1820
file_volume = utils.NestedDict(file_volume)
1921

2022
table = formatting.KeyValueTable(['Name', 'Value'])

SoftLayer/CLI/user/permissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@click.argument('identifier')
1212
@environment.pass_env
1313
def cli(env, identifier):
14-
"""User Permissions. TODO change to list all permissions, and which users have them"""
14+
"""User Permissions."""
1515

1616
mgr = SoftLayer.UserManager(env.client)
1717
user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username')
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
getDatacenters = [
2+
{
3+
"id": 1441195,
4+
"longName": "Dallas 10",
5+
"name": "dal10"
6+
},
7+
{
8+
"id": 449494,
9+
"longName": "Dallas 9",
10+
"name": "dal09"
11+
}
12+
]

0 commit comments

Comments
 (0)