# Path: src/common/ListModule.py
# class ListModule:
#     """
#     called in Listing operation to get the object list
#     of ManagementConsole,ManagedSystem,LogicalPartition,
#     LogicalPartitionProfile,VirtualIOServer and other objects.   
#     """
#     log_object = HMCClientLogger.HMCClientLogger(__name__)
#     
#     def listing(self, service, ip, root, content_type, Resource, session_id, uuid=None):
#         
#          """
#          Makes an HTTPRequest to get the details of the
#          corresponding object and store the response content
#          into a python object.
#          Args:
#              service:uom or web
#              ip:ip address of the hmc
#              root:root element in rest uri
#              content_type:type of object to be extracted
#                           (logicalpartition,logicalpartitionprofile,
#                            ManagedSystem,VirtualIOServer and other objects)
#              session_id:to access the session
#              uuid:root unique id
#          Returns:
#              list of corresponding objects
#          """
#          #for ManagementConsole the uuid is none and for other types the uri is appended with roots uuid
#          obj_list = []
#          xml_object = None
#          headers_obj = HmcHeaders.HmcHeaders(service)
#          ns = headers_obj.ns
#          request_obj = HTTPClient.HTTPClient(service, ip, root, content_type, session_id)
#          if uuid == None:
#              request_obj.HTTPGet()
#          else:
#              request_obj.HTTPGet(append=str(uuid)+"/"+Resource)
#          if request_obj.response_b:
#              root = etree.fromstring(request_obj.response.text)
#              entries = root.findall(".//%s:%s"%(Resource,Resource),
#                                  namespaces={"%s" %(Resource): ns["xmlns"]})
#              for entry in entries:
#                  if entry.getchildren() != []:
#                      xmlstring = etree.tostring(entry)
#                      xml_object = UOM.CreateFromDocument(xmlstring)
#                      obj_list.append(xml_object)
#              return obj_list
# 
# Path: src/utility/HMCClientLogger.py
# class HMCClientLogger:
#                 def __init__(self,module_name):
#                                 self.logger_module = logging.getLogger(module_name)
#                                 self.logger_module.setLevel(logging.DEBUG)
#                                 
# # create file handler which logs even debug messages
#                                 if not os.path.exists("output/Log"):
#                                     os.makedirs("output/Log")
#                                 filehandler = logging.FileHandler('output/Log/Debug.log')
#                                 filehandler.setLevel(logging.DEBUG)
#                                 consolehandler=logging.StreamHandler()
#                                 consolehandler.setLevel(logging.WARNING)
# # create formatter and add it to the handlers
#                                 fileformatter = logging.Formatter('%(asctime)s - %(levelname)s - %(name)s -  %(message)s',datefmt='%m/%d/%Y %I:%M:%S %p')
#                                 consoleformatter = logging.Formatter(' %(levelname)s : %(message)s')
#                                 filehandler.setFormatter(fileformatter)
#                                 consolehandler.setFormatter(consoleformatter)
# # add the handlers to logger
#                                 self.logger_module.addHandler(filehandler)
#                                 self.logger_module.addHandler(consolehandler)
#                                 
#                 def log_debug(self,message):
#                                 self.logger_module.debug(message)
#                 def log_info(self,message):
#                                 self.logger_module.info(message)
#                 def log_error(self,message):
#                                 self.logger_module.error(message)
#                 def log_warn(self,message):
#                                 self.logger_module.warn(message)


from src.common import ListModule
from src.utility import HMCClientLogger
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

log = HMCClientLogger.HMCClientLogger(__name__)

ROOT = "Cluster"
CONTENT_TYPE = "application/atom+xml, application/vnd.ibm.powervm.uom+xml;type=SharedStoragePool"

class ListSharedStoragePool:
    """
    Lists the details of SharedStoragePool
    """
    
    def __init__(self):
        """
        initializes root and content-type
        """
        self.root = ROOT
        self.content_type = CONTENT_TYPE

    def list_shared_storagepool(self, ip, cluster_id, x_api_session):
        """
        returns a  shared storage pool object of a given cluster
        Args:
           ip : ip address of HMC
           cluster_id : the UUID Of the Cluster to get ssp
           x_api_session : session to be used
        """
        log.log_debug("ssp object of a cluster is started")

# Path: src/common/ListModule.py
# class ListModule:
#     """
#     called in Listing operation to get the object list
#     of ManagementConsole,ManagedSystem,LogicalPartition,
#     LogicalPartitionProfile,VirtualIOServer and other objects.   
#     """
#     log_object = HMCClientLogger.HMCClientLogger(__name__)
#     
#     def listing(self, service, ip, root, content_type, Resource, session_id, uuid=None):
#         
#          """
#          Makes an HTTPRequest to get the details of the
#          corresponding object and store the response content
#          into a python object.
#          Args:
#              service:uom or web
#              ip:ip address of the hmc
#              root:root element in rest uri
#              content_type:type of object to be extracted
#                           (logicalpartition,logicalpartitionprofile,
#                            ManagedSystem,VirtualIOServer and other objects)
#              session_id:to access the session
#              uuid:root unique id
#          Returns:
#              list of corresponding objects
#          """
#          #for ManagementConsole the uuid is none and for other types the uri is appended with roots uuid
#          obj_list = []
#          xml_object = None
#          headers_obj = HmcHeaders.HmcHeaders(service)
#          ns = headers_obj.ns
#          request_obj = HTTPClient.HTTPClient(service, ip, root, content_type, session_id)
#          if uuid == None:
#              request_obj.HTTPGet()
#          else:
#              request_obj.HTTPGet(append=str(uuid)+"/"+Resource)
#          if request_obj.response_b:
#              root = etree.fromstring(request_obj.response.text)
#              entries = root.findall(".//%s:%s"%(Resource,Resource),
#                                  namespaces={"%s" %(Resource): ns["xmlns"]})
#              for entry in entries:
#                  if entry.getchildren() != []:
#                      xmlstring = etree.tostring(entry)
#                      xml_object = UOM.CreateFromDocument(xmlstring)
#                      obj_list.append(xml_object)
#              return obj_list
# 
# Path: src/utility/HMCClientLogger.py
# class HMCClientLogger:
#                 def __init__(self,module_name):
#                                 self.logger_module = logging.getLogger(module_name)
#                                 self.logger_module.setLevel(logging.DEBUG)
#                                 
# # create file handler which logs even debug messages
#                                 if not os.path.exists("output/Log"):
#                                     os.makedirs("output/Log")
#                                 filehandler = logging.FileHandler('output/Log/Debug.log')
#                                 filehandler.setLevel(logging.DEBUG)
#                                 consolehandler=logging.StreamHandler()
#                                 consolehandler.setLevel(logging.WARNING)
# # create formatter and add it to the handlers
#                                 fileformatter = logging.Formatter('%(asctime)s - %(levelname)s - %(name)s -  %(message)s',datefmt='%m/%d/%Y %I:%M:%S %p')
#                                 consoleformatter = logging.Formatter(' %(levelname)s : %(message)s')
#                                 filehandler.setFormatter(fileformatter)
#                                 consolehandler.setFormatter(consoleformatter)
# # add the handlers to logger
#                                 self.logger_module.addHandler(filehandler)
#                                 self.logger_module.addHandler(consolehandler)
#                                 
#                 def log_debug(self,message):
#                                 self.logger_module.debug(message)
#                 def log_info(self,message):
#                                 self.logger_module.info(message)
#                 def log_error(self,message):
#                                 self.logger_module.error(message)
#                 def log_warn(self,message):
#                                 self.logger_module.warn(message)


# Path: src/shared_storage_pool/ListSharedStoragePool.py
from src.common import ListModule
from src.utility import HMCClientLogger

#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

log = HMCClientLogger.HMCClientLogger(__name__)

ROOT = "Cluster"
CONTENT_TYPE = "application/atom+xml, application/vnd.ibm.powervm.uom+xml;type=SharedStoragePool"

class ListSharedStoragePool:
    """
    Lists the details of SharedStoragePool
    """
    
    def __init__(self):
        """
        initializes root and content-type
        """
        self.root = ROOT
        self.content_type = CONTENT_TYPE

    def list_shared_storagepool(self, ip, cluster_id, x_api_session):
        """
        returns a  shared storage pool object of a given cluster
        Args:
           ip : ip address of HMC
           cluster_id : the UUID Of the Cluster to get ssp
           x_api_session : session to be used
        """
        log.log_debug("ssp object of a cluster is started")

        list_object = ListModule.ListModule()