def json_download_all_files(self, HTTP_object, feedparser_STM,
                             object_list):
     """
     downloads all the available json files for Short term metrics
     Args:
         HTTP_object : HTTP Request object carrying the headers and URL
         feedparser_STM : feedparser object containing the entries of STM
         object_list : Available VIOS object List
     """
     try:
         print("press ctrl+c to exit")
         for i in range(0, len(feedparser_STM.entries)):
             json_url = feedparser_STM.entries[i].links[0].href
             # Get the links for short term monitor json files and perform get request
             HTTP_object.HTTPGet(url=json_url)
             log_object.log_debug(
                 "response code for Short Term Monitor json file links %s" %
                 (HTTP_object.response))
             if not HTTP_object.response_b:
                 continue
             # Downloading the json file
             JsonFilesDownload.json_file(feedparser_STM.entries[i].title,
                                         HTTP_object.response.text)
     except KeyboardInterrupt:
         return 5
    def json_download_recent_files_phyp(self, HTTP_object, feedparser_STM,
                                        object_list):
        """
        downloads the recent json files for Short term metrics PHYP
        Args:
            HTTP_object : HTTP Request object carrying the headers and URL
            feedparser_STM : feedparser object containing the entries of STM
            object_list : Available VIOS object List
        """

        timestamp_phyp = []
        # get timestamps of all the json files of category phyp
        for j in range(0, len(feedparser_STM.entries)):
            if feedparser_STM.entries[j].category == "phyp":
                timestamp_phyp.append(
                    feedparser_STM.entries[j].links[0].href[154:160])
                timestamp_phyp.sort()
        for k in range(0, len(feedparser_STM.entries)):
            if (feedparser_STM.entries[k].category == "phyp"
                    and feedparser_STM.entries[k].links[0].href[154:160]
                    == timestamp_phyp[len(timestamp_phyp) - 1]):
                #print (CreateFromDocument.entries[i].links[0].href)
                HTTP_object.HTTPGet(
                    url=feedparser_STM.entries[k].links[0].href)
                log_object.log_debug(HTTP_object.response)
                print("\nThe recent json file of PowerHypervisor :")
                JsonFilesDownload.json_file(feedparser_STM.entries[k].title,
                                            HTTP_object.response.text)
                break
    def json_download_logicalpartitions(self, HTTP_object,
                                        feedparser_processed_metrics):
        """
        downloads the json files for the LogicalPartition
        Args:
          HTTP_object : HTTP Request object carrying the headers and URL
          feedparser_processed_metrics : Feedparser object containing the processed metrics entries
        """

        for k in range(0, len(feedparser_processed_metrics.entries)):
            if feedparser_processed_metrics.entries[
                    k].category == "LogicalPartition":
                json_url_lpar = feedparser_processed_metrics.entries[k].links[
                    0].href
                HTTP_object.HTTPGet(url=json_url_lpar)
                log_object.log_debug("into lpar/uuid/processedmetrics %s" %
                                     (HTTP_object.response))
                feedparser_processed_metrics_lpar = feedparser.parse(
                    HTTP_object.response.text)
                for j in range(0,
                               len(feedparser_processed_metrics_lpar.entries)):
                    json_url_lpar_jsonlink = feedparser_processed_metrics_lpar.entries[
                        j].links[0].href
                    HTTP_object.HTTPGet(url=json_url_lpar_jsonlink)
                    log_object.log_debug(
                        "into lpar/uuid/processedmetrics/jsonfile %s" %
                        (HTTP_object.response))
                    if not HTTP_object.response_b:
                        continue
                    print("\nLogicalPartition json file:")
                    JsonFilesDownload.json_file(
                        feedparser_processed_metrics_lpar.entries[j].title,
                        HTTP_object.response.text)
Exemple #4
0
 def json_download_recent_files_vios(self,HTTP_object,feedparser_LTM,object_list):
     """
     downloads  the recent json files for Long term metrics VIOS
     Args:
         HTTP_object : HTTP Request object carrying the headers and URL
         feedparser_LTM : feedparser object containing the entries of LTM
         object_list : Available VIOS object List
     """
     try:
         timestamp_vios=[]
         vios_names=self.get_virtualioserver_list(object_list)
         #print(object_list)
         for k in range(0,len(vios_names)):
             #print(vios_names[k])
             timestamp_vios.append([])
         for j in range(0,len(vios_names)):
             for i in range(0, len(feedparser_LTM.entries)):
                 if feedparser_LTM.entries[i].category==vios_names[j]:
                     timestamp_vios[j].append(feedparser_LTM.entries[i].links[0].href[156:162])
                     timestamp_vios[j].sort()
         for j in range(0,len(vios_names)):
             for i in range(0, len(feedparser_LTM.entries)):
                 if feedparser_LTM.entries[i].category==vios_names[j] and feedparser_LTM.entries[i].links[0].href[156:162]==timestamp_vios[j][len(timestamp_vios[j])-1]:
                     #print (feedparser_LTM.entries[i].links[0].href)
                     json_url=feedparser_LTM.entries[i].links[0].href
                     HTTP_object.HTTPGet(url=json_url)
                     log_object.log_debug(HTTP_object.response)
                     print("\nThe recent json file of VirtualIOserver :%s "%(vios_names[j]))
                     JsonFilesDownload.json_file(feedparser_LTM.entries[i].title, HTTP_object.response.text)
                     break
     except TypeError:
         log_object.log_warn("There are no VIOS available in the system")
    def json_download_managedsystem(self, HTTP_object, feedparser_processed_metrics):
        """
        downloads the json files for the managed system
        Args:
          HTTP_object : HTTP Request object carrying the headers and URL
          feedparser_processed_metrics : Feedparser object containing the processed metrics entries
        """

        for i in range(0,len(feedparser_processed_metrics.entries)):
            if feedparser_processed_metrics.entries[i].category=="ManagedSystem":
                json_url_managedsystem=feedparser_processed_metrics.entries[i].links[0].href
                HTTP_object.HTTPGet(url = json_url_managedsystem)
                log_object.log_debug(HTTP_object.response)
                if not HTTP_object.response_b :
                    continue
                print("\nManagedSystem json file:")
                JsonFilesDownload.json_file(feedparser_processed_metrics.entries[i].title, HTTP_object.response.text)
 def json_download_all_files(self, HTTP_object, feedparser_LTM, object_list):
     """
     downloads all the available json files for Long term metrics
     Args:
         HTTP_object : HTTP Request object carrying the headers and URL
         feedparser_LTM : feedparser object containing the entries of LTM
         object_list : Available VIOS object List
     """
     try:
         print("press ctrl+c to exit")
         for i in range(0,len(feedparser_LTM.entries)):
             json_url_link=feedparser_LTM.entries[i].links[0].href
             # Get the links for long term monitor json files and perform get request
             HTTP_object.HTTPGet(url=json_url_link)
             log_object.log_debug("response code for Long Term Monitor json file links %s" %(HTTP_object.response))
             if not HTTP_object.response_b:
                 continue
             # Downloading the json file
             JsonFilesDownload.json_file(feedparser_LTM.entries[i].title, HTTP_object.response.text)
     except KeyboardInterrupt:
         return 5
    def json_download_managedsystem(self, HTTP_object,
                                    feedparser_processed_metrics):
        """
        downloads the json files for the managed system
        Args:
          HTTP_object : HTTP Request object carrying the headers and URL
          feedparser_processed_metrics : Feedparser object containing the processed metrics entries
        """

        for i in range(0, len(feedparser_processed_metrics.entries)):
            if feedparser_processed_metrics.entries[
                    i].category == "ManagedSystem":
                json_url_managedsystem = feedparser_processed_metrics.entries[
                    i].links[0].href
                HTTP_object.HTTPGet(url=json_url_managedsystem)
                log_object.log_debug(HTTP_object.response)
                if not HTTP_object.response_b:
                    continue
                print("\nManagedSystem json file:")
                JsonFilesDownload.json_file(
                    feedparser_processed_metrics.entries[i].title,
                    HTTP_object.response.text)
    def json_download_logicalpartitions(self, HTTP_object, feedparser_processed_metrics):
        """
        downloads the json files for the LogicalPartition
        Args:
          HTTP_object : HTTP Request object carrying the headers and URL
          feedparser_processed_metrics : Feedparser object containing the processed metrics entries
        """


        for k in range(0,len(feedparser_processed_metrics.entries)):
            if feedparser_processed_metrics.entries[k].category=="LogicalPartition" :
                json_url_lpar = feedparser_processed_metrics.entries[k].links[0].href
                HTTP_object.HTTPGet(url=json_url_lpar)
                log_object.log_debug("into lpar/uuid/processedmetrics %s"%(HTTP_object.response))
                feedparser_processed_metrics_lpar=feedparser.parse(HTTP_object.response.text)
                for j in range(0,len(feedparser_processed_metrics_lpar.entries)):
                    json_url_lpar_jsonlink= feedparser_processed_metrics_lpar.entries[j].links[0].href
                    HTTP_object.HTTPGet(url=json_url_lpar_jsonlink)
                    log_object.log_debug("into lpar/uuid/processedmetrics/jsonfile %s"%(HTTP_object.response))
                    if not HTTP_object.response_b :
                        continue
                    print("\nLogicalPartition json file:")
                    JsonFilesDownload.json_file(feedparser_processed_metrics_lpar.entries[j].title, HTTP_object.response.text)
 def json_download_recent_files_phyp(self, HTTP_object, feedparser_STM, object_list):
     """
     downloads the recent json files for Short term metrics PHYP
     Args:
         HTTP_object : HTTP Request object carrying the headers and URL
         feedparser_STM : feedparser object containing the entries of STM
         object_list : Available VIOS object List
     """
 
     timestamp_phyp=[]
     # get timestamps of all the json files of category phyp
     for j in range(0, len(feedparser_STM.entries)):
         if feedparser_STM.entries[j].category=="phyp":
             timestamp_phyp.append(feedparser_STM.entries[j].links[0].href[154:160])
             timestamp_phyp.sort()
     for k in range(0, len(feedparser_STM.entries)):
         if(feedparser_STM.entries[k].category=="phyp" and feedparser_STM.entries[k].links[0].href[154:160]==timestamp_phyp[len(timestamp_phyp)-1]):
             #print (CreateFromDocument.entries[i].links[0].href)
             HTTP_object.HTTPGet(url=feedparser_STM.entries[k].links[0].href)
             log_object.log_debug(HTTP_object.response)
             print("\nThe recent json file of PowerHypervisor :")
             JsonFilesDownload.json_file(feedparser_STM.entries[k].title, HTTP_object.response.text)
             break