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