Skip to content

Commit 1608c9f

Browse files
authored
Merge pull request #3 from softlayer/master
update from origin repo
2 parents a8e7c26 + dda8fad commit 1608c9f

File tree

17 files changed

+519
-9
lines changed

17 files changed

+519
-9
lines changed

CHANGELOG.md

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

3+
4+
## [5.6.4] - 2018-11-16
5+
6+
- Changes: https://github.com/softlayer/softlayer-python/compare/v5.6.3...v5.6.4
7+
8+
+ #1041 Dedicated host cancel, cancel-guests, list-guests
9+
+ #1071 added createDate and modifyDate parameters to sg rule-list
10+
+ #1060 Fixed slcli subnet list
11+
+ #1056 Fixed documentation link in image manager
12+
+ #1062 Added description to slcli order
13+
314
## [5.6.3] - 2018-11-07
415

516
- Changes: https://github.com/softlayer/softlayer-python/compare/v5.6.0...v5.6.3
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Cancel a dedicated host."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
6+
import SoftLayer
7+
from SoftLayer.CLI import environment
8+
from SoftLayer.CLI import exceptions
9+
from SoftLayer.CLI import formatting
10+
from SoftLayer.CLI import helpers
11+
12+
13+
@click.command()
14+
@click.argument('identifier')
15+
@environment.pass_env
16+
def cli(env, identifier):
17+
"""Cancel a dedicated host server immediately"""
18+
19+
mgr = SoftLayer.DedicatedHostManager(env.client)
20+
21+
host_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'dedicated host')
22+
23+
if not (env.skip_confirmations or formatting.no_going_back(host_id)):
24+
raise exceptions.CLIAbort('Aborted')
25+
26+
mgr.cancel_host(host_id)
27+
28+
click.secho('Dedicated Host %s was cancelled' % host_id, fg='green')
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""Cancel a dedicated host."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
6+
import SoftLayer
7+
from SoftLayer.CLI import environment
8+
from SoftLayer.CLI import exceptions
9+
from SoftLayer.CLI import formatting
10+
from SoftLayer.CLI import helpers
11+
12+
13+
@click.command()
14+
@click.argument('identifier')
15+
@environment.pass_env
16+
def cli(env, identifier):
17+
"""Cancel all virtual guests of the dedicated host immediately.
18+
19+
Use the 'slcli vs cancel' command to cancel an specific guest
20+
"""
21+
22+
dh_mgr = SoftLayer.DedicatedHostManager(env.client)
23+
24+
host_id = helpers.resolve_id(dh_mgr.resolve_ids, identifier, 'dedicated host')
25+
26+
if not (env.skip_confirmations or formatting.no_going_back(host_id)):
27+
raise exceptions.CLIAbort('Aborted')
28+
29+
table = formatting.Table(['id', 'server name', 'status'])
30+
31+
result = dh_mgr.cancel_guests(host_id)
32+
33+
if result:
34+
for status in result:
35+
table.add_row([
36+
status['id'],
37+
status['fqdn'],
38+
status['status']
39+
])
40+
41+
env.fout(table)
42+
else:
43+
click.secho('There is not any guest into the dedicated host %s' % host_id, fg='red')
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
"""List guests which are in a dedicated host server."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
6+
import SoftLayer
7+
from SoftLayer.CLI import columns as column_helper
8+
from SoftLayer.CLI import environment
9+
from SoftLayer.CLI import formatting
10+
from SoftLayer.CLI import helpers
11+
12+
COLUMNS = [
13+
column_helper.Column('guid', ('globalIdentifier',)),
14+
column_helper.Column('cpu', ('maxCpu',)),
15+
column_helper.Column('memory', ('maxMemory',)),
16+
column_helper.Column('datacenter', ('datacenter', 'name')),
17+
column_helper.Column('primary_ip', ('primaryIpAddress',)),
18+
column_helper.Column('backend_ip', ('primaryBackendIpAddress',)),
19+
column_helper.Column(
20+
'created_by',
21+
('billingItem', 'orderItem', 'order', 'userRecord', 'username')),
22+
column_helper.Column('power_state', ('powerState', 'name')),
23+
column_helper.Column(
24+
'tags',
25+
lambda server: formatting.tags(server.get('tagReferences')),
26+
mask="tagReferences.tag.name"),
27+
]
28+
29+
DEFAULT_COLUMNS = [
30+
'id',
31+
'hostname',
32+
'domain',
33+
'primary_ip',
34+
'backend_ip',
35+
'power_state'
36+
]
37+
38+
39+
@click.command()
40+
@click.argument('identifier')
41+
@click.option('--cpu', '-c', help='Number of CPU cores', type=click.INT)
42+
@click.option('--domain', '-D', help='Domain portion of the FQDN')
43+
@click.option('--hostname', '-H', help='Host portion of the FQDN')
44+
@click.option('--memory', '-m', help='Memory in mebibytes', type=click.INT)
45+
@helpers.multi_option('--tag', help='Filter by tags')
46+
@click.option('--sortby',
47+
help='Column to sort by',
48+
default='hostname',
49+
show_default=True)
50+
@click.option('--columns',
51+
callback=column_helper.get_formatter(COLUMNS),
52+
help='Columns to display. [options: %s]'
53+
% ', '.join(column.name for column in COLUMNS),
54+
default=','.join(DEFAULT_COLUMNS),
55+
show_default=True)
56+
@environment.pass_env
57+
def cli(env, identifier, sortby, cpu, domain, hostname, memory, tag, columns):
58+
"""List guests which are in a dedicated host server."""
59+
60+
mgr = SoftLayer.DedicatedHostManager(env.client)
61+
guests = mgr.list_guests(host_id=identifier,
62+
cpus=cpu,
63+
hostname=hostname,
64+
domain=domain,
65+
memory=memory,
66+
tags=tag,
67+
mask=columns.mask())
68+
69+
table = formatting.Table(columns.columns)
70+
table.sortby = sortby
71+
72+
for guest in guests:
73+
table.add_row([value or formatting.blank()
74+
for value in columns.row(guest)])
75+
76+
env.fout(table)

SoftLayer/CLI/order/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"""View and order from the catalog."""
2+
# :license: MIT, see LICENSE for more details.

SoftLayer/CLI/routes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
('dedicatedhost:create', 'SoftLayer.CLI.dedicatedhost.create:cli'),
3838
('dedicatedhost:create-options', 'SoftLayer.CLI.dedicatedhost.create_options:cli'),
3939
('dedicatedhost:detail', 'SoftLayer.CLI.dedicatedhost.detail:cli'),
40+
('dedicatedhost:cancel', 'SoftLayer.CLI.dedicatedhost.cancel:cli'),
41+
('dedicatedhost:cancel-guests', 'SoftLayer.CLI.dedicatedhost.cancel_guests:cli'),
42+
('dedicatedhost:list-guests', 'SoftLayer.CLI.dedicatedhost.list_guests:cli'),
4043

4144
('cdn', 'SoftLayer.CLI.cdn'),
4245
('cdn:detail', 'SoftLayer.CLI.cdn.detail:cli'),

SoftLayer/CLI/subnet/list.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
@click.option('--identifier', help="Filter by network identifier")
2727
@click.option('--subnet-type', '-t', help="Filter by subnet type")
2828
@click.option('--network-space', help="Filter by network space")
29-
@click.option('--v4', '--ipv4', is_flag=True, help="Display only IPv4 subnets")
30-
@click.option('--v6', '--ipv6', is_flag=True, help="Display only IPv6 subnets")
29+
@click.option('--ipv4', '--v4', is_flag=True, help="Display only IPv4 subnets")
30+
@click.option('--ipv6', '--v6', is_flag=True, help="Display only IPv6 subnets")
3131
@environment.pass_env
32-
def cli(env, sortby, datacenter, identifier, subnet_type, network_space,
33-
ipv4, ipv6):
32+
def cli(env, sortby, datacenter, identifier, subnet_type, network_space, ipv4, ipv6):
3433
"""List subnets."""
3534

3635
mgr = SoftLayer.NetworkManager(env.client)

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.6.3'
8+
VERSION = 'v5.6.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_Account.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,14 @@
316316
{
317317
'id': '100',
318318
'networkIdentifier': '10.0.0.1',
319+
'cidr': '/24',
320+
'networkVlanId': 123,
319321
'datacenter': {'name': 'dal00'},
320322
'version': 4,
321-
'subnetType': 'PRIMARY'
323+
'subnetType': 'PRIMARY',
324+
'ipAddressCount': 10,
325+
'virtualGuests': [],
326+
'hardware': []
322327
}]
323328

324329
getSshKeys = [{'id': '100', 'label': 'Test 1'},

SoftLayer/fixtures/SoftLayer_Virtual_DedicatedHost.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,59 @@
7676
'id': 12345,
7777
'createDate': '2017-11-02T11:40:56-07:00'
7878
}
79+
80+
deleteObject = True
81+
82+
getGuests = [{
83+
'id': 200,
84+
'hostname': 'vs-test1',
85+
'domain': 'test.sftlyr.ws',
86+
'fullyQualifiedDomainName': 'vs-test1.test.sftlyr.ws',
87+
'status': {'keyName': 'ACTIVE', 'name': 'Active'},
88+
'datacenter': {'id': 50, 'name': 'TEST00',
89+
'description': 'Test Data Center'},
90+
'powerState': {'keyName': 'RUNNING', 'name': 'Running'},
91+
'maxCpu': 2,
92+
'maxMemory': 1024,
93+
'primaryIpAddress': '172.16.240.2',
94+
'globalIdentifier': '1a2b3c-1701',
95+
'primaryBackendIpAddress': '10.45.19.37',
96+
'hourlyBillingFlag': False,
97+
'billingItem': {
98+
'id': 6327,
99+
'recurringFee': 1.54,
100+
'orderItem': {
101+
'order': {
102+
'userRecord': {
103+
'username': 'chechu',
104+
}
105+
}
106+
}
107+
},
108+
}, {
109+
'id': 202,
110+
'hostname': 'vs-test2',
111+
'domain': 'test.sftlyr.ws',
112+
'fullyQualifiedDomainName': 'vs-test2.test.sftlyr.ws',
113+
'status': {'keyName': 'ACTIVE', 'name': 'Active'},
114+
'datacenter': {'id': 50, 'name': 'TEST00',
115+
'description': 'Test Data Center'},
116+
'powerState': {'keyName': 'RUNNING', 'name': 'Running'},
117+
'maxCpu': 4,
118+
'maxMemory': 4096,
119+
'primaryIpAddress': '172.16.240.7',
120+
'globalIdentifier': '05a8ac-6abf0',
121+
'primaryBackendIpAddress': '10.45.19.35',
122+
'hourlyBillingFlag': True,
123+
'billingItem': {
124+
'id': 6327,
125+
'recurringFee': 1.54,
126+
'orderItem': {
127+
'order': {
128+
'userRecord': {
129+
'username': 'chechu',
130+
}
131+
}
132+
}
133+
}
134+
}]

0 commit comments

Comments
 (0)