Some PEP8 cleanup

This commit is contained in:
Uggla 2016-02-12 09:11:05 +01:00
parent 89ae5f7d76
commit e699acf328

View File

@ -23,7 +23,7 @@ class Base(object):
self.api_url = tortilla.wrap(url, debug=config.TORTILLADEBUG) self.api_url = tortilla.wrap(url, debug=config.TORTILLADEBUG)
try: try:
if connection_parameters.auth_token == None: if connection_parameters.auth_token is None:
self.data = self.api_url.get(verify=connection_parameters.verify_cert) self.data = self.api_url.get(verify=connection_parameters.verify_cert)
else: else:
self.data = self.api_url.get(verify=connection_parameters.verify_cert, self.data = self.api_url.get(verify=connection_parameters.verify_cert,
@ -63,11 +63,11 @@ class Base(object):
if float(mapping.redfish_version) < 1.00: if float(mapping.redfish_version) < 1.00:
links = getattr(self.data, mapping.redfish_mapper.map_links()) links = getattr(self.data, mapping.redfish_mapper.map_links())
if link_type in links: if link_type in links:
return urljoin(self.url, links[link_type][mapping.redfish_mapper.map_links_ref()]) return urljoin(self.url, links[link_type][mapping.redfish_mapper.map_links_ref()])
else: else:
links = getattr(self.data, link_type) links = getattr(self.data, link_type)
link = getattr(links, mapping.redfish_mapper.map_links_ref()) link = getattr(links, mapping.redfish_mapper.map_links_ref())
return urljoin(self.url, link) return urljoin(self.url, link)
@property @property
def url(self): def url(self):
@ -138,8 +138,7 @@ class BaseCollection(Base):
def __init__(self, url, connection_parameters): def __init__(self, url, connection_parameters):
super(BaseCollection, self).__init__(url, connection_parameters) super(BaseCollection, self).__init__(url, connection_parameters)
self.links=[] self.links = []
#linksmembers = self.data.Links.Members #linksmembers = self.data.Links.Members
#linksmembers = self.data.links.Member #linksmembers = self.data.links.Member
@ -153,7 +152,6 @@ class BaseCollection(Base):
#self.links.append(getattr(link,'href')) #self.links.append(getattr(link,'href'))
self.links.append(urljoin(self.url, getattr(link, mapping.redfish_mapper.map_links_ref()))) self.links.append(urljoin(self.url, getattr(link, mapping.redfish_mapper.map_links_ref())))
config.logger.debug(self.links) config.logger.debug(self.links)
@ -204,10 +202,10 @@ class Managers(Base):
try: try:
# New proliant firmware now respects Redfish v1.00, so seems to correct below statement # New proliant firmware now respects Redfish v1.00, so seems to correct below statement
# TODO : better handle exception and if possible support old firmware ? # TODO : better handle exception and if possible support old firmware ?
self.ethernet_interfaces_collection = EthernetInterfacesCollection( self.ethernet_interfaces_collection = \
self.get_link_url('EthernetInterfaces'), EthernetInterfacesCollection(
connection_parameters self.get_link_url('EthernetInterfaces'),
) connection_parameters)
# Works on proliant, need to treat 095 vs 0.96 differences # Works on proliant, need to treat 095 vs 0.96 differences
#self.ethernet_interfaces_collection = EthernetInterfacesCollection( #self.ethernet_interfaces_collection = EthernetInterfacesCollection(
@ -222,7 +220,6 @@ class Managers(Base):
# This means we don't have EthernetInterfaces # This means we don't have EthernetInterfaces
self.ethernet_interfaces_collection = None self.ethernet_interfaces_collection = None
def get_firmware_version(self): def get_firmware_version(self):
'''Get firmware version of the manager '''Get firmware version of the manager
@ -473,7 +470,8 @@ class Boot(Base):
class EthernetInterfacesCollection(BaseCollection): class EthernetInterfacesCollection(BaseCollection):
'''Class to manage redfish EthernetInterfacesColkection data.''' '''Class to manage redfish EthernetInterfacesColkection data.'''
def __init__(self, url, connection_parameters): def __init__(self, url, connection_parameters):
super(EthernetInterfacesCollection, self).__init__(url, connection_parameters) super(EthernetInterfacesCollection,
self).__init__(url, connection_parameters)
self.ethernet_interfaces_dict = {} self.ethernet_interfaces_dict = {}
@ -482,7 +480,8 @@ class EthernetInterfacesCollection(BaseCollection):
# Check more than 1 hour for this bug.... grrr.... # Check more than 1 hour for this bug.... grrr....
for link in self.links: for link in self.links:
index = re.search(r'EthernetInterfaces/(\w+)', link) index = re.search(r'EthernetInterfaces/(\w+)', link)
self.ethernet_interfaces_dict[index.group(1)] = EthernetInterfaces(link, connection_parameters) self.ethernet_interfaces_dict[index.group(1)] = \
EthernetInterfaces(link, connection_parameters)
class EthernetInterfaces(Base): class EthernetInterfaces(Base):
@ -509,7 +508,6 @@ class EthernetInterfaces(Base):
except AttributeError: except AttributeError:
return "Not available" return "Not available"
def get_ipv4(self): def get_ipv4(self):
'''Get EthernetInterface ipv4 address '''Get EthernetInterface ipv4 address