本文整理汇总了Python中util.full_stack函数的典型用法代码示例。如果您正苦于以下问题:Python full_stack函数的具体用法?Python full_stack怎么用?Python full_stack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了full_stack函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
def handle(self, *args, **kwargs):
self.task.arguments = {'args': args, 'kwargs': kwargs}
if not kwargs['celery_hosts']:
raise CommandError("Please specified the --celery_hosts count")
try:
tasks_with_problem = self.check_tasks(kwargs['celery_hosts'])
except CeleryActivesNodeError as celery_error:
self.task.update_status_for(
TaskHistory.STATUS_WARNING,
'Could not check celery tasks.\n{}{}'.format(
full_stack(), celery_error
)
)
return
except Exception as e:
self.task.update_status_for(
TaskHistory.STATUS_ERROR,
'Could not execute task.\n{}{}'.format(full_stack(), e)
)
return
problems = len(tasks_with_problem)
status = TaskHistory.STATUS_SUCCESS
if problems > 0:
status = TaskHistory.STATUS_WARNING
self.task.update_status_for(status, 'Problems: {}'.format(problems))
self.check_unique_keys()
示例2: do
def do(self, workflow_dict):
try:
workflow_dict['disks'] = []
for instance in workflow_dict['instances']:
host = instance.hostname
if instance.is_arbiter:
LOG.info("Do not creat nfsaas disk for Arbiter...")
continue
LOG.info("Creating nfsaas disk...")
disk = NfsaasProvider(
).create_disk(environment=workflow_dict['environment'],
plan=workflow_dict[
'plan'],
host=host)
if not disk:
return False
workflow_dict['disks'].append(disk)
return True
except Exception, e:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0009)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例3: stop_vm
def stop_vm(workflow_dict):
try:
environment = workflow_dict['environment']
cs_credentials = get_credentials_for(
environment=environment, credential_type=CredentialType.CLOUDSTACK)
cs_provider = CloudStackProvider(credentials=cs_credentials)
instances_detail = workflow_dict['instances_detail']
for instance_detail in instances_detail:
instance = instance_detail['instance']
host = instance.hostname
host_csattr = HostAttr.objects.get(host=host)
stoped = cs_provider.stop_virtual_machine(vm_id=host_csattr.vm_id)
if not stoped:
raise Exception("Could not stop host {}".format(host))
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例4: undo
def undo(self, workflow_dict):
LOG.info("Running undo...")
try:
script = build_stop_database_script()
script = build_context_script({}, script)
for target_instance in workflow_dict['target_instances']:
target_host = target_instance.hostname
target_cs_host_attr = CS_HostAttr.objects.get(host=target_host)
output = {}
exec_remote_command(server=target_host.address,
username=target_cs_host_attr.vm_user,
password=target_cs_host_attr.vm_password,
command=script,
output=output)
LOG.info(output)
try:
if 'region_migration_dir_infra_name' in workflow_dict:
shutil.rmtree(workflow_dict['region_migration_dir_infra_name'])
except Exception:
pass
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例5: run_vm_script
def run_vm_script(workflow_dict, context_dict, script, reverse=False, wait=0):
try:
instances_detail = workflow_dict['instances_detail']
final_context_dict = dict(context_dict.items() + workflow_dict['initial_context_dict'].items())
if reverse:
instances_detail_final = instances_detail[::-1]
else:
instances_detail_final = instances_detail
for instance_detail in instances_detail_final:
host = instance_detail['instance'].hostname
host_csattr = HostAttr.objects.get(host=host)
command = build_context_script(final_context_dict, script)
output = {}
return_code = exec_remote_command(server = host.address,
username = host_csattr.vm_user,
password = host_csattr.vm_password,
command = command,
output = output)
if return_code:
raise Exception, "Could not run script. Output: {}".format(output)
sleep(wait)
return True
except Exception, e:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例6: do
def do(self, workflow_dict):
try:
database = workflow_dict['database']
instances_detail = []
for instance in database.databaseinfra.instances.filter(instance_type=Instance.REDIS):
instances_detail.append({
'instance': instance,
#'is_master': is_master,
'offering_changed': False,
})
workflow_dict['instances_detail'] = instances_detail
context_dict = {
'IS_HA': False,
'DBPASSWORD': database.databaseinfra.password,
'DATABASENAME': database.name,
}
workflow_dict['initial_context_dict'] = context_dict
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例7: do
def do(self, workflow_dict):
try:
command = "mkdir /data2 && mount -t nfs -o bg,intr {} /data2"
host = workflow_dict['host']
volume = workflow_dict['volume']
command = command.format(volume.nfsaas_path)
cs_host_attr = CsHostAttr.objects.get(host=host)
output = {}
return_code = exec_remote_command(server=host.address,
username=cs_host_attr.vm_user,
password=cs_host_attr.vm_password,
command=command,
output=output)
if return_code != 0:
raise Exception(str(output))
workflow_dict['mount'] = command
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0022)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例8: do
def do(self, workflow_dict):
try:
for source_host in workflow_dict['source_hosts']:
host = source_host.future_host
LOG.info("Starting td_agent on host {}".format(host))
cs_host_attr = CS_HostAttr.objects.get(host=host)
context_dict = {}
script = test_bash_script_error()
script += build_start_td_agent_script()
script = build_context_script(context_dict, script)
LOG.info(script)
output = {}
return_code = exec_remote_command(server=host.address,
username=cs_host_attr.vm_user,
password=cs_host_attr.vm_password,
command=script,
output=output)
LOG.info(output)
if return_code != 0:
LOG.error("Error starting td_agent")
LOG.error(str(output))
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例9: run_vm_script
def run_vm_script(workflow_dict, context_dict, script):
try:
instances_detail = workflow_dict["instances_detail"]
final_context_dict = dict(context_dict.items() + workflow_dict["initial_context_dict"].items())
for instance_detail in instances_detail:
host = instance_detail["instance"].hostname
host_csattr = HostAttr.objects.get(host=host)
final_context_dict["IS_MASTER"] = instance_detail["is_master"]
command = build_context_script(final_context_dict, script)
output = {}
return_code = exec_remote_command(
server=host.address,
username=host_csattr.vm_user,
password=host_csattr.vm_password,
command=command,
output=output,
)
if return_code:
raise Exception, "Could not run script. Output: {}".format(output)
return True
except Exception:
traceback = full_stack()
workflow_dict["exceptions"]["error_codes"].append(DBAAS_0015)
workflow_dict["exceptions"]["traceback"].append(traceback)
return False
示例10: run_vm_script
def run_vm_script(workflow_dict, context_dict, script):
try:
final_context_dict = dict(context_dict.items())
instance = workflow_dict['instance']
host = workflow_dict['host']
host_csattr = HostAttr.objects.get(host=host)
final_context_dict['HOSTADDRESS'] = instance.address
final_context_dict['PORT'] = instance.port
final_context_dict['DBPASSWORD'] = workflow_dict['databaseinfra'].password
command = build_context_script(final_context_dict, script)
output = {}
return_code = exec_remote_command(server=host.address,
username=host_csattr.vm_user,
password=host_csattr.vm_password,
command=command,
output=output)
if return_code:
raise Exception("Could not run script. Output: {}".format(output))
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例11: undo
def undo(self, workflow_dict):
try:
original_cloudstackpack = workflow_dict['original_cloudstackpack']
environment = workflow_dict['environment']
cs_credentials = get_credentials_for(
environment=environment, credential_type=CredentialType.CLOUDSTACK)
cs_provider = CloudStackProvider(credentials=cs_credentials)
original_serviceofferingid = original_cloudstackpack.offering.serviceofferingid
if workflow_dict['offering_changed']:
host = workflow_dict['host']
host_csattr = HostAttr.objects.get(host=host)
offering_changed = cs_provider.change_service_for_vm(
vm_id=host_csattr.vm_id, serviceofferingid=original_serviceofferingid)
if not offering_changed:
raise Exception("Could not change offering for Host {}".format(host))
else:
LOG.info('No resize to instance {}'.format(workflow_dict['instance']))
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例12: do
def do(self, workflow_dict):
try:
databaseinfra = workflow_dict['databaseinfra']
workflow_dict['objects_changed'] = []
switch_dns_forward(databaseinfra=databaseinfra,
source_object_list=workflow_dict['source_hosts'],
ip_attribute_name='address',
dns_attribute_name='hostname',
equivalent_atribute_name='future_host',
workflow_dict=workflow_dict)
switch_dns_forward(databaseinfra=databaseinfra,
source_object_list=workflow_dict['source_instances'],
ip_attribute_name='address',
dns_attribute_name='dns',
equivalent_atribute_name='future_instance',
workflow_dict=workflow_dict)
switch_dns_forward(databaseinfra=databaseinfra,
source_object_list=workflow_dict['source_secondary_ips'],
ip_attribute_name='ip',
dns_attribute_name='dns',
equivalent_atribute_name='equivalent_dbinfraattr',
workflow_dict=workflow_dict)
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例13: undo
def undo(self, workflow_dict):
try:
if not 'database' in workflow_dict:
return False
database = workflow_dict['database']
if not database.is_in_quarantine:
LOG.info("Putting Database in quarentine...")
database.is_in_quarantine = True
database.quarantine_dt = datetime.datetime.now().date()
database.save()
database.delete()
LOG.info("Database destroyed....")
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0003)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例14: do
def do(self, workflow_dict):
try:
sleep(60)
databaseinfra = workflow_dict['databaseinfra']
driver = databaseinfra.get_driver()
files_to_remove = driver.remove_deprectaed_files()
command = files_to_remove + " && cp -rp /data/* /data2"
host = workflow_dict['host']
cs_host_attr = CsHostAttr.objects.get(host=host)
output = {}
return_code = exec_remote_command(server=host.address,
username=cs_host_attr.vm_user,
password=cs_host_attr.vm_password,
command=command,
output=output)
if return_code != 0:
raise Exception(str(output))
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0022)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例15: do
def do(self, workflow_dict):
try:
workflow_dict['disks'] = []
for instance in workflow_dict['instances']:
if instance.instance_type == Instance.REDIS_SENTINEL:
continue
host = instance.hostname
LOG.info("Creating nfsaas disk...")
disk = NfsaasProvider(
).create_disk(environment=workflow_dict['environment'],
plan=workflow_dict[
'plan'],
host=host)
if not disk:
return False
workflow_dict['disks'].append(disk)
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0009)
workflow_dict['exceptions']['traceback'].append(traceback)
return False