Skip to content

Commit 72f8eb1

Browse files
author
Fernando
committed
Refactor the cdn edit option.
1 parent cb508db commit 72f8eb1

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

SoftLayer/CLI/cdn/edit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
help="HTTP port."
2121
)
2222
@click.option('--origin', '-o',
23-
required=True,
2423
type=click.STRING,
2524
help="Origin server address."
2625
)
@@ -43,7 +42,7 @@
4342
def cli(env, identifier, header, http_port, origin, respect_headers, cache, performance_configuration):
4443
"""Edit a CDN Account.
4544
46-
You can use the hostname or uniqueId as IDENTIFIER.
45+
Note: You can use the hostname or uniqueId as IDENTIFIER.
4746
"""
4847

4948
manager = SoftLayer.CDNManager(env.client)
@@ -77,5 +76,6 @@ def cli(env, identifier, header, http_port, origin, respect_headers, cache, perf
7776
table.add_row(['Vendor Name', cdn.get('vendorName')])
7877
table.add_row(['Cache key optimization', cdn.get('cacheKeyQueryRule')])
7978
table.add_row(['cname', cdn.get('cname')])
79+
table.add_row(['Origin server address', cdn.get('originHost')])
8080

8181
env.fout(table)

SoftLayer/managers/cdn.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ def edit(self, identifier, header=None, http_port=None, origin=None,
199199
'vendorName': cdn_instance_detail.get('vendorName'),
200200
'cname': cdn_instance_detail.get('cname'),
201201
'domain': cdn_instance_detail.get('domain'),
202-
'httpPort': cdn_instance_detail.get('httpPort')
202+
'httpPort': cdn_instance_detail.get('httpPort'),
203+
'origin': cdn_instance_detail.get('originHost')
203204
}
204205

205206
if header:

tests/CLI/modules/cdn_tests.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,36 +97,32 @@ def test_remove_origin(self):
9797
self.assertEqual(result.output, "Origin with path /example1 has been deleted\n")
9898

9999
def test_edit_header(self):
100-
result = self.run_command(['cdn', 'edit', 'test.example.com',
101-
'--origin=10.34.12.125', '--header=www.test.com'])
100+
result = self.run_command(['cdn', 'edit', 'test.example.com', '--header=www.test.com'])
102101
self.assert_no_fail(result)
103102
header_result = json.loads(result.output)
104103
self.assertEqual('www.test.com', header_result['Header'])
105104

106105
def test_edit_http_port(self):
107-
result = self.run_command(['cdn', 'edit', 'test.example.com',
108-
'--origin=10.34.12.125', '--http-port=83'])
106+
result = self.run_command(['cdn', 'edit', 'test.example.com', '--http-port=83'])
109107
self.assert_no_fail(result)
110108
header_result = json.loads(result.output)
111109
self.assertEqual(83, header_result['Http Port'])
112110

113111
def test_edit_respect_headers(self):
114-
result = self.run_command(['cdn', 'edit', 'test.example.com',
115-
'--origin=10.34.12.125', '--respect-headers=1'])
112+
result = self.run_command(['cdn', 'edit', 'test.example.com', '--respect-headers=1'])
116113
self.assert_no_fail(result)
117114
header_result = json.loads(result.output)
118115
self.assertEqual(True, header_result['Respect Headers'])
119116

120117
def test_edit_cache(self):
121-
result = self.run_command(['cdn', 'edit', 'test.example.com',
122-
'--origin=10.34.12.125', '--cache', 'include-specified', '--cache', 'test'])
118+
result = self.run_command(['cdn', 'edit', 'test.example.com', '--cache', 'include-specified',
119+
'--cache', 'test'])
123120
self.assert_no_fail(result)
124121
header_result = json.loads(result.output)
125122
self.assertEqual('include: test', header_result['Cache key optimization'])
126123

127124
def test_edit_cache_by_uniqueId(self):
128-
result = self.run_command(['cdn', 'edit', '9934111111111',
129-
'--origin=10.34.12.125', '--cache', 'include-specified', '--cache', 'test'])
125+
result = self.run_command(['cdn', 'edit', '9934111111111', '--cache', 'include-specified', '--cache', 'test'])
130126
self.assert_no_fail(result)
131127
header_result = json.loads(result.output)
132128
self.assertEqual('include: test', header_result['Cache key optimization'])

tests/managers/cdn_tests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ def test_purge_content(self):
107107
def test_cdn_edit(self):
108108
identifier = '9934111111111'
109109
header = 'www.test.com'
110-
origin = '1.1.1.1'
111-
result = self.cdn_client.edit(identifier, header=header, origin=origin)
110+
result = self.cdn_client.edit(identifier, header=header)
112111

113112
self.assertEqual(fixtures.SoftLayer_Network_CdnMarketplace_Configuration_Mapping.
114113
updateDomainMapping, result)

0 commit comments

Comments
 (0)