Cleanup to respect pep8 coding standard.
This commit is contained in:
parent
6dbed9f32b
commit
9acb9e9b5e
|
@ -4,23 +4,22 @@ import ConfigParser
|
|||
|
||||
|
||||
class AlexandriaConfiguration(object):
|
||||
|
||||
|
||||
def __init__(self, configuration_file):
|
||||
self.config = ConfigParser.ConfigParser(allow_no_value=True)
|
||||
self.config.read(configuration_file)
|
||||
|
||||
|
||||
def get_drivers(self):
|
||||
drivers = self.config.sections()
|
||||
drivers.remove("alexandria")
|
||||
return drivers
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return self.config.sections()
|
||||
|
||||
|
||||
def get_driver_info(self,driver):
|
||||
return self.config.options(driver)
|
||||
|
||||
|
||||
def get_alexandria_port(self):
|
||||
return self.config.get("alexandria", "port")
|
||||
|
|
@ -3,37 +3,37 @@
|
|||
import types
|
||||
|
||||
class Driver(object):
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.driver_type = self.__class__.__name__
|
||||
# Get credentials from conf files for CMDB
|
||||
# Get credentials from conf files for CMDB
|
||||
pass
|
||||
|
||||
|
||||
def get_driver_type(self):
|
||||
return self.driver_type
|
||||
|
||||
|
||||
def get_ci(self):
|
||||
pass
|
||||
|
||||
|
||||
def push_ci(self):
|
||||
pass
|
||||
|
||||
|
||||
class Itop(Driver):
|
||||
|
||||
|
||||
def get_ci(self):
|
||||
print "Get from itop"
|
||||
return True
|
||||
|
||||
|
||||
def push_ci(self):
|
||||
pass
|
||||
|
||||
class Redfish(Driver):
|
||||
|
||||
|
||||
def get_ci(self):
|
||||
print "Get from redfish"
|
||||
return True
|
||||
|
||||
|
||||
pass
|
||||
|
||||
class Ironic(Driver):
|
||||
|
@ -51,5 +51,3 @@ class Fakeprovider(Driver):
|
|||
|
||||
class DriverCollection(list):
|
||||
pass
|
||||
|
||||
|
|
@ -5,33 +5,31 @@ import glob
|
|||
import os
|
||||
import re
|
||||
|
||||
|
||||
class Model(object):
|
||||
"""Implements Alexandria reference model."""
|
||||
def __init__(self):
|
||||
|
||||
|
||||
self.reference_items = []
|
||||
|
||||
|
||||
self.read_ref_files()
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def read_ref_files(self):
|
||||
cwd = os.getcwd()
|
||||
model_files = glob.glob(cwd + "/model/redfish/*.json") # hierarchy model/std/*.json
|
||||
|
||||
# Hierarchy model/std/*.json
|
||||
model_files = glob.glob(cwd + "/model/redfish/*.json")
|
||||
for file in model_files:
|
||||
# Derive attribute name from file.
|
||||
attr_name = os.path.basename(file)
|
||||
attr_name = re.sub(r"\..*$", "", attr_name)
|
||||
|
||||
|
||||
# read json file
|
||||
with open(file) as json_data:
|
||||
data_structure = json.load(json_data)
|
||||
json_data.close()
|
||||
|
||||
|
||||
# Create an class attribute for that structure
|
||||
setattr(self, attr_name, data_structure)
|
||||
self.reference_items.append(attr_name)
|
||||
return True
|
||||
|
||||
|
Loading…
Reference in New Issue