Add redfishtool package

Add redfishtool package to controller nodes
It will be used by maintenance processes(mtcAgent and hwmon).
Two patches are required.
1. python2 support patch
2. config file support patch

Deploy test pass
redfishtool can run normally in controller node.

Story: 2005861
Task: 34187

Depends-On: https://review.opendev.org/665993/
Change-Id: I69e08cffd8587cb4287394f2b7a2f46fd3d054d9
Signed-off-by: zhipengl <zhipengs.liu@intel.com>
This commit is contained in:
zhipengl 2019-06-20 23:14:09 +08:00 committed by zhipeng liu
parent bea9f54079
commit f5db9e98f4
6 changed files with 748 additions and 0 deletions

View File

@ -0,0 +1,6 @@
COPY_LIST=" \
$STX_BASE/downloads/Redfishtool-1.0.8.tar.gz \
$PKG_BASE/files/* \
"
TIS_PATCH_VER=0

View File

@ -0,0 +1,63 @@
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright (c) 2016, Contributing Member(s) of Distributed Management
# Task Force, Inc.. All rights reserved.
Summary: Redfish Tool Package
Name: Redfishtool
Version: 1.0.8
Release: %{?_tis_dist}.%{tis_patch_ver}
#For full text see link: https://github.com/DMTF/Redfishtool/blob/master/LICENSE.md
License: BSD-3-Clause.
Group: base
Packager: StarlingX
URL: https://github.com/DMTF/Redfishtool
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
Patch01: 0001-Adapt-redfishtool-to-python2.patch
Patch02: 0002-Add-configfile-option-support.patch
BuildRequires: python-setuptools
Requires: python-requests
%description
Redfish Tool Package
%define pythonroot /usr/lib64/python2.7/site-packages
%define debug_package %{nil}
%prep
%setup
%patch01 -p1
%patch02 -p1
# Remove bundled egg-info
rm -rf *.egg-info
%build
%{__python} setup.py build
%install
%{__python} setup.py install --root=%{buildroot} \
--install-lib=%{pythonroot} \
--prefix=/usr \
--install-data=/usr/share \
--single-version-externally-managed
%post
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
%doc LICENSE.md
%{pythonroot}/redfishtool/*
%{pythonroot}/redfishtool-%{version}*.egg-info
%{_bindir}/redfishtool

View File

@ -0,0 +1,640 @@
From ecaf5c44da357e2ee5279a3f84a060f7af2c9dd1 Mon Sep 17 00:00:00 2001
From: zhipengl <zhipengs.liu@intel.com>
Date: Fri, 21 Jun 2019 01:50:14 +0800
Subject: [PATCH] Adapt-redfishtool-to-python2
Signed-off-by: zhipengl <zhipengs.liu@intel.com>
---
redfishtool/AccountService.py | 18 +++++++++---------
redfishtool/Chassis.py | 22 +++++++++++-----------
redfishtool/Managers.py | 29 ++++++++++++++---------------
redfishtool/ServiceRoot.py | 2 +-
redfishtool/SessionService.py | 10 +++++-----
redfishtool/Systems.py | 36 ++++++++++++++++++------------------
redfishtool/raw.py | 2 +-
redfishtool/redfishtoolTransport.py | 29 ++++++++++++++---------------
setup.py | 1 +
9 files changed, 74 insertions(+), 75 deletions(-)
diff --git a/redfishtool/AccountService.py b/redfishtool/AccountService.py
index e0ec106..bfb17f8 100644
--- a/redfishtool/AccountService.py
+++ b/redfishtool/AccountService.py
@@ -34,7 +34,7 @@ import getopt
import re
import sys
from .ServiceRoot import RfServiceRoot
-from urllib.parse import urljoin
+from urlparse import urljoin
class RfAccountServiceMain():
def __init__(self):
@@ -259,13 +259,13 @@ class RfAccountServiceOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="UserName")
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, UserName".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," list {} Collection member info: Id, URI, UserName".format(collName), skip1=True, printV12=cmdTop)
# else: check if no account was specified. If not, return the collection
elif(rft.IdLevel2OptnCount==0):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=accountsLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection ".format(collName), skip1=True, printV12=cmdTop)
# else: check if the -a (all) option is set. If not, return the session specific by -i or -m or -l
# search collection to find path using getPath2
@@ -287,14 +287,14 @@ class RfAccountServiceOperations():
elif( r is None ):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', collUrl, relPath=path2, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection Member ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection Member ".format(collName), skip1=True, printV12=cmdTop)
# else, return ALL of the Accounts members
else:
rft.printVerbose(4,"getting expanded Accounts Collection")
rc,r,j,d=rft.getAllCollectionMembers(rft, r.url, relPath=accountsLink)
if(rc==0):
- rft.printVerbose(1," Get ALL {} Collection Members".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get ALL {} Collection Members".format(collName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
@@ -324,13 +324,13 @@ class RfAccountServiceOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="IsPredefined")
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, IsPredefined".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," list {} Collection member info: Id, URI, IsPredefined".format(collName), skip1=True, printV12=cmdTop)
# else: check if no account was specified. If not, return the collection
elif(rft.IdLevel2OptnCount==0):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=rolesLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection ".format(collName), skip1=True, printV12=cmdTop)
# else: check if the -a (all) option is set. If not, return the session specific by -i or -m or -l
# search collection to find path using getPath2
@@ -352,14 +352,14 @@ class RfAccountServiceOperations():
elif( r is None ):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', collUrl, relPath=path2, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection Member ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection Member ".format(collName), skip1=True, printV12=cmdTop)
# else, return ALL of the Accounts members
else:
rft.printVerbose(4,"getting expanded Roles Collection")
rc,r,j,d=rft.getAllCollectionMembers(rft, r.url, relPath=rolesLink)
if(rc==0):
- rft.printVerbose(1," Get ALL {} Collection Members".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get ALL {} Collection Members".format(collName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
diff --git a/redfishtool/Chassis.py b/redfishtool/Chassis.py
index d8f0bf5..0494bd9 100644
--- a/redfishtool/Chassis.py
+++ b/redfishtool/Chassis.py
@@ -37,7 +37,7 @@ import getopt
import re
import sys
from .ServiceRoot import RfServiceRoot
-from urllib.parse import urljoin
+from urlparse import urljoin
class RfChassisMain():
def __init__(self):
@@ -208,7 +208,7 @@ class RfChassisOperations():
rft.printVerbose(4,"Expand Chassis collection to return ALL Chassis collection members fully expanded in response")
rc,r,j,d=rft.getAllCollectionMembers(rft, r.url, relPath=systemsLink)
if(rc==0):
- rft.printVerbose(1," Get ALL {} Collection Members".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get ALL {} Collection Members".format(collName), skip1=True, printV12=cmdTop)
# otherwise, just return the collection
# now read the /Chassis collection
@@ -217,7 +217,7 @@ class RfChassisOperations():
if cmdTop is True: prop=rft.prop
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=systemsLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," Chassis Collection:",skip1=True, printV12=cmdTop)
+ rft.printVerbose(1," Chassis Collection:", skip1=True, printV12=cmdTop)
return(rc,r,j,d)
@@ -262,7 +262,7 @@ class RfChassisOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="AssetTag")
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, AssetTag".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," list {} Collection member info: Id, URI, AssetTag".format(collName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
@@ -439,7 +439,7 @@ class RfChassisOperations():
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=resLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Resource ".format(resName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Resource ".format(resName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
@@ -464,7 +464,7 @@ class RfChassisOperations():
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=resLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Resource ".format(resName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Resource ".format(resName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
@@ -521,13 +521,13 @@ class RfChassisOperations():
if( prop in powerControl[indx] ):
respDataVal=powerControl[indx][prop]
respData={prop: respDataVal}
- rft.printVerbose(1," Get Current Power consumption (PowerConsumedWatts) of PowerControl[{}] resource".format(indx,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get Current Power consumption (PowerConsumedWatts) of PowerControl[{}] resource".format(indx), skip1=True, printV12=cmdTop)
else:
rft.printErr("Error: Property {} not not returned in PowerControl[{}] resource".format(prop,indx))
return(4,r,j,d)
else:
respData=powerControl[indx] #return the full powerControl array
- rft.printVerbose(1," Chassis PowerControl[{}] array:".format(indx,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Chassis PowerControl[{}] array:".format(indx), skip1=True, printV12=cmdTop)
return(rc,r,j,respData)
@@ -684,13 +684,13 @@ class RfChassisOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="Name")
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName), skip1=True, printV12=cmdTop)
# else: check if no Log was specified. If not, return the collection
elif(rft.IdLevel2OptnCount==0):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=logLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection ".format(collName), skip1=True, printV12=cmdTop)
# else: check if the -a (all) option is set. If not, return the proc specific by -i or -m
# search collection to find path using getPath2
@@ -712,7 +712,7 @@ class RfChassisOperations():
elif( r is None ):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', collUrl, relPath=path2, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection Member ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection Member ".format(collName), skip1=True, printV12=cmdTop)
# If '--Entries' specified, get "Entries" nav link and read it
if rc == 0 and rft.gotEntriesOptn:
diff --git a/redfishtool/Managers.py b/redfishtool/Managers.py
index 586a871..400dad7 100644
--- a/redfishtool/Managers.py
+++ b/redfishtool/Managers.py
@@ -37,7 +37,7 @@ import getopt
import re
import sys
from .ServiceRoot import RfServiceRoot
-from urllib.parse import urljoin
+from urlparse import urljoin
class RfManagersMain():
def __init__(self):
@@ -211,7 +211,7 @@ class RfManagersOperations():
rft.printVerbose(4,"Expand Managers collection to return ALL Managers collection members fully expanded in response")
rc,r,j,d=rft.getAllCollectionMembers(rft, r.url, relPath=systemsLink)
if(rc==0):
- rft.printVerbose(1," Get ALL {} Collection Members".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get ALL {} Collection Members".format(collName), skip1=True, printV12=cmdTop)
# otherwise, just return the collection
# now read the /Managers collection
@@ -467,7 +467,7 @@ class RfManagersOperations():
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=resLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Resource ".format(resName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Resource ".format(resName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
@@ -503,13 +503,13 @@ class RfManagersOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="Name")
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName), skip1=True, printV12=cmdTop)
# else: check if no NIC was specified. If not, return the collection
elif(rft.IdLevel2OptnCount==0):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=nicLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection ".format(collName), skip1=True, printV12=cmdTop)
# else: check if the -a (all) option is set. If not, return the proc specific by -i or -m
# search collection to find path using getPath2
@@ -531,14 +531,14 @@ class RfManagersOperations():
elif( r is None ):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', collUrl, relPath=path2, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection Member ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection Member ".format(collName), skip1=True, printV12=cmdTop)
# else, return ALL of the EthernetInterfaces members
else:
rft.printVerbose(4,"getting expanded EthernetInterfaces Collection")
rc,r,j,d=rft.getAllCollectionMembers(rft, r.url, relPath=nicLink)
if(rc==0):
- rft.printVerbose(1," Get ALL {} Collection Members".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get ALL {} Collection Members".format(collName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
@@ -568,13 +568,13 @@ class RfManagersOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="Name" )
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName), skip1=True, printV12=cmdTop)
# else: check if no SerialInterfaces controller was specified. If not, return the collection
elif(rft.IdLevel2OptnCount==0):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=cntlrLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection ".format(collName), skip1=True, printV12=cmdTop)
# else: check if the -a (all) option is set. If not, return the proc specific by -i or -m
# search collection to find path using getPath2
@@ -596,14 +596,14 @@ class RfManagersOperations():
elif( r is None ):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', collUrl, relPath=path2, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection Member ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection Member ".format(collName), skip1=True, printV12=cmdTop)
# else, return ALL of the SerialInterfaces members
else:
rft.printVerbose(4,"getting expanded SerialInterfaces Collection")
rc,r,j,d=rft.getAllCollectionMembers(rft, r.url, relPath=cntlrLink)
if(rc==0):
- rft.printVerbose(1," Get ALL {} Collection Members".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get ALL {} Collection Members".format(collName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
@@ -633,13 +633,12 @@ class RfManagersOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="Name")
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName,skip1=True, printV12=cmdTop))
-
+ rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName), skip1=True, printV12=cmdTop)
# else: check if no Log was specified. If not, return the collection
elif(rft.IdLevel2OptnCount==0):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=logLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection ".format(collName), skip1=True, printV12=cmdTop)
# else: check if the -a (all) option is set. If not, return the proc specific by -i or -m
# search collection to find path using getPath2
@@ -661,7 +660,7 @@ class RfManagersOperations():
elif( r is None ):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', collUrl, relPath=path2, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection Member ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection Member ".format(collName), skip1=True, printV12=cmdTop)
# If '--Entries' specified, get "Entries" nav link and read it
if rc == 0 and rft.gotEntriesOptn:
diff --git a/redfishtool/ServiceRoot.py b/redfishtool/ServiceRoot.py
index 5d85b5d..9395b83 100644
--- a/redfishtool/ServiceRoot.py
+++ b/redfishtool/ServiceRoot.py
@@ -12,7 +12,7 @@
#
import requests
import json
-from urllib.parse import urljoin, urlparse, urlunparse
+from urlparse import urljoin, urlparse, urlunparse
class RfServiceRoot:
def __init__(self):
diff --git a/redfishtool/SessionService.py b/redfishtool/SessionService.py
index 7a07811..c7a1624 100644
--- a/redfishtool/SessionService.py
+++ b/redfishtool/SessionService.py
@@ -30,7 +30,7 @@ import getopt
import re
import sys
from .ServiceRoot import RfServiceRoot
-from urllib.parse import urljoin
+from urlparse import urljoin
class RfSessionServiceMain():
def __init__(self):
@@ -267,13 +267,13 @@ class RfSessionServiceOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="UserName")
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, Socket".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," list {} Collection member info: Id, URI, Socket".format(collName), skip1=True, printV12=cmdTop)
# else: check if no session was specified. If not, return the collection
elif(rft.IdLevel2OptnCount==0):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=sessionsLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection ".format(collName), skip1=True, printV12=cmdTop)
# else: check if the -a (all) option is set. If not, return the session specific by -i or -m or -l
# search collection to find path using getPath2
@@ -295,14 +295,14 @@ class RfSessionServiceOperations():
elif( r is None ):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', collUrl, relPath=path2, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection Member ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection Member ".format(collName), skip1=True, printV12=cmdTop)
# else, return ALL of the Sessions members
else:
rft.printVerbose(4,"getting expanded Sessions Collection")
rc,r,j,d=rft.getAllCollectionMembers(rft, r.url, relPath=sessionsLink)
if(rc==0):
- rft.printVerbose(1," Get ALL {} Collection Members".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get ALL {} Collection Members".format(collName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
diff --git a/redfishtool/Systems.py b/redfishtool/Systems.py
index 9a7dfbe..9a9148a 100644
--- a/redfishtool/Systems.py
+++ b/redfishtool/Systems.py
@@ -39,7 +39,7 @@ import getopt
import re
import sys
from .ServiceRoot import RfServiceRoot
-from urllib.parse import urljoin
+from urlparse import urljoin
class RfSystemsMain():
def __init__(self):
@@ -216,7 +216,7 @@ class RfSystemsOperations():
rft.printVerbose(4,"Expand Systems collection to return ALL Systems collection members fully expanded in response")
rc,r,j,d=rft.getAllCollectionMembers(rft, r.url, relPath=systemsLink)
if(rc==0):
- rft.printVerbose(1," Get ALL {} Collection Members".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get ALL {} Collection Members".format(collName), skip1=True, printV12=cmdTop)
# otherwise, just return the collection
# now read the /Systems collection
@@ -419,7 +419,7 @@ class RfSystemsOperations():
reqData=reqPostData)
if(rc==0):
- rft.printVerbose(1," Systems reset: ", resetType, skip1=True, printV12=cmdTop)
+ rft.printVerbose(1,(" Systems reset: {}").format(resetType), skip1=True, printV12=cmdTop)
resetd=None
return(rc,r,False,resetd)
else: return(rc,r,False,None)
@@ -623,13 +623,13 @@ class RfSystemsOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="Socket")
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, Socket".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," list {} Collection member info: Id, URI, Socket".format(collName), skip1=True, printV12=cmdTop)
# else: check if no proc was specified. If not, return the collection
elif(rft.IdLevel2OptnCount==0):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=procsLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection ".format(collName), skip1=True, printV12=cmdTop)
# else: check if the -a (all) option is set. If not, return the proc specific by -i or -m
# search collection to find path using getPath2
@@ -651,14 +651,14 @@ class RfSystemsOperations():
elif( r is None ):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', collUrl, relPath=path2, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection Member ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection Member ".format(collName), skip1=True, printV12=cmdTop)
# else, return ALL of the processor members
else:
rft.printVerbose(4,"getting expanded Processor Collection")
rc,r,j,d=rft.getAllCollectionMembers(rft, r.url, relPath=procsLink)
if(rc==0):
- rft.printVerbose(1," Get ALL {} Collection Members".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get ALL {} Collection Members".format(collName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
@@ -688,13 +688,13 @@ class RfSystemsOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="Name")
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName), skip1=True, printV12=cmdTop)
# else: check if no NIC was specified. If not, return the collection
elif(rft.IdLevel2OptnCount==0):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=nicLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection ".format(collName), skip1=True, printV12=cmdTop)
# else: check if the -a (all) option is set. If not, return the proc specific by -i or -m
# search collection to find path using getPath2
@@ -716,14 +716,14 @@ class RfSystemsOperations():
elif( r is None ):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', collUrl, relPath=path2, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection Member ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection Member ".format(collName), skip1=True, printV12=cmdTop)
# else, return ALL of the EthernetInterfaces members
else:
rft.printVerbose(4,"getting expanded EthernetInterfaces Collection")
rc,r,j,d=rft.getAllCollectionMembers(rft, r.url, relPath=nicLink)
if(rc==0):
- rft.printVerbose(1," Get ALL {} Collection Members".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get ALL {} Collection Members".format(collName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
@@ -753,13 +753,13 @@ class RfSystemsOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="Name" )
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName), skip1=True, printV12=cmdTop)
# else: check if no SimpleStorage controller was specified. If not, return the collection
elif(rft.IdLevel2OptnCount==0):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=cntlrLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection ".format(collName), skip1=True, printV12=cmdTop)
# else: check if the -a (all) option is set. If not, return the proc specific by -i or -m
# search collection to find path using getPath2
@@ -781,14 +781,14 @@ class RfSystemsOperations():
elif( r is None ):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', collUrl, relPath=path2, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection Member ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection Member ".format(collName), skip1=True, printV12=cmdTop)
# else, return ALL of the SimpleStorage members
else:
rft.printVerbose(4,"getting expanded SimpleStorage Collection")
rc,r,j,d=rft.getAllCollectionMembers(rft, r.url, relPath=cntlrLink)
if(rc==0):
- rft.printVerbose(1," Get ALL {} Collection Members".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," Get ALL {} Collection Members".format(collName), skip1=True, printV12=cmdTop)
return(rc,r,j,d)
@@ -818,13 +818,13 @@ class RfSystemsOperations():
#loop through the members and create the list sub-operation response
rc,r,j,d=rft.listCollection(rft, r, d, prop="Name")
if(rc==0):
- rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," list {} Collection member info: Id, URI, Name".format(collName), skip1=True, printV12=cmdTop)
# else: check if no Log was specified. If not, return the collection
elif(rft.IdLevel2OptnCount==0):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', r.url, relPath=logLink, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection ".format(collName), skip1=True, printV12=cmdTop)
# else: check if the -a (all) option is set. If not, return the proc specific by -i or -m
# search collection to find path using getPath2
@@ -846,7 +846,7 @@ class RfSystemsOperations():
elif( r is None ):
rc,r,j,d=rft.rftSendRecvRequest(rft.AUTHENTICATED_API, 'GET', collUrl, relPath=path2, prop=prop)
if(rc==0):
- rft.printVerbose(1," {} Collection Member ".format(collName,skip1=True, printV12=cmdTop))
+ rft.printVerbose(1," {} Collection Member ".format(collName), skip1=True, printV12=cmdTop)
# If '--Entries' specified, get "Entries" nav link and read it
if rc == 0 and rft.gotEntriesOptn:
diff --git a/redfishtool/raw.py b/redfishtool/raw.py
index bfb617c..1b32d0b 100644
--- a/redfishtool/raw.py
+++ b/redfishtool/raw.py
@@ -30,7 +30,7 @@ import getopt
import re
import sys
#from .ServiceRoot import RfServiceRoot
-from urllib.parse import urljoin, urlparse, urlunparse
+from urlparse import urljoin, urlparse, urlunparse
class RfRawMain():
def __init__(self):
diff --git a/redfishtool/redfishtoolTransport.py b/redfishtool/redfishtoolTransport.py
index 017fa11..f157eff 100644
--- a/redfishtool/redfishtoolTransport.py
+++ b/redfishtool/redfishtoolTransport.py
@@ -39,7 +39,7 @@ import json
import sys
import socket
import time
-from urllib.parse import urljoin, urlparse, urlunparse
+from urlparse import urljoin, urlparse, urlunparse
from requests.auth import HTTPBasicAuth, AuthBase
from .ServiceRoot import RfServiceRoot
@@ -730,31 +730,32 @@ class RfTransport():
return(0)
- def printVerbose(self,v,*argv, skip1=False, printV12=True,**kwargs):
+ def printVerbose(self,v, argv, skip1=False, printV12=True):
if(self.quiet):
return(0)
if( (v==1 or v==2) and (printV12 is True) and (self.verbose >= v )):
if(skip1 is True): print("#")
- print("#",*argv, **kwargs)
+ print("#", argv)
elif( (v==1 or v==2) and (self.verbose >4 )):
if(skip1 is True): print("#")
- print("#",*argv, **kwargs)
+ print("#", argv)
elif((v==3 ) and (printV12 is True) and (self.verbose >=v)):
if(skip1 is True): print("#")
- print("#REQUEST:",*argv,file=sys.stdout,**kwargs)
+ sys.stdout.write("#REQUEST:",argv)
+ # print("#REQUEST:",argv,file=sys.stdout)
elif((v==4 or v==5) and (self.verbose >=v)):
if(skip1 is True): print("#")
- print("#DB{}:".format(v),*argv,file=sys.stdout,**kwargs)
+ sys.stdout.write("#DB{}:".format(v),argv)
+ # print("#DB{}:".format(v),argv,file=sys.stdout)
elif( v==0): #print no mater value of verbose, but not if quiet=1
if(skip1 is True): print("")
- print(*argv, **kwargs)
+ print(argv)
else:
pass
sys.stdout.flush()
#if you set v= anything except 0,1,2,3,4,5 it is ignored
-
def printStatus(self, s, r=None, hdrs=None, authMsg=None, addSessionLoginInfo=False):
if(self.quiet):
return(0)
@@ -785,22 +786,20 @@ class RfTransport():
sys.stdout.flush()
-
-
- def printErr(self,*argv,noprog=False,prepend="",**kwargs):
+ def printErr(self,argv,noprog=False,prepend=""):
if( self.quiet == False):
if(noprog is True):
- print(prepend,*argv, file=sys.stderr, **kwargs)
+ sys.stderr.write("{}{}".format(prepend,argv))
else:
- print(prepend," {}:".format(self.program),*argv, file=sys.stderr, **kwargs)
+ sys.stderr.write("{} {}:{}".format(prepend, self.program, argv))
else:
pass
-
+
sys.stderr.flush()
return(0)
- def printStatusErr4xx(self, status_code,*argv,noprog=False, prepend="",**kwargs):
+ def printStatusErr4xx(self, status_code):
if(self.quiet):
return(0)
if( status_code < 400 ):
diff --git a/setup.py b/setup.py
index d37d099..481f429 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,6 @@
from setuptools import setup
from os import path
+from io import open
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
--
2.7.4

View File

@ -0,0 +1,35 @@
From d0c3cc759545a82138329e292e99f310ec74047f Mon Sep 17 00:00:00 2001
From: zhipengl <zhipengs.liu@intel.com>
Date: Sat, 22 Jun 2019 02:06:54 +0800
Subject: [PATCH] Add configfile option support
Signed-off-by: zhipengl <zhipengs.liu@intel.com>
---
redfishtool/redfishtoolMain.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/redfishtool/redfishtoolMain.py b/redfishtool/redfishtoolMain.py
index cd3dd6f..ea2e44f 100644
--- a/redfishtool/redfishtoolMain.py
+++ b/redfishtool/redfishtoolMain.py
@@ -156,6 +156,17 @@ def main(argv):
rft.authToken=rft.token
elif opt in ("-c", "--config"): #read additional options from a file
rft.configFile=arg
+ try:
+ with open(arg, 'r') as f:
+ configdata = json.load(f)
+ if 'username' in configdata and 'password' in configdata:
+ rft.user = configdata['username']
+ rft.password = configdata['password']
+ rft.printVerbose(1,"Main: get pw from configfile, usr:{}, pw:{}".format(rft.user, rft.password))
+ else:
+ rft.printErr("Invalid --config= filedata: {}".format(configdata))
+ except IOError:
+ rft.printErr("Invalid: Could not open configfile")
elif opt in ("-T", "--Timeout"): #Specify http timeout in seconds
timePattern="^([1-9][0-9]*)$"
timeMatch=re.search(timePattern,arg)
--
2.7.4

View File

@ -342,3 +342,6 @@ python2-ruamel-yaml
# util-linux-config
util-linux-config
# redfish tool
Redfishtool

View File

@ -140,3 +140,4 @@ grub/grub2
utilities/build-info
ceph/ceph
ceph/ceph-manager
bmc/Redfishtool