Skip to content

Commit 13ae244

Browse files
caberoscaberos
authored andcommitted
new feature licenses create-options
1 parent 275fc96 commit 13ae244

File tree

7 files changed

+103
-0
lines changed

7 files changed

+103
-0
lines changed

SoftLayer/CLI/licenses/__init__.py

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Licenses order options for a given VMware licenses."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.CLI import formatting
8+
from SoftLayer.managers import licenses
9+
from SoftLayer import utils
10+
11+
12+
@click.command()
13+
@environment.pass_env
14+
def cli(env):
15+
"""Server order options for a given chassis."""
16+
17+
licenses_manager = licenses.LicensesManager(env.client)
18+
19+
options = licenses_manager.get_create_options()
20+
21+
table = formatting.Table(['Id', 'description', 'keyName', 'recurringFee'])
22+
for item in options:
23+
table.add_row([item.get('id'),
24+
utils.trim_to(item.get('description'), 40),
25+
item.get('keyName'),
26+
item.get('prices')[0]['recurringFee']])
27+
28+
env.fout(table)

SoftLayer/CLI/routes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@
124124
('email:detail', 'SoftLayer.CLI.email.detail:cli'),
125125
('email:edit', 'SoftLayer.CLI.email.edit:cli'),
126126

127+
('licenses', 'SoftLayer.CLI.licenses'),
128+
('licenses:create-options', 'SoftLayer.CLI.licenses.create_options:cli'),
129+
127130
('event-log', 'SoftLayer.CLI.event_log'),
128131
('event-log:get', 'SoftLayer.CLI.event_log.get:cli'),
129132
('event-log:types', 'SoftLayer.CLI.event_log.types:cli'),

SoftLayer/fixtures/SoftLayer_Product_Package.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,3 +2055,29 @@
20552055
"categoryCode": "dedicated_virtual_hosts"
20562056
}
20572057
}]}
2058+
2059+
getItems_vmware = [{
2060+
"capacity": "2",
2061+
"description": "VMware vSAN Enterprise Tier III 65 - 124 TB 6.x",
2062+
"id": 9567,
2063+
"itemTaxCategoryId": 166,
2064+
"keyName": "VMWARE_VSAN_ENTERPRISE_TIER_III_65_124_TB_6_X_2",
2065+
"softwareDescriptionId": 1979,
2066+
"units": "CPU",
2067+
"itemCategory": {
2068+
"categoryCode": "software_license",
2069+
"id": 438,
2070+
"name": "Software License",
2071+
"quantityLimit": 1,
2072+
},
2073+
"prices": [
2074+
{
2075+
"id": 245164,
2076+
"itemId": 9567,
2077+
"laborFee": "0",
2078+
"locationGroupId": None,
2079+
"recurringFee": "0",
2080+
"setupFee": "0",
2081+
"sort": 0,
2082+
}
2083+
]}]

SoftLayer/managers/licenses.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
SoftLayer.license
3+
~~~~~~~~~~~~~~~
4+
License Manager
5+
:license: MIT, see LICENSE for more details.
6+
"""
7+
8+
9+
# pylint: disable=too-many-public-methods
10+
11+
12+
class LicensesManager(object):
13+
"""Manages account lincese."""
14+
15+
def __init__(self, client):
16+
self.client = client
17+
18+
def get_create_options(self):
19+
"""Returns valid options for ordering Licenses.
20+
21+
:param string datacenter: short name, like dal09
22+
"""
23+
24+
return self.client.call('SoftLayer_Product_Package', 'getItems',
25+
id=301)

docs/cli/licenses.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. _cli_licenses:
2+
3+
licenses Commands
4+
=================
5+
6+
.. click:: SoftLayer.CLI.licenses.create-options:cli
7+
:prog: licenses create-options
8+
:show-nested:

tests/CLI/modules/licenses_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from SoftLayer.fixtures import SoftLayer_Product_Package
2+
from SoftLayer import testing
3+
4+
5+
class LicensesTests(testing.TestCase):
6+
7+
def test_create(self):
8+
_mock = self.set_mock('SoftLayer_Product_Package', 'getItems')
9+
10+
_mock.return_value = SoftLayer_Product_Package.getItems_vmware
11+
12+
result = self.run_command(['licenses', 'create-options'])
13+
self.assert_no_fail(result)

0 commit comments

Comments
 (0)