本文整理汇总了Python中rally.db.deployment_list函数的典型用法代码示例。如果您正苦于以下问题:Python deployment_list函数的具体用法?Python deployment_list怎么用?Python deployment_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deployment_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_deployment
def create_deployment(self):
dpl_file_name = ".".join((self.deployment_name, "json"))
dpl_path = os.path.join(self.rally_deployment_dir, dpl_file_name)
logging.debug("deployment config file path is %s" % dpl_path)
if not os.path.isfile(dpl_path):
err_msg = "Cannot find deployment config file for rally."
raise HealthException(err_msg, self.url)
deployments = db.deployment_list(name=self.deployment_name)
if deployments:
# Destroy the previous deployment
uuid = deployments[0].uuid
self.delete_deployment_and_tasks(uuid)
logging.info("Destroy previous deployment!")
# Create deployment
command = "rally deployment create --filename=%s --name=%s" % (dpl_path, self.deployment_name)
logging.info(command)
returncode, output, err_msg = self.exec_cli(command)
if returncode > 0:
# Send error message to Compass. Rally failed.
raise HealthException(err_msg, self.url)
deployment = db.deployment_list(name=self.deployment_name)[0]
return deployment.uuid
示例2: test_deployment_list_parent
def test_deployment_list_parent(self):
deploy = db.deployment_create({})
subdeploy1 = db.deployment_create({'parent_uuid': deploy.uuid})
subdeploy2 = db.deployment_create({'parent_uuid': deploy.uuid})
self.assertEqual([deploy.uuid], [d.uuid for d in db.deployment_list()])
subdeploys = db.deployment_list(parent_uuid=deploy.uuid)
self.assertEqual(set([subdeploy1.uuid, subdeploy2.uuid]),
set([d.uuid for d in subdeploys]))
示例3: test_deployment_list_with_status
def test_deployment_list_with_status(self):
deploy_one = db.deployment_create({})
deploy_two = db.deployment_create({
'config': {},
'status': consts.DeployStatus.DEPLOY_FAILED,
})
deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_INIT)
self.assertEqual(len(deploys), 1)
self.assertEqual(deploys[0]['uuid'], deploy_one['uuid'])
deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_FAILED)
self.assertEqual(len(deploys), 1)
self.assertEqual(deploys[0]['uuid'], deploy_two['uuid'])
deploys = db.deployment_list(
status=consts.DeployStatus.DEPLOY_FINISHED)
self.assertEqual(len(deploys), 0)
示例4: test_deployment_delete
def test_deployment_delete(self):
deploy_one = db.deployment_create({})
deploy_two = db.deployment_create({})
db.deployment_delete(deploy_two['uuid'])
deploys = db.deployment_list()
self.assertEqual(len(deploys), 1)
self.assertEqual(deploys[0]['uuid'], deploy_one['uuid'])
示例5: test_deployment_create
def test_deployment_create(self):
deploy = db.deployment_create({'config': {'opt': 'val'}})
deploys = db.deployment_list()
self.assertEqual(len(deploys), 1)
self.assertEqual(deploy['uuid'], deploys[0]['uuid'])
self.assertEqual(deploy['status'], consts.DeployStatus.DEPLOY_INIT)
self.assertEqual(deploy['config'], {'opt': 'val'})
示例6: list
def list(self):
"""Print list of deployments."""
headers = ['uuid', 'created_at', 'name', 'status']
table = prettytable.PrettyTable(headers)
for t in db.deployment_list():
r = [str(t[column]) for column in headers]
table.add_row(r)
print(table)
示例7: test_deployment_create_several
def test_deployment_create_several(self):
# Create a deployment
deploys = db.deployment_list()
self.assertEqual(len(deploys), 0)
deploy_one = db.deployment_create({'config': {'opt1': 'val1'}})
deploys = db.deployment_list()
self.assertEqual(len(deploys), 1)
self.assertEqual(deploy_one['uuid'], deploys[0]['uuid'])
self.assertEqual(deploy_one['status'], consts.DeployStatus.DEPLOY_INIT)
self.assertEqual(deploy_one['config'], {'opt1': 'val1'})
# Create another deployment and sure that they are different
deploy_two = db.deployment_create({'config': {'opt2': 'val2'}})
deploys = db.deployment_list()
self.assertEqual(len(deploys), 2)
self.assertEqual([deploy_one['uuid'], deploy_two['uuid']],
[deploy['uuid'] for deploy in deploys])
self.assertNotEqual(deploy_one['uuid'], deploy_two['uuid'])
self.assertEqual(deploy_two['status'], consts.DeployStatus.DEPLOY_INIT)
self.assertEqual(deploy_two['config'], {'opt2': 'val2'})
示例8: test_deployment_list_with_status_and_name
def test_deployment_list_with_status_and_name(self):
deploy_one = db.deployment_create({})
deploy_two = db.deployment_create({
"config": {},
"status": consts.DeployStatus.DEPLOY_FAILED,
})
deploy_three = db.deployment_create({"name": "deployment_name"})
deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_INIT)
deploys.sort(key=lambda x: x["id"])
self.assertEqual(len(deploys), 2)
self.assertEqual(deploys[0]["uuid"], deploy_one["uuid"])
deploys = db.deployment_list(status=consts.DeployStatus.DEPLOY_FAILED)
self.assertEqual(len(deploys), 1)
self.assertEqual(deploys[0]["uuid"], deploy_two["uuid"])
deploys = db.deployment_list(
status=consts.DeployStatus.DEPLOY_FINISHED)
self.assertEqual(len(deploys), 0)
deploys = db.deployment_list(name="deployment_name")
self.assertEqual(deploys[0]["uuid"], deploy_three["uuid"])
self.assertEqual(len(deploys), 1)
示例9: test_deployment_create_several
def test_deployment_create_several(self):
# Create a deployment
deploys = db.deployment_list()
self.assertEqual(len(deploys), 0)
deploy_one = db.deployment_create({"config": {"opt1": "val1"}})
deploys = db.deployment_list()
self.assertEqual(len(deploys), 1)
self.assertEqual(deploy_one["uuid"], deploys[0]["uuid"])
self.assertEqual(deploy_one["status"], consts.DeployStatus.DEPLOY_INIT)
self.assertEqual(deploy_one["config"], {"opt1": "val1"})
# Create another deployment and sure that they are different
deploy_two = db.deployment_create({"config": {"opt2": "val2"}})
deploys = db.deployment_list()
self.assertEqual(len(deploys), 2)
self.assertEqual(set([deploy_one["uuid"], deploy_two["uuid"]]),
set([deploy["uuid"] for deploy in deploys]))
self.assertNotEqual(deploy_one["uuid"], deploy_two["uuid"])
self.assertEqual(deploy_two["status"], consts.DeployStatus.DEPLOY_INIT)
self.assertEqual(deploy_two["config"], {"opt2": "val2"})
示例10: delete_deployment_and_tasks
def delete_deployment_and_tasks(self, deployment_uuid=None):
if not deployment_uuid:
deployments = db.deployment_list(name=self.deployment_name)
if not deployments:
return
deployment_uuid = deployments[0].uuid
self.cleanup_previous_tasks(deployment_uuid)
command = "rally deployment destroy --deployment %s" % self.deployment_name
returncode, output, err_msg = self.exec_cli(command)
if returncode > 0:
raise HealthException(err_msg, self.url)
logging.info("Destroyed the deployment '%s'" % self.deployment_name)
示例11: list
def list(self, deployment_list=None):
"""Print list of deployments."""
headers = ['uuid', 'created_at', 'name', 'status', 'active']
current_deploy_id = envutils.get_global('RALLY_DEPLOYMENT')
deployment_list = deployment_list or db.deployment_list()
table_rows = []
if deployment_list:
for t in deployment_list:
r = [str(t[column]) for column in headers[:-1]]
r.append("" if t["uuid"] != current_deploy_id else "*")
table_rows.append(utils.Struct(**dict(zip(headers, r))))
common_cliutils.print_list(table_rows, headers)
else:
print(_("There are no deployments. "
"To create a new deployment, use:"
"\nrally deployment create"))
示例12: list
def list(self, deployment_list=None):
"""Print list of deployments."""
headers = ['uuid', 'created_at', 'name', 'status', 'active']
current_deploy_id = envutils.get_global('RALLY_DEPLOYMENT')
deployment_list = deployment_list or db.deployment_list()
if deployment_list:
table = prettytable.PrettyTable(headers)
for t in deployment_list:
r = [str(t[column]) for column in headers[:-1]]
r.append("" if t["uuid"] != current_deploy_id else "*")
table.add_row(r)
print(table)
else:
print(_("There are no deployments. "
"To create a new deployment, use:"
"\nrally deployment create"))
示例13: list
def list(self, deployment_list=None):
"""List existing deployments."""
headers = ["uuid", "created_at", "name", "status", "active"]
current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
deployment_list = deployment_list or db.deployment_list()
table_rows = []
if deployment_list:
for t in deployment_list:
r = [str(t[column]) for column in headers[:-1]]
r.append("" if t["uuid"] != current_deployment else "*")
table_rows.append(utils.Struct(**dict(zip(headers, r))))
cliutils.print_list(table_rows, headers,
sortby_index=headers.index("created_at"))
else:
print(_("There are no deployments. "
"To create a new deployment, use:"
"\nrally deployment create"))
示例14: deployment
def deployment(self, deploy_id=None, name=None):
"""Set active deployment.
:param deploy_id: a UUID of a deployment
"""
if not (name or deploy_id):
print('You should specify --name or --uuid of deployment')
return 1
deploy = None
if name:
deployments = db.deployment_list(name=name)
if len(deployments) > 1:
print("Multiple deployments found by name: `%s`" % name)
return 1
elif not deployments:
print("There is no `%s` deployment" % name)
return 1
else:
deploy = deployments[0]
deploy_id = deploy["uuid"]
try:
deploy = deploy or db.deployment_get(deploy_id)
print('Using deployment: %s' % deploy_id)
self._ensure_rally_configuration_dir_exists()
self._update_attribute_in_global_file('RALLY_DEPLOYMENT',
deploy_id)
self._update_openrc_deployment_file(
deploy_id, deploy.get('admin') or deploy.get('users')[0])
print ('~/.rally/openrc was updated\n\nHINTS:\n'
'* To get your cloud resources, run:\n\t'
'rally show [flavors|images|keypairs|networks|secgroups]\n'
'\n* To use standard OpenStack clients, set up your env by '
'running:\n\tsource ~/.rally/openrc\n'
' OpenStack clients are now configured, e.g run:\n\t'
'glance image-list')
except exceptions.DeploymentNotFound:
print('Deployment %s is not found.' % deploy_id)
return 1
示例15: cleanup
def cleanup(self):
subdeploys = db.deployment_list(parent_uuid=self.deployment["uuid"])
for subdeploy in subdeploys:
rally.api.Deployment.destroy(subdeploy["uuid"])