當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。