本文整理汇总了Python中nailgun.objects.Release.get_by_uid方法的典型用法代码示例。如果您正苦于以下问题:Python Release.get_by_uid方法的具体用法?Python Release.get_by_uid怎么用?Python Release.get_by_uid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.objects.Release
的用法示例。
在下文中一共展示了Release.get_by_uid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _validate_common
# 需要导入模块: from nailgun.objects import Release [as 别名]
# 或者: from nailgun.objects.Release import get_by_uid [as 别名]
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
示例2: get_all_by_release
# 需要导入模块: from nailgun.objects import Release [as 别名]
# 或者: from nailgun.objects.Release import get_by_uid [as 别名]
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
示例3: _validate_common
# 需要导入模块: from nailgun.objects import Release [as 别名]
# 或者: from nailgun.objects.Release import get_by_uid [as 别名]
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
示例4: get_cluster_attributes_by_components
# 需要导入模块: from nailgun.objects import Release [as 别名]
# 或者: from nailgun.objects.Release import get_by_uid [as 别名]
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', {})
}
示例5: _validate_common
# 需要导入模块: from nailgun.objects import Release [as 别名]
# 或者: from nailgun.objects.Release import get_by_uid [as 别名]
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