Skip to content

Commit 13f0fc8

Browse files
Merge pull request #1918 from caberos/issue1915
New command: slcli order quote-delete
2 parents 5c08bac + c3e4839 commit 13f0fc8

File tree

8 files changed

+120
-78
lines changed

8 files changed

+120
-78
lines changed

SoftLayer/CLI/order/quote_delete.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Delete the quote of an order"""
2+
# :license: MIT, see LICENSE for more details.
3+
import click
4+
5+
from SoftLayer.CLI.command import SLCommand as SLCommand
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.managers import ordering
8+
9+
10+
@click.command(cls=SLCommand)
11+
@click.argument('identifier')
12+
@environment.pass_env
13+
def cli(env, identifier):
14+
"""Delete the quote of an order"""
15+
16+
manager = ordering.OrderingManager(env.client)
17+
result = manager.delete_quote(identifier)
18+
19+
if result:
20+
env.fout(f"Quote id: {identifier} was deleted.")

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@
275275
('order:place-quote', 'SoftLayer.CLI.order.place_quote:cli'),
276276
('order:quote-list', 'SoftLayer.CLI.order.quote_list:cli'),
277277
('order:quote-detail', 'SoftLayer.CLI.order.quote_detail:cli'),
278+
('order:quote-delete', 'SoftLayer.CLI.order.quote_delete:cli'),
278279
('order:quote-save', 'SoftLayer.CLI.order.quote_save:cli'),
279280
('order:quote', 'SoftLayer.CLI.order.quote:cli'),
280281
('order:lookup', 'SoftLayer.CLI.order.lookup:cli'),

SoftLayer/fixtures/SoftLayer_Billing_Order_Quote.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,4 @@
104104
}
105105

106106
saveQuote = getObject
107+
deleteQuote = getObject

SoftLayer/managers/ordering.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,3 +737,11 @@ def get_regions(self, package_id, location=None):
737737
if location:
738738
_filter = {"regions": {"location": {"location": {"name": {"operation": location}}}}}
739739
return self.client.call('SoftLayer_Product_Package', 'getRegions', id=package_id, filter=_filter)
740+
741+
def delete_quote(self, quote_id):
742+
"""Delete the quote of an order.
743+
744+
:param quote_id: ID number of target quote
745+
"""
746+
747+
return self.client['SoftLayer_Billing_Order_Quote'].deleteQuote(id=quote_id)

docs/cli/ordering.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ Quotes
139139
:prog: order place-quote
140140
:show-nested:
141141

142+
.. click:: SoftLayer.CLI.order.quote_delete:cli
143+
:prog: order quote-delete
144+
:show-nested:
145+
142146
Lookup
143147
======
144148
.. click:: SoftLayer.CLI.order.lookup:cli

tests/CLI/modules/order_tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,11 @@ def test_order_lookup(self):
442442
self.assertIn('Ordered By', result.output)
443443
self.assertIn('Initial Invoice', result.output)
444444

445+
def test_quote_delete(self):
446+
result = self.run_command(['order', 'quote-delete', '12345'])
447+
self.assert_no_fail(result)
448+
self.assert_called_with('SoftLayer_Billing_Order_Quote', 'deleteQuote', identifier='12345')
449+
445450

446451
def _get_all_packages():
447452
package_type = {'keyName': 'BARE_METAL_CPU'}

tests/CLI/modules/vs/vs_create_tests.py

Lines changed: 77 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,28 @@ def test_create_vlan_subnet(self, confirm_mock):
6969
self.assertIn('"guid": "1a2b3c-1701"', result.output)
7070
self.assert_called_with('SoftLayer_Product_Order', 'placeOrder')
7171
args = ({
72-
'startCpus': 2,
73-
'maxMemory': 1024,
74-
'hostname': 'host',
75-
'domain': 'example.com',
76-
'localDiskFlag': True,
77-
'hourlyBillingFlag': True,
78-
'supplementalCreateObjectOptions': {'bootMode': None},
79-
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
80-
'datacenter': {'name': 'dal05'},
81-
'primaryBackendNetworkComponent': {
82-
'networkVlan': {
83-
'id': 577940,
84-
'primarySubnet': {'id': 478700}
85-
}
86-
},
87-
'primaryNetworkComponent': {
88-
'networkVlan': {
89-
'id': 1639255,
90-
'primarySubnet': {'id': 297614}
91-
}
92-
}
93-
},)
72+
'startCpus': 2,
73+
'maxMemory': 1024,
74+
'hostname': 'host',
75+
'domain': 'example.com',
76+
'localDiskFlag': True,
77+
'hourlyBillingFlag': True,
78+
'supplementalCreateObjectOptions': {'bootMode': None},
79+
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
80+
'datacenter': {'name': 'dal05'},
81+
'primaryBackendNetworkComponent': {
82+
'networkVlan': {
83+
'id': 577940,
84+
'primarySubnet': {'id': 478700}
85+
}
86+
},
87+
'primaryNetworkComponent': {
88+
'networkVlan': {
89+
'id': 1639255,
90+
'primarySubnet': {'id': 297614}
91+
}
92+
}
93+
},)
9494

9595
self.assert_called_with('SoftLayer_Virtual_Guest', 'generateOrderTemplate', args=args)
9696

@@ -114,26 +114,26 @@ def test_create_by_router(self, confirm_mock):
114114
self.assert_no_fail(result)
115115
self.assert_called_with('SoftLayer_Product_Order', 'placeOrder')
116116
args = ({
117-
'startCpus': 2,
118-
'maxMemory': 1024,
119-
'hostname': 'host',
120-
'domain': 'example.com',
121-
'localDiskFlag': True,
122-
'hourlyBillingFlag': True,
123-
'supplementalCreateObjectOptions': {'bootMode': None},
124-
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
125-
'datacenter': {'name': 'dal05'},
126-
'primaryBackendNetworkComponent': {
117+
'startCpus': 2,
118+
'maxMemory': 1024,
119+
'hostname': 'host',
120+
'domain': 'example.com',
121+
'localDiskFlag': True,
122+
'hourlyBillingFlag': True,
123+
'supplementalCreateObjectOptions': {'bootMode': None},
124+
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
125+
'datacenter': {'name': 'dal05'},
126+
'primaryBackendNetworkComponent': {
127127
'router': {
128128
'id': 577940
129129
}
130-
},
131-
'primaryNetworkComponent': {
132-
'router': {
133-
'id': 1639255
134-
}
135-
}
136-
},)
130+
},
131+
'primaryNetworkComponent': {
132+
'router': {
133+
'id': 1639255
134+
}
135+
}
136+
},)
137137

138138
self.assert_called_with('SoftLayer_Virtual_Guest', 'generateOrderTemplate', args=args)
139139

@@ -216,17 +216,17 @@ def test_create_with_integer_image_guid(self, confirm_mock):
216216
self.assert_no_fail(result)
217217
self.assertIn('"guid": "1a2b3c-1701"', result.output)
218218
args = ({
219-
'startCpus': 2,
220-
'maxMemory': 1024,
221-
'hostname': 'host',
222-
'domain': 'example.com',
223-
'localDiskFlag': True,
224-
'hourlyBillingFlag': True,
225-
'supplementalCreateObjectOptions': {'bootMode': None},
226-
'blockDeviceTemplateGroup': {'globalIdentifier': 'aaaa1111bbbb2222'},
227-
'datacenter': {'name': 'dal05'},
228-
'networkComponents': [{'maxSpeed': 100}]
229-
},)
219+
'startCpus': 2,
220+
'maxMemory': 1024,
221+
'hostname': 'host',
222+
'domain': 'example.com',
223+
'localDiskFlag': True,
224+
'hourlyBillingFlag': True,
225+
'supplementalCreateObjectOptions': {'bootMode': None},
226+
'blockDeviceTemplateGroup': {'globalIdentifier': 'aaaa1111bbbb2222'},
227+
'datacenter': {'name': 'dal05'},
228+
'networkComponents': [{'maxSpeed': 100}]
229+
},)
230230

231231
self.assert_called_with('SoftLayer_Virtual_Guest', 'generateOrderTemplate', args=args)
232232
self.assert_called_with('SoftLayer_Product_Order', 'placeOrder')
@@ -345,18 +345,18 @@ def test_create_with_host_id(self, confirm_mock):
345345

346346
self.assert_called_with('SoftLayer_Product_Order', 'placeOrder')
347347
template_args = ({
348-
'startCpus': 2,
349-
'maxMemory': 1024,
350-
'hostname': 'host',
351-
'domain': 'example.com',
352-
'localDiskFlag': True,
353-
'hourlyBillingFlag': True,
354-
'supplementalCreateObjectOptions': {'bootMode': None},
355-
'dedicatedHost': {'id': 123},
356-
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
357-
'datacenter': {'name': 'dal05'},
358-
'networkComponents': [{'maxSpeed': 100}]
359-
},)
348+
'startCpus': 2,
349+
'maxMemory': 1024,
350+
'hostname': 'host',
351+
'domain': 'example.com',
352+
'localDiskFlag': True,
353+
'hourlyBillingFlag': True,
354+
'supplementalCreateObjectOptions': {'bootMode': None},
355+
'dedicatedHost': {'id': 123},
356+
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
357+
'datacenter': {'name': 'dal05'},
358+
'networkComponents': [{'maxSpeed': 100}]
359+
},)
360360

361361
self.assert_called_with('SoftLayer_Virtual_Guest', 'generateOrderTemplate', args=template_args)
362362

@@ -633,22 +633,21 @@ def test_create_with_ipv6(self, confirm_mock):
633633
self.assertEqual(result.exit_code, 0)
634634
self.assert_called_with('SoftLayer_Product_Order', 'verifyOrder')
635635
args = ({
636-
'startCpus': None,
637-
'maxMemory': None,
638-
'hostname': 'TEST',
639-
'domain': 'TESTING',
640-
'localDiskFlag': None,
641-
'hourlyBillingFlag': True,
642-
'supplementalCreateObjectOptions': {
643-
'bootMode': None,
644-
'flavorKeyName': 'B1_2X8X25'
645-
},
646-
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
647-
'datacenter': {
648-
'name': 'TEST00'
649-
}
650-
},
651-
)
636+
'startCpus': None,
637+
'maxMemory': None,
638+
'hostname': 'TEST',
639+
'domain': 'TESTING',
640+
'localDiskFlag': None,
641+
'hourlyBillingFlag': True,
642+
'supplementalCreateObjectOptions': {
643+
'bootMode': None,
644+
'flavorKeyName': 'B1_2X8X25'
645+
},
646+
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
647+
'datacenter': {
648+
'name': 'TEST00'
649+
}
650+
},)
652651
self.assert_called_with('SoftLayer_Virtual_Guest', 'generateOrderTemplate', args=args)
653652
self.assertEqual([], self.calls('SoftLayer_Virtual_Guest', 'setTags'))
654653

tests/managers/ordering_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,3 +901,7 @@ def test_get_items(self):
901901
def test_get_regions(self):
902902
self.ordering.get_regions(123)
903903
self.assert_called_with('SoftLayer_Product_Package', 'getRegions')
904+
905+
def test_delete_quote(self):
906+
self.ordering.delete_quote(123)
907+
self.assert_called_with('SoftLayer_Billing_Order_Quote', 'deleteQuote')

0 commit comments

Comments
 (0)