Exemplo n.º 1
0
 def internal_load_template():
     local_path = template.local_path
     if local_path is not None and isfile(local_path):
         with open(local_path) as template_file:
             return TemplateContent.from_dict(json.load(template_file))
     else:
         try:
             req = requests.get(template.url)
             return TemplateContent.from_dict(json.loads(req.content))
         except Exception as e:
             self.log.warn("Fail to load template from remote file %s" % template.url)
             self.log.error(e)
             return None
Exemplo n.º 2
0
 def internal_load_template():
     local_path = template.local_path
     if local_path is not None and isfile(local_path):
         with open(local_path) as template_file:
             return TemplateContent.from_dict(json.load(template_file))
     else:
         try:
             req = requests.get(template.url)
             return TemplateContent.from_dict(json.loads(req.content))
         except Exception as e:
             self.log.warn("Fail to load template from remote file %s" %
                           template.url)
             self.log.error(e)
             return None
Exemplo n.º 3
0
    def __load_template_content(self, args):
        """ Convert dict of template content into TemplateContent object

        :type args: dict
        :param args: args to create a template

        :rtype: TemplateContent
        :return: instance of TemplateContent
        """
        self.__validate_template_content(args)
        return TemplateContent.from_dict(args)
Exemplo n.º 4
0
    def __load_template_content(self, args):
        """ Convert dict of template content into TemplateContent object

        :type args: dict
        :param args: args to create a template

        :rtype: TemplateContent
        :return: instance of TemplateContent
        """
        self.__validate_template_content(args)
        return TemplateContent.from_dict(args)
Exemplo n.º 5
0
        def internal_load_template():
            # todo local cache not valid, disabled temprary
            # local_path = template.local_path
            # if local_path is not None and isfile(local_path):
            #     with open(local_path) as template_file:
            #         return TemplateContent.from_dict(json.load(template_file))
            # else:

            try:
                # req = requests.get(template.url)
                return TemplateContent.from_dict(
                    self.util.get_config("ukylin.k8s.template"))
            except Exception as e:
                self.log.warn("Fail to load template from remote file %s" %
                              template.url)
                self.log.error(e)
                return None