Ejemplo n.º 1
0
def action_loadfakedeploymenttasks(params):
    from nailgun.db.sqlalchemy import fixman
    from nailgun.logger import logger

    logger.info("Applying fake deployment tasks to all releases...")
    fixman.load_fake_deployment_tasks()
    logger.info("Done")
Ejemplo n.º 2
0
def action_loadfakedeploymenttasks(params):
    from nailgun.db.sqlalchemy import fixman
    from nailgun.logger import logger

    logger.info("Applying fake deployment tasks to all releases...")
    fixman.load_fake_deployment_tasks()
    logger.info("Done")
Ejemplo n.º 3
0
    def test_load_fake_deployment_tasks(self):
        fxtr_path = os.path.join(fixman.get_base_fixtures_path(),
                                 'deployment_tasks.yaml')
        with open(fxtr_path) as f:
            deployment_tasks = yaml.load(f)

        fixman.load_fake_deployment_tasks()

        for rel in self.db.query(Release).all():
            self.assertEqual(rel.deployment_tasks, deployment_tasks)
Ejemplo n.º 4
0
    def test_load_fake_deployment_tasks(self):
        fxtr_path = os.path.join(fixman.get_base_fixtures_path(),
                                 'deployment_tasks.yaml')
        with open(fxtr_path) as f:
            deployment_tasks = yaml.load(f)

        fixman.load_fake_deployment_tasks()

        for rel in self.db.query(Release).all():
            self.assertEqual(rel.deployment_tasks, deployment_tasks)
Ejemplo n.º 5
0
    def test_load_fake_deployment_tasks(self):
        self.env.upload_fixtures(["openstack"])
        fxtr_path = os.path.join(fixman.get_base_fixtures_path(),
                                 'deployment_tasks.yaml')
        with open(fxtr_path) as f:
            deployment_tasks = yaml.load(f)

        fixman.load_fake_deployment_tasks()
        for rel in self.db.query(Release).all():
            deployment_graph = objects.DeploymentGraph.get_for_model(rel)
            db_deployment_tasks = objects.DeploymentGraph.get_tasks(
                deployment_graph)
            self._compare_tasks(deployment_tasks, db_deployment_tasks)
Ejemplo n.º 6
0
    def test_load_fake_deployment_tasks(self):
        self.env.upload_fixtures(["openstack"])
        fxtr_path = os.path.join(fixman.get_base_fixtures_path(),
                                 'deployment_tasks.yaml')
        with open(fxtr_path) as f:
            deployment_tasks = yaml.load(f)

        fixman.load_fake_deployment_tasks()
        for rel in self.db.query(Release).all():
            deployment_graph = objects.DeploymentGraph.get_for_model(rel)
            db_deployment_tasks = objects.DeploymentGraph.get_tasks(
                deployment_graph)
            self._compare_tasks(deployment_tasks, db_deployment_tasks)
Ejemplo n.º 7
0
    def create_release(self, api=False, **kwargs):
        os = kwargs.get("operating_system", consts.RELEASE_OS.centos)
        version = kwargs.get("version", "{0}-6.1".format(randint(0, 100000000)))

        # NOTE(ikalnitsky): In order to do not read each time openstack.yaml
        # we're reading it once and then look for needed release.
        releases = self.read_fixtures(("openstack",))
        release_data = next((r for r in releases if r["fields"]["operating_system"] == os), releases[0])
        release_data = release_data["fields"]

        release_data.update(
            {
                "name": u"release_name_" + version,
                "version": version,
                "description": u"release_desc" + version,
                "modes": ["ha_compact", "multinode"],
            }
        )

        if kwargs.get("deployment_tasks") is None:
            kwargs["deployment_tasks"] = load_fake_deployment_tasks(apply_to_db=False)

        release_data.update(kwargs)
        if api:
            resp = self.app.post(
                reverse("ReleaseCollectionHandler"), params=jsonutils.dumps(release_data), headers=self.default_headers
            )
            self.tester.assertEqual(resp.status_code, 201)
            release = resp.json_body
            self.releases.append(self.db.query(Release).get(release["id"]))
        else:
            release = Release.create(release_data)
            db().commit()
            self.releases.append(release)
        return release
Ejemplo n.º 8
0
    def create_release(self, api=False, **kwargs):
        os = kwargs.get(
            'operating_system', consts.RELEASE_OS.centos)
        version = kwargs.get(
            'version', '{0}-6.1'.format(randint(0, 100000000)))

        # NOTE(ikalnitsky): In order to do not read each time openstack.yaml
        # we're reading it once and then look for needed release.
        releases = self.read_fixtures(('openstack',))
        release_data = next((
            r for r in releases if r['fields']['operating_system'] == os),
            releases[0])
        release_data = release_data['fields']

        release_data.update({
            'name': u"release_name_" + version,
            'version': version,
            'description': u"release_desc" + version,
            'roles': self.get_default_roles(),
            'modes': ['ha_compact', 'multinode'],
        })

        if kwargs.get('deployment_tasks') is None:
            kwargs['deployment_tasks'] = \
                load_fake_deployment_tasks(apply_to_db=False)

        release_data.update(kwargs)
        if api:
            resp = self.app.post(
                reverse('ReleaseCollectionHandler'),
                params=jsonutils.dumps(release_data),
                headers=self.default_headers
            )
            self.tester.assertEqual(resp.status_code, 201)
            release = resp.json_body
            self.releases.append(
                self.db.query(Release).get(release['id'])
            )
        else:
            release = Release.create(release_data)
            db().commit()
            self.releases.append(release)
        return release
Ejemplo n.º 9
0
    def create_release(self, api=False, **kwargs):
        os = kwargs.get('operating_system', consts.RELEASE_OS.centos)
        version = kwargs.get('version', '{0}-6.1'.format(randint(0,
                                                                 100000000)))

        # NOTE(ikalnitsky): In order to do not read each time openstack.yaml
        # we're reading it once and then look for needed release.
        releases = self.read_fixtures(('openstack', ))
        release_data = next(
            (r for r in releases if r['fields']['operating_system'] == os),
            releases[0])
        release_data = release_data['fields']

        release_data.update({
            'name': u"release_name_" + version,
            'version': version,
            'description': u"release_desc" + version,
            'roles': self.get_default_roles(),
            'modes': ['ha_compact', 'multinode'],
        })

        if kwargs.get('deployment_tasks') is None:
            kwargs['deployment_tasks'] = \
                load_fake_deployment_tasks(apply_to_db=False)

        release_data.update(kwargs)
        if api:
            resp = self.app.post(reverse('ReleaseCollectionHandler'),
                                 params=jsonutils.dumps(release_data),
                                 headers=self.default_headers)
            self.tester.assertEqual(resp.status_code, 201)
            release = resp.json_body
            self.releases.append(self.db.query(Release).get(release['id']))
        else:
            release = Release.create(release_data)
            db().commit()
            self.releases.append(release)
        return release