Пример #1
0
 def setUp(self):
     logging.basicConfig(
         level=logging.NOTSET,
         format=
         '%(asctime)s %(levelname)s %(name)s pid(%(process)d) Message: %(message)s',
         filename='/tmp/imagefactory-unittests.log')
     self.warehouse = ImageWarehouse(
         ApplicationConfiguration().configuration["warehouse"])
     self.metadata = dict(key1="value1", key2="value2", key3="value3")
Пример #2
0
 def setUp(self):
     logging.basicConfig(
         level=logging.NOTSET,
         format=
         '%(asctime)s %(levelname)s %(name)s pid(%(process)d) Message: %(message)s',
         filename='/tmp/imagefactory-unittests.log')
     self.warehouse = ImageWarehouse(
         ApplicationConfiguration().configuration["warehouse"])
     self.template_xml = "<template>This is a test template.  There is not much to it.</template>"
Пример #3
0
    def __init__(self, template=None, uuid=None, url=None, xml=None):
        self.log = logging.getLogger('%s.%s' % (__name__, self.__class__.__name__))
        self.warehouse = ImageWarehouse(ApplicationConfiguration().configuration["warehouse"])

        self.identifier = None
        self.url = None
        self.xml = None

        path = None
        if(template):
            template_string = str(template)
            template_string_type = self.__template_string_type(template_string)
            if(template_string_type == "UUID"):
                uuid = template_string
            elif(template_string_type == "URL"):
                url = template_string
            elif(template_string_type == "XML"):
                xml = template_string
            elif(template_string_type == "PATH"):
                path = template_string

        if(uuid):
            uuid_string = uuid
            self.identifier, self.xml = self.__fetch_template_for_uuid(uuid_string)
            if((not self.identifier) and (not self.xml)):
                raise RuntimeError("Could not create a template with the uuid %s" % (uuid, ))
        elif(url):
            self.url = url
            self.identifier, self.xml = self.__fetch_template_with_url(url)
        elif(xml):
            self.xml = xml
        elif(path):
            template_file = open(path, "r")
            file_content = template_file.read()
            template_file.close()
            if(self.__string_is_xml_template(file_content)):
                self.xml = file_content
            else:
                raise ValueError("File %s does not contain properly formatted template xml:\n%s" % (path, self.__abbreviated_template(file_content)))
        else:
            raise ValueError("'template' must be a UUID, URL, XML string or XML document path...")
Пример #4
0
 def _singleton_init(self):
     self.warehouse = ImageWarehouse(
         ApplicationConfiguration().configuration['warehouse'])
Пример #5
0
 def _singleton_init(self):
     super(ImageFactory, self)._singleton_init()
     self.log = logging.getLogger('%s.%s' % (__name__, self.__class__.__name__))
     self.qmf_object = Data(ImageFactory.qmf_schema)
     self.warehouse = ImageWarehouse(ApplicationConfiguration().configuration["warehouse"])