当前位置: 首页>>代码示例>>Python>>正文


Python objects.Release类代码示例

本文整理汇总了Python中nailgun.objects.Release的典型用法代码示例。如果您正苦于以下问题:Python Release类的具体用法?Python Release怎么用?Python Release使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Release类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _validate_common

    def _validate_common(cls, data, instance=None):
        d = cls.validate_json(data)

        release_id = d.get("release", d.get("release_id"))
        if release_id:
            if not Release.get_by_uid(release_id):
                raise errors.InvalidData(
                    "Invalid release ID", log_message=True)
        pend_release_id = d.get("pending_release_id")
        if pend_release_id:
            pend_release = Release.get_by_uid(pend_release_id,
                                              fail_if_not_found=True)
            if not release_id:
                if not instance:
                    raise errors.InvalidData(
                        "Cannot set pending release when "
                        "there is no current release",
                        log_message=True
                    )
                release_id = instance.release_id
            curr_release = Release.get_by_uid(release_id)

            if not cls._can_update_release(curr_release, pend_release):
                raise errors.InvalidData(
                    "Cannot set pending release as "
                    "it cannot update current release",
                    log_message=True
                )
        return d
开发者ID:Axam,项目名称:fuel-web,代码行数:29,代码来源:cluster.py

示例2: create_release

    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
开发者ID:thefuyang,项目名称:fuel-web,代码行数:35,代码来源:base.py

示例3: create_release

 def create_release(self, api=False, **kwargs):
     version = kwargs.get(
         'version', '{0}-5.1'.format(randint(0, 100000000)))
     release_data = {
         'name': u"release_name_" + version,
         'version': version,
         'description': u"release_desc" + version,
         'operating_system': 'CentOS',
         'roles': self.get_default_roles(),
         'networks_metadata': self.get_default_networks_metadata(),
         'attributes_metadata': self.get_default_attributes_metadata(),
         'volumes_metadata': self.get_default_volumes_metadata()
     }
     if kwargs:
         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
开发者ID:slystopad,项目名称:fuel-web,代码行数:31,代码来源:base.py

示例4: get_all_by_release

    def get_all_by_release(cls, release_id):
        """Get all components for specific release.

        :param release_id: release ID
        :type release_id: int

        :returns: list -- list of components
        """
        components = []
        release = Release.get_by_uid(release_id)
        release_os = release.operating_system.lower()
        release_version = release.version

        db_components = db().query(cls.single.model).options(
            joinedload(cls.single.model.releases),
            joinedload(cls.single.model.plugin)).all()

        for db_component in db_components:
            if db_component.releases:
                for db_release in db_component.releases:
                    if db_release.id == release.id:
                        components.append(db_component)
            elif db_component.plugin:
                for plugin_release in db_component.plugin.releases:
                    if (release_os == plugin_release.get('os') and
                            release_version == plugin_release.get('version')):
                        components.append(db_component)

        return components
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:29,代码来源:component.py

示例5: get_cluster_attributes_by_components

    def get_cluster_attributes_by_components(cls, components, release_id):
        """Enable cluster attributes by given components

        :param components: list of component names
        :type components: list of strings
        :param release_id: Release model id
        :type release_id: str
        :returns: dict -- objects with enabled attributes for cluster
        """

        def _update_attributes_dict_by_binds_exp(bind_exp, value):
            """Update cluster and attributes data with bound values

            :param bind_exp: path to specific attribute for model in format
                             model:some.attribute.value. Model can be
                             settings|cluster
            :type bind_exp: str
            :param value: value for specific attribute
            :type value: bool|str|int
            :returns: None
            """
            model, attr_expr = bind_exp.split(':')
            if model not in ('settings', 'cluster'):
                return

            path_items = attr_expr.split('.')
            path_items.insert(0, model)
            attributes = cluster_attributes
            for i in six.moves.range(0, len(path_items) - 1):
                attributes = attributes.setdefault(path_items[i], {})
            attributes[path_items[-1]] = value

        release = Release.get_by_uid(release_id)
        cluster_attributes = {}
        for component in Release.get_all_components(release):
            if component['name'] in components:
                for bind_item in component.get('bind', []):
                    if isinstance(bind_item, six.string_types):
                        _update_attributes_dict_by_binds_exp(bind_item, True)
                    elif isinstance(bind_item, list):
                        _update_attributes_dict_by_binds_exp(bind_item[0],
                                                             bind_item[1])
        return {
            'editable': cluster_attributes.get('settings', {}),
            'cluster': cluster_attributes.get('cluster', {})
        }
开发者ID:ansumanbebarta,项目名称:fuel-web,代码行数:46,代码来源:cluster.py

示例6: process_cluster_attributes

    def process_cluster_attributes(cls, cluster, attributes):
        """Generate Cluster-Plugins relation based on attributes.

        Iterates through plugins attributes, creates
        or deletes Cluster <-> Plugins relation if plugin
        is enabled or disabled.

        :param cluster: A cluster instance
        :type cluster: nailgun.db.sqlalchemy.models.cluster.Cluster
        :param attributes: Cluster attributes
        :type attributes: dict
        """
        from nailgun.objects import Release

        plugins = {}

        # Detach plugins data
        for k in list(attributes):
            if cls.is_plugin_data(attributes[k]):
                plugins[k] = attributes.pop(k)['metadata']

        propagate_task_deploy = get_in(
            attributes, 'common', 'propagate_task_deploy', 'value')
        if propagate_task_deploy is not None:
            legacy_tasks_are_ignored = not propagate_task_deploy
        else:
            legacy_tasks_are_ignored = not get_in(
                cluster.attributes.editable,
                'common', 'propagate_task_deploy', 'value')

        for container in six.itervalues(plugins):
            default = container.get('default', False)
            for attrs in container.get('versions', []):
                version_metadata = attrs.pop('metadata')
                plugin_id = version_metadata['plugin_id']
                plugin = Plugin.get_by_uid(plugin_id)
                if not plugin:
                    logger.warning(
                        'Plugin with id "%s" is not found, skip it', plugin_id)
                    continue
                enabled = container['enabled'] \
                    and plugin_id == container['chosen_id']
                if (enabled and
                        Release.is_lcm_supported(cluster.release) and
                        legacy_tasks_are_ignored and
                        cls.contains_legacy_tasks(
                            wrap_plugin(Plugin.get_by_uid(plugin.id)))):
                    raise errors.InvalidData(
                        'Cannot enable plugin with legacy tasks unless '
                        'propagate_task_deploy attribute is set. '
                        'Ensure tasks.yaml is empty and all tasks '
                        'has version >= 2.0.0.')
                ClusterPlugin.set_attributes(
                    cluster.id, plugin.id, enabled=enabled,
                    attrs=attrs if enabled or default else None
                )
开发者ID:openstack,项目名称:fuel-web,代码行数:56,代码来源:manager.py

示例7: _validate_common

    def _validate_common(cls, data):
        d = cls.validate_json(data)

        release_id = d.get("release", d.get("release_id", None))
        if release_id:
            release = Release.get_by_uid(release_id)
            if not release:
                raise errors.InvalidData(
                    "Invalid release ID", log_message=True)
        return d
开发者ID:enchantner,项目名称:fuel-web,代码行数:10,代码来源:cluster.py

示例8: GET

    def GET(self, release_id):
        """:returns: JSONized component data for release and releated plugins.

        :http: * 200 (OK)
               * 404 (release not found in db)
        """
        release = self.get_object_or_404(Release, release_id)
        components = Release.get_all_components(release)

        return [ComponentSerializer.serialize(c) for c in components]
开发者ID:dnikishov,项目名称:fuel-web,代码行数:10,代码来源:component.py

示例9: get_deployment_tasks

    def get_deployment_tasks(cls, instance):
        """Return deployment graph for cluster based on cluster attributes

            - if there is deployment_graph defined by user - use it instead of
              defined
            - if instance assigned for patching - return custom patching graph
            - else return default for release deployment graph
        """
        if instance.deployment_tasks:
            return instance.deployment_tasks
        elif instance.pending_release_id:
            return yaml.load(graph_configuration.PATCHING)
        else:
            return Release.get_deployment_tasks(instance.release)
开发者ID:TorstenS73,项目名称:fuel-web,代码行数:14,代码来源:cluster.py

示例10: get_meta

    def get_meta(cls, instance):
        """Get immutable attributes for bond.

        :param instance: NodeBondInterface instance
        :type instance: NodeBondInterface model
        :returns: dict -- Object of bond attributes
        """
        meta = {}
        dpdk_drivers = Release.get_supported_dpdk_drivers(
            instance.node.cluster.release)
        meta['dpdk'] = {
            'available': cls.dpdk_available(instance, dpdk_drivers)}
        meta['offloading'] = {
            'modes': Bond.get_available_offloading_modes(instance)
        }
        return meta
开发者ID:openstack,项目名称:fuel-web,代码行数:16,代码来源:bond.py

示例11: get_deployment_tasks

    def get_deployment_tasks(cls, instance):
        """Return deployment graph for cluster based on cluster attributes

            - if there is deployment_graph defined by user - use it instead of
              defined
            - if instance assigned for patching - return custom patching graph
            - else return default for release and enabled plugins
              deployment graph
        """
        if instance.deployment_tasks:
            return instance.deployment_tasks
        else:
            release_deployment_tasks = \
                Release.get_deployment_tasks(instance.release)
            plugin_deployment_tasks = \
                PluginManager.get_plugins_deployment_tasks(instance)
            return release_deployment_tasks + plugin_deployment_tasks
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:17,代码来源:cluster.py

示例12: create_release

    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
开发者ID:blkart,项目名称:fuel-web,代码行数:43,代码来源:base.py

示例13: _validate_common

 def _validate_common(cls, data):
     d = cls.validate_json(data)
     if d.get("name"):
         if ClusterCollection.filter_by(
             query=None,
             name=d["name"]
         ).first():
             raise errors.AlreadyExists(
                 "Environment with this name already exists",
                 log_message=True
             )
     release_id = d.get("release", d.get("release_id", None))
     if release_id:
         release = Release.get_by_uid(release_id)
         if not release:
             raise errors.InvalidData(
                 "Invalid release ID",
                 log_message=True
             )
     return d
开发者ID:MsiRgb,项目名称:fuel-web,代码行数:20,代码来源:cluster.py


注:本文中的nailgun.objects.Release类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。