Skip to content

Commit bdeddcc

Browse files
Merge pull request #1838 from caberos/issue1837
vs os-available command
2 parents 0ea78de + ed4714d commit bdeddcc

File tree

6 files changed

+72
-1
lines changed

6 files changed

+72
-1
lines changed

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
('virtual:notification-add', 'SoftLayer.CLI.virt.notification_add:cli'),
5959
('virtual:notification-delete', 'SoftLayer.CLI.virt.notification_delete:cli'),
6060
('virtual:host-list', 'SoftLayer.CLI.dedicatedhost.list:cli'),
61+
('virtual:os-available', 'SoftLayer.CLI.virt.os_available:cli'),
6162

6263
('dedicatedhost', 'SoftLayer.CLI.dedicatedhost'),
6364
('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/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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ If no timezone is specified, IMS local time (CST) will be assumed, which might n
296296
:prog: virtual host-list
297297
:show-nested:
298298

299+
.. click:: SoftLayer.CLI.virt.os_available:cli
300+
:prog: virtual os-available
301+
:show-nested:
302+
299303
Manages the migration of virutal guests. Supports migrating virtual guests on Dedicated Hosts as well.
300304

301305
Reserved Capacity

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)