Skip to content

Commit e1b25bf

Browse files
Merge branch 'master' into issue1836
2 parents caad33a + bdeddcc commit e1b25bf

File tree

9 files changed

+82
-6
lines changed

9 files changed

+82
-6
lines changed

SoftLayer/CLI/block/refresh.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1010
@click.argument('volume_id')
1111
@click.argument('snapshot_id')
12+
@click.option('--force-refresh', '-f', is_flag=True, default=False, show_default=True,
13+
help="Cancel current refresh process and initiates the new refresh.")
1214
@environment.pass_env
13-
def cli(env, volume_id, snapshot_id):
15+
def cli(env, volume_id, snapshot_id, force_refresh):
1416
"""Refresh a duplicate volume with a snapshot from its parent."""
1517
block_manager = SoftLayer.BlockStorageManager(env.client)
16-
resp = block_manager.refresh_dupe(volume_id, snapshot_id)
18+
resp = block_manager.refresh_dupe(volume_id, snapshot_id, force_refresh)
1719

1820
click.echo(resp)

SoftLayer/CLI/file/refresh.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1010
@click.argument('volume_id')
1111
@click.argument('snapshot_id')
12+
@click.option('--force-refresh', '-f', is_flag=True, default=False, show_default=True,
13+
help="Cancel current refresh process and initiates the new refresh.")
1214
@environment.pass_env
13-
def cli(env, volume_id, snapshot_id):
15+
def cli(env, volume_id, snapshot_id, force_refresh):
1416
"""Refresh a duplicate volume with a snapshot from its parent."""
1517
file_manager = SoftLayer.FileStorageManager(env.client)
16-
resp = file_manager.refresh_dupe(volume_id, snapshot_id)
18+
resp = file_manager.refresh_dupe(volume_id, snapshot_id, force_refresh)
1719

1820
click.echo(resp)

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
('virtual:notification-delete', 'SoftLayer.CLI.virt.notification_delete:cli'),
6060
('virtual:host-list', 'SoftLayer.CLI.dedicatedhost.list:cli'),
6161
('virtual:host-create', 'SoftLayer.CLI.dedicatedhost.create:cli'),
62+
('virtual:os-available', 'SoftLayer.CLI.virt.os_available:cli'),
6263

6364
('dedicatedhost', 'SoftLayer.CLI.dedicatedhost'),
6465
('dedicatedhost:list', 'SoftLayer.CLI.dedicatedhost.list:cli'),

SoftLayer/CLI/virt/os_available.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""Get all available Operating Systems."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
6+
import SoftLayer
7+
8+
from SoftLayer.CLI import environment
9+
from SoftLayer.CLI import formatting
10+
11+
12+
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
13+
@environment.pass_env
14+
def cli(env):
15+
"""Get all available Operating Systems."""
16+
17+
table = formatting.KeyValueTable(['Id', 'KeyName', 'Description', 'Hourly', 'Monthly', 'Setup'])
18+
table.align['name'] = 'r'
19+
table.align['value'] = 'l'
20+
manager = SoftLayer.OrderingManager(env.client)
21+
_filter = {"items": {"prices": {"categories": {"categoryCode": {"operation": "os"}}}}}
22+
# PUBLIC_CLOUD_SERVER = 835
23+
operations = manager.get_items(storage_filter=_filter, package_id=835)
24+
25+
for operation_system in operations:
26+
table.add_row([operation_system.get('id'), operation_system.get('keyName'), operation_system.get('description'),
27+
operation_system['prices'][0].get('hourlyRecurringFee') or formatting.blank(),
28+
operation_system['prices'][0]['laborFee'],
29+
operation_system['prices'][0]['setupFee']])
30+
env.fout(table)

SoftLayer/fixtures/SoftLayer_Product_Package.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,3 +2276,33 @@
22762276
}
22772277
}
22782278
]
2279+
2280+
getItemsOS = [{
2281+
"description": "Debian GNU/Linux 6.x Squeeze/Stable - LAMP Install (64 bit)",
2282+
"id": 3975,
2283+
"itemTaxCategoryId": 166,
2284+
"keyName": "OS_DEBIAN_6_X_SQUEEZE_LAMP_64_BIT",
2285+
"softwareDescriptionId": 881,
2286+
"itemCategory": {
2287+
"categoryCode": "os",
2288+
"id": 12,
2289+
"name": "Operating System",
2290+
},
2291+
"prices": [
2292+
{
2293+
"hourlyRecurringFee": "0",
2294+
"id": 14056,
2295+
"itemId": 3975,
2296+
"laborFee": "0",
2297+
"recurringFee": "0",
2298+
"setupFee": "0",
2299+
"packageReferences": [
2300+
{
2301+
"id": 74660,
2302+
"itemPriceId": 14056,
2303+
"packageId": 46
2304+
}
2305+
]
2306+
}
2307+
]
2308+
}]

SoftLayer/managers/storage.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,15 +563,17 @@ def cancel_volume(self,
563563
reason,
564564
id=billing_item_id)
565565

566-
def refresh_dupe(self, volume_id, snapshot_id):
566+
def refresh_dupe(self, volume_id, snapshot_id, force_refresh=False):
567567
""""Refresh a duplicate volume with a snapshot from its parent.
568568
569569
:param integer volume_id: The id of the volume
570570
:param integer snapshot_id: The id of the snapshot
571+
:param boolean force_refresh: Force refreshing the volume if True
571572
"""
572573
return self.client.call('Network_Storage',
573574
'refreshDuplicate',
574575
snapshot_id,
576+
force_refresh,
575577
id=volume_id)
576578

577579
def convert_dep_dupe(self, volume_id):

SoftLayer/managers/vs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ def get_disk_category_id_by_disk_number(self, capacity, disk_number):
11201120
if category_to_request is None:
11211121
return None
11221122

1123-
key_name = "*= GUEST_DISK_"+str(capacity)+"_GB_SAN"
1123+
key_name = "*= GUEST_DISK_" + str(capacity) + "_GB_SAN"
11241124
object_filter = {
11251125
"itemPrices": {
11261126
"locationGroupId": {"operation": "is null"},

docs/cli/vs.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ If no timezone is specified, IMS local time (CST) will be assumed, which might n
299299
.. click:: SoftLayer.CLI.virt.create:cli
300300
This command is an alias for `slcli dedicatedhost create`
301301
:prog: virtual host-create
302+
303+
.. click:: SoftLayer.CLI.virt.os_available:cli
304+
:prog: virtual os-available
302305
:show-nested:
303306

304307
Manages the migration of virutal guests. Supports migrating virtual guests on Dedicated Hosts as well.

tests/CLI/modules/vs/vs_tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,3 +995,9 @@ def test_add_notification(self):
995995
def test_notification_delete(self):
996996
result = self.run_command(['vs', 'notification-delete', '100'])
997997
self.assert_no_fail(result)
998+
999+
def test_os_available(self):
1000+
_mock = self.set_mock('SoftLayer_Product_Package', 'getItems')
1001+
_mock.return_value = SoftLayer_Product_Package.getItemsOS
1002+
result = self.run_command(['vs', 'os-available'])
1003+
self.assert_no_fail(result)

0 commit comments

Comments
 (0)