Fixing wrong error messages:
The commands getDNS, getNTP and getDomainName
were throwing incorrect error message when they are
not set in the BMC.
The rmIP command was throwing error while deleting any
IP address, even when the IP exists in the interface.
This commit will fix the tool to throw the error
only for the IP which does not exist in the interface.
Tested by:
1. Delete the IP address from the eth0.
python openbmctool.py -H <$bmc> -U root -P 0penBmc network rmIP -I eth0 -a <IP address>
2. getDomainName when the DomainName is not configured.
python openbmctool.py -H <$bmc> -U root -P 0penBmc network getDomainName -I eth0
3. getDNS when the DNS is not configured.
python openbmctool.py -H <$bmc> -U root -P 0penBmc network getDNS -I eth0
4. getNTP when the NTP is not configured.
python openbmctool.py -H <$bmc> -U root -P 0penBmc network getNTP -I eth0
Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com>
Change-Id: I6463f78b4d6e8b15a1c512734c883b563db82dd1
diff --git a/thalerj/openbmctool.py b/thalerj/openbmctool.py
index 34ed5b5..7eee2d3 100644
--- a/thalerj/openbmctool.py
+++ b/thalerj/openbmctool.py
@@ -3107,8 +3107,7 @@
except(requests.exceptions.ConnectionError) as err:
return connectionErrHandler(args.json, "ConnectionError", err)
if res.status_code == 404:
- return "The specified Interface"+"("+args.Interface+")"+\
- " doesn't exist"
+ return "The DomainName is not configured on Interface"+"("+args.Interface+")"
return res.text
@@ -3302,8 +3301,7 @@
except(requests.exceptions.ConnectionError) as err:
return connectionErrHandler(args.json, "ConnectionError", err)
if res.status_code == 404:
- return "The specified Interface"+"("+args.Interface+")" + \
- " doesn't exist"
+ return "The NameServer is not configured on Interface"+"("+args.Interface+")"
return res.text
@@ -3352,7 +3350,6 @@
url = "https://" + host + "/xyz/openbmc_project/network/" + args.Interface\
+ "/attr/NTPServers"
-
try:
res = session.get(url, headers=jsonHeader, verify=False, timeout=baseTimeout)
except(requests.exceptions.Timeout):
@@ -3360,8 +3357,7 @@
except(requests.exceptions.ConnectionError) as err:
return connectionErrHandler(args.json, "ConnectionError", err)
if res.status_code == 404:
- return "The specified Interface"+"("+args.Interface+")" + \
- " doesn't exist"
+ return "The NTPServer is not configured on Interface"+"("+args.Interface+")"
return res.text
@@ -3483,7 +3479,6 @@
objDict = json.loads(res.text)
if not objDict['data']:
return "No object found for given address on given Interface"
-
for obj in objDict['data']:
try:
if args.address in objDict['data'][obj]['Address']:
@@ -3499,8 +3494,9 @@
else:
continue
except KeyError:
- return "No object found for address " + args.address + \
- " on Interface(" + args.Interface + ")"
+ continue
+ return "No object found for address " + args.address + \
+ " on Interface(" + args.Interface + ")"
def addVLAN(host, args, session):