Skip to content

Commit 567421b

Browse files
authored
Merge pull request CiscoUcs#15 from parag-may4/callhome_fix
add/modify/delete call home proxy config object
2 parents 4dbb6a1 + d83ea43 commit 567421b

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

tests/admin/test_callhome.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ def test_004_callhome_config():
5151

5252

5353
def test_005_callhome_proxy_config():
54-
mo = call_home_proxy_config(handle, url="sch.proxycisco.com", port="80")
55-
assert_equal(mo.url, "sch.proxycisco.com")
54+
mo = call_home_proxy_config(handle, url="http://sch.proxycisco.com", port="80")
55+
assert_equal(mo.url, "http://sch.proxycisco.com")
56+
mo = call_home_proxy_config(handle, url="", port="80")
57+
assert_equal(mo, None)
5658

5759

5860
def test_006_callhome_disable():

ucsc_apis/admin/callhome.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,14 @@ def call_home_proxy_config(handle, url, port="80", **kwargs):
168168
Args:
169169
handle (UcscHandle)
170170
url (String) : URL for the call home proxy
171+
To clear proxy config, set this as empty string ("")
171172
port (String) : port number for the call home proxy
173+
To clear proxy config, set this as empty string ("")
172174
**kwargs: Any additional key-value pair of managed object(MO)'s
173175
property and value, which are not part of regular args.
174176
This should be used for future version compatibility.
175177
Returns:
176-
SmartcallhomeHttpProxy : ManagedObject
178+
SmartcallhomeHttpProxy : ManagedObject or None
177179
178180
Raises:
179181
UcscOperationError: If SmartcallhomeHttpProxy is not present
@@ -182,16 +184,20 @@ def call_home_proxy_config(handle, url, port="80", **kwargs):
182184
call_home_proxy_config(handle, url="www.testproxy.com", port=80)
183185
"""
184186

185-
mo = handle.query_dn(ucsc_base_dn + "/call-home/proxy")
186-
if not mo:
187-
raise UcscOperationError("call_home_proxy_config",
188-
"call home proxy is not available.")
189-
190-
mo.url = url
191-
mo.port = port
187+
from ucscsdk.mometa.smartcallhome.SmartcallhomeHttpProxy import \
188+
SmartcallhomeHttpProxy
189+
mo = SmartcallhomeHttpProxy(parent_mo_or_dn=ucsc_base_dn + "/call-home",
190+
url=url,
191+
port=port)
192192

193193
mo.set_prop_multiple(**kwargs)
194194

195+
if url == "" or port == "":
196+
mo.port = None
197+
handle.remove_mo(mo)
198+
handle.commit()
199+
return
200+
195201
handle.add_mo(mo, modify_present=True)
196202
handle.commit()
197203
return mo

0 commit comments

Comments
 (0)