Exemplo n.º 1
0
 def _load_template(self, image_id, build_id, template):
     if not template:
         if build_id:
             template = self._template_for_build_id(build_id)
         if not template and image_id:
             template = self._template_for_image_id(image_id)
     return Template(template)
Exemplo n.º 2
0
 def testTemplateFromURL(self):
     template_id = self.warehouse.store_template(self.template_xml)
     template_url = "%s/%s/%s" % (
         self.warehouse.url, self.warehouse.template_bucket, template_id)
     template = Template(template_url)
     self.assertEqual(template_url, template.url)
     self.assertEqual(template_id, template.identifier)
     self.assertEqual(self.template_xml, template.xml)
Exemplo n.º 3
0
 def testTemplateFramImageID(self):
     template_id = self.warehouse.store_template(self.template_xml)
     template = Template(template_id)
     target = "mock"
     builder = MockBuilder(self.template_xml, target)
     builder.build_image()
     metadata = dict(template=template_id,
                     target=target,
                     icicle="None",
                     target_parameters="None")
     self.warehouse.store_target_image(builder.new_image_id,
                                       builder.image,
                                       metadata=metadata)
     image_template = Template(builder.new_image_id)
     self.assertEqual(template_id, image_template.identifier)
     self.assertEqual(self.template_xml, image_template.xml)
     self.assertIsNone(template.url)
Exemplo n.º 4
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.template = Template("<template></template>")
     self.target = "mock"
     self.builder = MockBuilder(self.template, self.target)
Exemplo n.º 5
0
    def testTemplateFromPath(self):
        (fd, template_path) = tempfile.mkstemp(prefix="test_image_factory-")
        os.write(fd, self.template_xml)
        os.close(fd)

        template = Template(template_path)
        self.assertIsNone(template.url)
        self.assertIsNone(template.identifier)
        self.assertEqual(self.template_xml, template.xml)

        os.remove(template_path)
Exemplo n.º 6
0
    def provider_image(self, image_id, provider, credentials):
        target_image_id = image_id

        image_metadata = self.warehouse.metadata_for_id_of_type(("template", "target"), target_image_id, "target_image")
        template_id = image_metadata["template"]
        target = image_metadata["target"]

        if (template_id and target):
            build_adaptor = BuildAdaptor(Template(uuid=template_id),target,agent=self.agent)
            build_adaptor.push_image(target_image_id, provider, credentials)
            return build_adaptor
        else:
            raise RuntimeError("Could not return build_adaptor!\nimage_metadata: %s\ntemplate_id: %s\ntemplate: %s\n" % (image_metadata, template_id, target))
Exemplo n.º 7
0
    def __init__(self, template, target, image_id='', build_id=''):
        super(BuildJob, self).__init__()

        self.log = logging.getLogger('%s.%s' %
                                     (__name__, self.__class__.__name__))

        self.template = template if isinstance(
            template, Template) else Template(template)
        self.target = target
        self.image_id = image_id
        self.build_id = build_id
        self.provider = None
        self.status = "New"
        self.percent_complete = 0
        self._watcher = None

        self._builder = self._get_builder()
        self._builder.delegate = self

        self.new_image_id = self._builder.new_image_id
Exemplo n.º 8
0
 def testTemplateStringRepresentation(self):
     template = Template(self.template_xml)
     self.assertEqual(self.template_xml, repr(template))
     self.assertEqual(self.template_xml, str(template))
     self.assertEqual(self.template_xml, "%r" % (template, ))
     self.assertEqual(self.template_xml, "%s" % (template, ))
Exemplo n.º 9
0
 def testTemplateFromXML(self):
     template = Template(self.template_xml)
     self.assertEqual(self.template_xml, template.xml)
     self.assertIsNone(template.identifier)
     self.assertIsNone(template.url)
Exemplo n.º 10
0
 def testTemplateFromUUID(self):
     template_id = self.warehouse.store_template(self.template_xml)
     template = Template(template_id)
     self.assertEqual(template_id, template.identifier)
     self.assertEqual(self.template_xml, template.xml)
     self.assertIsNone(template.url)
Exemplo n.º 11
0
 def image(self,template,target):
     template_object = Template(template=template)
     build_adaptor = BuildAdaptor(template_object,target,agent=self.agent)
     build_adaptor.build_image()
     return build_adaptor