Example #1
0
 def build_image(self, b_dir, config):
     log.info('building image...')
     docker = Docker.client
     template = '{}_{}_d{}'.format(
         self.application.name, config, self.deployment.id)
     new_image = docker.build(b_dir, template)[0]
     log.info('image built {}'.format(new_image))
     registry_image = '{}/{}'.format(CONFIG.get('base', 'docker-registry'), template)
     docker.tag(new_image, registry_image)
     log.info('pushing to registry {}'.format(registry_image))
     docker.push(registry_image)
     log.debug('finished')
     self.deployment.image = template
Example #2
0
    def build_templates(self, configuration):
        b_dir = tempfile.mkdtemp()
        dockerfile = os.path.join(CONFIG.get('base', 'templates'), 'dockerfile')
        runapp = os.path.join(CONFIG.get('base', 'templates'), 'runapp_{}.sh'.format('python26'))
        setupapp = os.path.join(CONFIG.get('base', 'templates'), 'setup_{}.sh'.format('python26'))
        log.debug('generating templates')
        params = self.params.copy()
        params['command'] = self.configurations[configuration]

        shutil.move(self.params['packed_env'], os.path.join(b_dir, 'env.tgz'))
        params['packed_env'] = 'env.tgz'

        dockerfile_content = file(dockerfile).read().format(**params)
        runapp_content = file(runapp).read().format(**params)
        setupapp_content = file(setupapp).read().format(**params)
        with file(os.path.join(b_dir, 'Dockerfile'), 'w') as f:
            f.write(dockerfile_content)
        with file(os.path.join(b_dir, 'runapp.sh'), 'w') as f:
            f.write(runapp_content)
        with file(os.path.join(b_dir, 'setupapp.sh'), 'w') as f:
            f.write(setupapp_content)
        log.debug('template directory complete {}'.format(b_dir))
        return b_dir
Example #3
0
 def connect():
     Keystone._client = ksclient.Client(auth_url=CONFIG.get('keystone', 'auth_url'),
                                        username=CONFIG.get('keystone', 'username'),
                                        password=CONFIG.get('keystone', 'password'),
                                        tenant_name=CONFIG.get('keystone', 'tenant'))
Example #4
0
    def connect():
        keystone = Keystone.client

        Heat._client = Client('1', endpoint="{}/{}".format(CONFIG.get('base', 'heat_endpoint'),
                                                           keystone.tenant_id),
                              token=keystone.auth_token)
Example #5
0
 def connect():
     keystone = Keystone.client
     Neutron._client = client.Client('2.0', endpoint_url=CONFIG.get('base', 'neutron_endpoint'),
                                     token=keystone.auth_token)