Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log


## [5.6.4] - 2018-11-16

- Changes: https://github.com/softlayer/softlayer-python/compare/v5.6.3...v5.6.4

+ #1041 Dedicated host cancel, cancel-guests, list-guests
+ #1071 added createDate and modifyDate parameters to sg rule-list
+ #1060 Fixed slcli subnet list
+ #1056 Fixed documentation link in image manager
+ #1062 Added description to slcli order

## [5.6.3] - 2018-11-07

- Changes: https://github.com/softlayer/softlayer-python/compare/v5.6.0...v5.6.3
Expand Down
28 changes: 28 additions & 0 deletions SoftLayer/CLI/dedicatedhost/cancel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Cancel a dedicated host."""
# :license: MIT, see LICENSE for more details.

import click

import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import exceptions
from SoftLayer.CLI import formatting
from SoftLayer.CLI import helpers


@click.command()
@click.argument('identifier')
@environment.pass_env
def cli(env, identifier):
"""Cancel a dedicated host server immediately"""

mgr = SoftLayer.DedicatedHostManager(env.client)

host_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'dedicated host')

if not (env.skip_confirmations or formatting.no_going_back(host_id)):
raise exceptions.CLIAbort('Aborted')

mgr.cancel_host(host_id)

click.secho('Dedicated Host %s was cancelled' % host_id, fg='green')
43 changes: 43 additions & 0 deletions SoftLayer/CLI/dedicatedhost/cancel_guests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Cancel a dedicated host."""
# :license: MIT, see LICENSE for more details.

import click

import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import exceptions
from SoftLayer.CLI import formatting
from SoftLayer.CLI import helpers


@click.command()
@click.argument('identifier')
@environment.pass_env
def cli(env, identifier):
"""Cancel all virtual guests of the dedicated host immediately.

Use the 'slcli vs cancel' command to cancel an specific guest
"""

dh_mgr = SoftLayer.DedicatedHostManager(env.client)

host_id = helpers.resolve_id(dh_mgr.resolve_ids, identifier, 'dedicated host')

if not (env.skip_confirmations or formatting.no_going_back(host_id)):
raise exceptions.CLIAbort('Aborted')

table = formatting.Table(['id', 'server name', 'status'])

result = dh_mgr.cancel_guests(host_id)

if result:
for status in result:
table.add_row([
status['id'],
status['fqdn'],
status['status']
])

env.fout(table)
else:
click.secho('There is not any guest into the dedicated host %s' % host_id, fg='red')
76 changes: 76 additions & 0 deletions SoftLayer/CLI/dedicatedhost/list_guests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""List guests which are in a dedicated host server."""
# :license: MIT, see LICENSE for more details.

import click

import SoftLayer
from SoftLayer.CLI import columns as column_helper
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting
from SoftLayer.CLI import helpers

COLUMNS = [
column_helper.Column('guid', ('globalIdentifier',)),
column_helper.Column('cpu', ('maxCpu',)),
column_helper.Column('memory', ('maxMemory',)),
column_helper.Column('datacenter', ('datacenter', 'name')),
column_helper.Column('primary_ip', ('primaryIpAddress',)),
column_helper.Column('backend_ip', ('primaryBackendIpAddress',)),
column_helper.Column(
'created_by',
('billingItem', 'orderItem', 'order', 'userRecord', 'username')),
column_helper.Column('power_state', ('powerState', 'name')),
column_helper.Column(
'tags',
lambda server: formatting.tags(server.get('tagReferences')),
mask="tagReferences.tag.name"),
]

DEFAULT_COLUMNS = [
'id',
'hostname',
'domain',
'primary_ip',
'backend_ip',
'power_state'
]


@click.command()
@click.argument('identifier')
@click.option('--cpu', '-c', help='Number of CPU cores', type=click.INT)
@click.option('--domain', '-D', help='Domain portion of the FQDN')
@click.option('--hostname', '-H', help='Host portion of the FQDN')
@click.option('--memory', '-m', help='Memory in mebibytes', type=click.INT)
@helpers.multi_option('--tag', help='Filter by tags')
@click.option('--sortby',
help='Column to sort by',
default='hostname',
show_default=True)
@click.option('--columns',
callback=column_helper.get_formatter(COLUMNS),
help='Columns to display. [options: %s]'
% ', '.join(column.name for column in COLUMNS),
default=','.join(DEFAULT_COLUMNS),
show_default=True)
@environment.pass_env
def cli(env, identifier, sortby, cpu, domain, hostname, memory, tag, columns):
"""List guests which are in a dedicated host server."""

mgr = SoftLayer.DedicatedHostManager(env.client)
guests = mgr.list_guests(host_id=identifier,
cpus=cpu,
hostname=hostname,
domain=domain,
memory=memory,
tags=tag,
mask=columns.mask())

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

for guest in guests:
table.add_row([value or formatting.blank()
for value in columns.row(guest)])

env.fout(table)
2 changes: 2 additions & 0 deletions SoftLayer/CLI/order/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"""View and order from the catalog."""
# :license: MIT, see LICENSE for more details.
3 changes: 3 additions & 0 deletions SoftLayer/CLI/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
('dedicatedhost:create', 'SoftLayer.CLI.dedicatedhost.create:cli'),
('dedicatedhost:create-options', 'SoftLayer.CLI.dedicatedhost.create_options:cli'),
('dedicatedhost:detail', 'SoftLayer.CLI.dedicatedhost.detail:cli'),
('dedicatedhost:cancel', 'SoftLayer.CLI.dedicatedhost.cancel:cli'),
('dedicatedhost:cancel-guests', 'SoftLayer.CLI.dedicatedhost.cancel_guests:cli'),
('dedicatedhost:list-guests', 'SoftLayer.CLI.dedicatedhost.list_guests:cli'),

('cdn', 'SoftLayer.CLI.cdn'),
('cdn:detail', 'SoftLayer.CLI.cdn.detail:cli'),
Expand Down
7 changes: 3 additions & 4 deletions SoftLayer/CLI/subnet/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
@click.option('--identifier', help="Filter by network identifier")
@click.option('--subnet-type', '-t', help="Filter by subnet type")
@click.option('--network-space', help="Filter by network space")
@click.option('--v4', '--ipv4', is_flag=True, help="Display only IPv4 subnets")
@click.option('--v6', '--ipv6', is_flag=True, help="Display only IPv6 subnets")
@click.option('--ipv4', '--v4', is_flag=True, help="Display only IPv4 subnets")
@click.option('--ipv6', '--v6', is_flag=True, help="Display only IPv6 subnets")
@environment.pass_env
def cli(env, sortby, datacenter, identifier, subnet_type, network_space,
ipv4, ipv6):
def cli(env, sortby, datacenter, identifier, subnet_type, network_space, ipv4, ipv6):
"""List subnets."""

mgr = SoftLayer.NetworkManager(env.client)
Expand Down
2 changes: 1 addition & 1 deletion SoftLayer/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

:license: MIT, see LICENSE for more details.
"""
VERSION = 'v5.6.3'
VERSION = 'v5.6.4'
API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3.1/'
API_PRIVATE_ENDPOINT = 'https://api.service.softlayer.com/xmlrpc/v3.1/'
API_PUBLIC_ENDPOINT_REST = 'https://api.softlayer.com/rest/v3.1/'
Expand Down
7 changes: 6 additions & 1 deletion SoftLayer/fixtures/SoftLayer_Account.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,14 @@
{
'id': '100',
'networkIdentifier': '10.0.0.1',
'cidr': '/24',
'networkVlanId': 123,
'datacenter': {'name': 'dal00'},
'version': 4,
'subnetType': 'PRIMARY'
'subnetType': 'PRIMARY',
'ipAddressCount': 10,
'virtualGuests': [],
'hardware': []
}]

getSshKeys = [{'id': '100', 'label': 'Test 1'},
Expand Down
56 changes: 56 additions & 0 deletions SoftLayer/fixtures/SoftLayer_Virtual_DedicatedHost.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,59 @@
'id': 12345,
'createDate': '2017-11-02T11:40:56-07:00'
}

deleteObject = True

getGuests = [{
'id': 200,
'hostname': 'vs-test1',
'domain': 'test.sftlyr.ws',
'fullyQualifiedDomainName': 'vs-test1.test.sftlyr.ws',
'status': {'keyName': 'ACTIVE', 'name': 'Active'},
'datacenter': {'id': 50, 'name': 'TEST00',
'description': 'Test Data Center'},
'powerState': {'keyName': 'RUNNING', 'name': 'Running'},
'maxCpu': 2,
'maxMemory': 1024,
'primaryIpAddress': '172.16.240.2',
'globalIdentifier': '1a2b3c-1701',
'primaryBackendIpAddress': '10.45.19.37',
'hourlyBillingFlag': False,
'billingItem': {
'id': 6327,
'recurringFee': 1.54,
'orderItem': {
'order': {
'userRecord': {
'username': 'chechu',
}
}
}
},
}, {
'id': 202,
'hostname': 'vs-test2',
'domain': 'test.sftlyr.ws',
'fullyQualifiedDomainName': 'vs-test2.test.sftlyr.ws',
'status': {'keyName': 'ACTIVE', 'name': 'Active'},
'datacenter': {'id': 50, 'name': 'TEST00',
'description': 'Test Data Center'},
'powerState': {'keyName': 'RUNNING', 'name': 'Running'},
'maxCpu': 4,
'maxMemory': 4096,
'primaryIpAddress': '172.16.240.7',
'globalIdentifier': '05a8ac-6abf0',
'primaryBackendIpAddress': '10.45.19.35',
'hourlyBillingFlag': True,
'billingItem': {
'id': 6327,
'recurringFee': 1.54,
'orderItem': {
'order': {
'userRecord': {
'username': 'chechu',
}
}
}
}
}]
Loading