本文整理汇总了Python中trove.backup.models.Backup类的典型用法代码示例。如果您正苦于以下问题:Python Backup类的具体用法?Python Backup怎么用?Python Backup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Backup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: delete
def delete(self, req, tenant_id, id):
LOG.info(_('Deleting backup for tenant %(tenant_id)s '
'ID: %(backup_id)s') %
{'tenant_id': tenant_id, 'backup_id': id})
context = req.environ[wsgi.CONTEXT_KEY]
Backup.delete(context, id)
return wsgi.Result(None, 202)
开发者ID:CMSS-BCRDB,项目名称:RDSV1.0,代码行数:7,代码来源:service.py
示例2: _action_reset_task_status
def _action_reset_task_status(self, context, instance, body):
LOG.debug("Setting Task-Status to NONE on instance %s." % instance.id)
instance.reset_task_status()
LOG.debug("Failing backups for instance %s." % instance.id)
Backup.fail_for_instance(instance.id)
return wsgi.Result(None, 202)
开发者ID:cretta,项目名称:trove,代码行数:8,代码来源:service.py
示例3: _create_replication_slave
def _create_replication_slave(self, context, instance_id, name, flavor,
image_id, databases, users,
datastore_manager, packages, volume_size,
availability_zone, root_password, nics,
overrides, slave_of_id, backup_id,
volume_type, modules):
if type(instance_id) in [list]:
ids = instance_id
root_passwords = root_password
else:
ids = [instance_id]
root_passwords = [root_password]
replica_number = 0
replica_backup_id = backup_id
replica_backup_created = False
replicas = []
master_instance_tasks = BuiltInstanceTasks.load(context, slave_of_id)
server_group = master_instance_tasks.server_group
scheduler_hints = srv_grp.ServerGroup.convert_to_hint(server_group)
LOG.debug("Using scheduler hints for locality: %s" % scheduler_hints)
try:
for replica_index in range(0, len(ids)):
try:
replica_number += 1
LOG.debug("Creating replica %d of %d."
% (replica_number, len(ids)))
instance_tasks = FreshInstanceTasks.load(
context, ids[replica_index])
snapshot = instance_tasks.get_replication_master_snapshot(
context, slave_of_id, flavor, replica_backup_id,
replica_number=replica_number)
replica_backup_id = snapshot['dataset']['snapshot_id']
replica_backup_created = (replica_backup_id is not None)
instance_tasks.create_instance(
flavor, image_id, databases, users, datastore_manager,
packages, volume_size, replica_backup_id,
availability_zone, root_passwords[replica_index],
nics, overrides, None, snapshot, volume_type,
modules, scheduler_hints)
replicas.append(instance_tasks)
except Exception:
# if it's the first replica, then we shouldn't continue
LOG.exception(_(
"Could not create replica %(num)d of %(count)d.")
% {'num': replica_number, 'count': len(ids)})
if replica_number == 1:
raise
for replica in replicas:
replica.wait_for_instance(CONF.restore_usage_timeout, flavor)
finally:
if replica_backup_created:
Backup.delete(context, replica_backup_id)
开发者ID:Hopebaytech,项目名称:trove,代码行数:57,代码来源:manager.py
示例4: delete
def delete(self, req, tenant_id, id):
LOG.info(_('Deleting backup for tenant %(tenant_id)s '
'ID: %(backup_id)s') %
{'tenant_id': tenant_id, 'backup_id': id})
context = req.environ[wsgi.CONTEXT_KEY]
context.notification = notification.DBaaSBackupDelete(context,
request=req)
with StartNotification(context, backup_id=id):
Backup.delete(context, id)
return wsgi.Result(None, 202)
开发者ID:Hopebaytech,项目名称:trove,代码行数:10,代码来源:service.py
示例5: _create_resources
def _create_resources():
security_groups = None
if backup_id is not None:
backup_info = Backup.get_by_id(context, backup_id)
if backup_info.is_running:
raise exception.BackupNotCompleteError(backup_id=backup_id)
location = backup_info.location
LOG.info(_("Checking if backup exist in '%s'") % location)
if not Backup.check_object_exist(context, location):
raise exception.BackupFileNotFound(location=location)
db_info = DBInstance.create(name=name, flavor_id=flavor_id,
tenant_id=context.tenant,
volume_size=volume_size,
service_type=service_type,
task_status=InstanceTasks.BUILDING)
LOG.debug(_("Tenant %(tenant)s created new "
"Trove instance %(db)s...") %
{'tenant': context.tenant, 'db': db_info.id})
service_status = InstanceServiceStatus.create(
instance_id=db_info.id,
status=rd_instance.ServiceStatuses.NEW)
if CONF.trove_dns_support:
dns_client = create_dns_client(context)
hostname = dns_client.determine_hostname(db_info.id)
db_info.hostname = hostname
db_info.save()
if CONF.trove_security_groups_support:
security_group = SecurityGroup.create_for_instance(
db_info.id,
context)
if CONF.trove_security_groups_rules_support:
SecurityGroupRule.create_sec_group_rule(
security_group,
CONF.trove_security_group_rule_protocol,
CONF.trove_security_group_rule_port,
CONF.trove_security_group_rule_port,
CONF.trove_security_group_rule_cidr,
context
)
security_groups = [security_group["name"]]
task_api.API(context).create_instance(db_info.id, name, flavor,
image_id, databases, users,
service_type, volume_size,
security_groups, backup_id,
availability_zone)
return SimpleInstance(context, db_info, service_status)
开发者ID:citrix-openstack-build,项目名称:trove,代码行数:54,代码来源:models.py
示例6: find
def find(self, req, tenant_id, id):
LOG.info(_('Listing all children and grandchildren for tenant %(tenant_id)s'
'ID: %(backup_id)s') %
{'tenant_id':tenant_id, 'backup_id': id})
context = req.environ[wsgi.CONTEXT_KEY]
child_list = []
Backup.find_children(context, id, child_list)
del child_list[-1]
view = views.BackupViews(child_list)
paged = pagination.SimplePaginatedDataView(req.url, 'backups', view,
None)
return wsgi.Result(paged.data(), 200)
开发者ID:CMSS-BCRDB,项目名称:RDSV1.0,代码行数:12,代码来源:service.py
示例7: _create_replication_slave
def _create_replication_slave(self, context, instance_id, name, flavor,
image_id, databases, users,
datastore_manager, packages, volume_size,
availability_zone, root_password, nics,
overrides, slave_of_id, backup_id):
if type(instance_id) in [list]:
ids = instance_id
root_passwords = root_password
else:
ids = [instance_id]
root_passwords = [root_password]
replica_number = 0
replica_backup_id = backup_id
replica_backup_created = False
replicas = []
try:
for replica_index in range(0, len(ids)):
try:
replica_number += 1
LOG.debug("Creating replica %d of %d."
% (replica_number, len(ids)))
instance_tasks = FreshInstanceTasks.load(
context, ids[replica_index])
snapshot = instance_tasks.get_replication_master_snapshot(
context, slave_of_id, flavor, replica_backup_id,
replica_number=replica_number)
replica_backup_id = snapshot['dataset']['snapshot_id']
replica_backup_created = True
instance_tasks.create_instance(
flavor, image_id, databases, users, datastore_manager,
packages, volume_size, replica_backup_id,
availability_zone, root_passwords[replica_index],
nics, overrides, None, snapshot)
replicas.append(instance_tasks)
except Exception:
# if it's the first replica, then we shouldn't continue
LOG.exception(_(
"Could not create replica %(num)d of %(count)d.")
% {'num': replica_number, 'count': len(instance_id)})
if replica_number == 1:
raise
for replica in replicas:
replica.wait_for_instance(CONF.restore_usage_timeout, flavor)
#rds-start
replica.create_monitor()
#rds-end
finally:
if replica_backup_created:
Backup.delete(context, replica_backup_id)
开发者ID:CMSS-BCRDB,项目名称:RDSV1.0,代码行数:53,代码来源:manager.py
示例8: delete
def delete(self, req, tenant_id, id):
LOG.info(_('Deleting backup for tenant %(tenant_id)s '
'ID: %(backup_id)s') %
{'tenant_id': tenant_id, 'backup_id': id})
context = req.environ[wsgi.CONTEXT_KEY]
backup = Backup.get_by_id(context, id)
policy.authorize_on_target(context, 'backup:delete',
{'tenant': backup.tenant_id})
context.notification = notification.DBaaSBackupDelete(context,
request=req)
with StartNotification(context, backup_id=id):
Backup.delete(context, id)
return wsgi.Result(None, 202)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:13,代码来源:service.py
示例9: show
def show(self, req, tenant_id, id):
"""Return a single backup."""
LOG.info(_("Showing a backup for tenant '%s'") % tenant_id)
LOG.info(_("id : '%s'\n\n") % id)
context = req.environ[wsgi.CONTEXT_KEY]
backup = Backup.get_by_id(context, id)
return wsgi.Result(views.BackupView(backup).data(), 200)
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:7,代码来源:service.py
示例10: backups
def backups(self, req, tenant_id, id):
"""Return all backups for the specified instance."""
LOG.info(_("req : '%s'\n\n") % req)
LOG.info(_("Indexing backups for instance '%s'") % id)
backups = backup_model.list_for_instance(id)
return wsgi.Result(backup_views.BackupViews(backups).data(), 200)
开发者ID:CiscoSystems,项目名称:openstack-trove,代码行数:7,代码来源:service.py
示例11: show
def show(self, req, tenant_id, id):
"""Return a single backup."""
LOG.debug("Showing a backup for tenant %s ID: '%s'"
% (tenant_id, id))
context = req.environ[wsgi.CONTEXT_KEY]
backup = Backup.get_by_id(context, id)
return wsgi.Result(views.BackupView(backup).data(), 200)
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:7,代码来源:service.py
示例12: validate_can_perform_action
def validate_can_perform_action(self):
"""
Raises exception if an instance action cannot currently be performed.
"""
# cases where action cannot be performed
if self.db_info.server_status != "ACTIVE":
status = self.db_info.server_status
elif (
self.db_info.task_status != InstanceTasks.NONE
and self.db_info.task_status != InstanceTasks.RESTART_REQUIRED
):
status = self.db_info.task_status
elif not self.datastore_status.status.action_is_allowed:
status = self.status
elif Backup.running(self.id):
status = InstanceStatus.BACKUP
else:
# action can be performed
return
msg = _(
"Instance %(instance_id)s is not currently available for an "
"action to be performed (status was %(action_status)s)."
) % {"instance_id": self.id, "action_status": status}
LOG.error(msg)
raise exception.UnprocessableEntity(msg)
开发者ID:zjtheone,项目名称:trove,代码行数:26,代码来源:models.py
示例13: index
def index(self, req, tenant_id):
"""
Return all backups information for a tenant ID.
"""
LOG.debug("Listing Backups for tenant '%s'" % tenant_id)
context = req.environ[wsgi.CONTEXT_KEY]
## add customise conditions when list instance
search_ops = {}
search_ops.update(req.GET)
search_ops = self._validate_search_ops(search_ops)
op_chain = search_ops.get('chain', None)
if op_chain:
backups = KSC_Backup.get_chain_whole(context, op_chain)
else:
backups = Backup.list(context, conditions=search_ops)
LOG.debug("index.backups: '%s'", backups)
bks = []
for backup in backups:
try:
#service = inst_models.ServiceImage.find_by(id=backup.service_image_id)
#backup.db_type = service['service_name']
ds,ds_version = ds_patch_models.find_datastore_by_image_id(backup['service_image_id'])
backup.db_type = ds.name
except Exception as ex:
backup['db_type'] = ""
LOG.warn("Failed get db type information of backup %s, %s"%(backup['id'], ex))
bks.append(backup)
backups = bks
return wsgi.Result(views.BackupViews(backups).data(), 200)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:29,代码来源:service.py
示例14: create_backup
def create_backup(self, backup_id):
from trove.backup.models import Backup, BackupState
backup = Backup.get_by_id(backup_id)
def finish_create_backup():
backup.state = BackupState.COMPLETED
backup.save()
self.event_spawn(1.0, finish_create_backup)
开发者ID:dfecker,项目名称:trove,代码行数:8,代码来源:guestagent.py
示例15: index
def index(self, req, tenant_id):
"""
Return all backups information for a tenant ID.
"""
LOG.debug("Listing Backups for tenant '%s'" % tenant_id)
context = req.environ[wsgi.CONTEXT_KEY]
backups = Backup.list(context)
return wsgi.Result(views.BackupViews(backups).data(), 200)
开发者ID:dfecker,项目名称:trove,代码行数:8,代码来源:service.py
示例16: status
def status(self):
# Check for taskmanager errors.
if self.db_info.task_status.is_error:
return InstanceStatus.ERROR
# Check for taskmanager status.
action = self.db_info.task_status.action
if "BUILDING" == action:
if "ERROR" == self.db_info.server_status:
return InstanceStatus.ERROR
return InstanceStatus.BUILD
if "REBOOTING" == action:
return InstanceStatus.REBOOT
if "RESIZING" == action:
return InstanceStatus.RESIZE
if "RESTART_REQUIRED" == action:
return InstanceStatus.RESTART_REQUIRED
if InstanceTasks.PROMOTING.action == action:
return InstanceStatus.PROMOTE
if InstanceTasks.EJECTING.action == action:
return InstanceStatus.EJECT
if InstanceTasks.LOGGING.action == action:
return InstanceStatus.LOGGING
# Check for server status.
if self.db_info.server_status in ["BUILD", "ERROR", "REBOOT", "RESIZE"]:
return self.db_info.server_status
# As far as Trove is concerned, Nova instances in VERIFY_RESIZE should
# still appear as though they are in RESIZE.
if self.db_info.server_status in ["VERIFY_RESIZE"]:
return InstanceStatus.RESIZE
# Check if there is a backup running for this instance
if Backup.running(self.id):
return InstanceStatus.BACKUP
# Report as Shutdown while deleting, unless there's an error.
if "DELETING" == action:
if self.db_info.server_status in ["ACTIVE", "SHUTDOWN", "DELETED"]:
return InstanceStatus.SHUTDOWN
else:
LOG.error(
_LE("While shutting down instance (%(instance)s): " "server had status (%(status)s)."),
{"instance": self.id, "status": self.db_info.server_status},
)
return InstanceStatus.ERROR
# Check against the service status.
# The service is only paused during a reboot.
if tr_instance.ServiceStatuses.PAUSED == self.datastore_status.status:
return InstanceStatus.REBOOT
# If the service status is NEW, then we are building.
if tr_instance.ServiceStatuses.NEW == self.datastore_status.status:
return InstanceStatus.BUILD
# For everything else we can look at the service status mapping.
return self.datastore_status.status.api_status
开发者ID:zjtheone,项目名称:trove,代码行数:58,代码来源:models.py
示例17: _relocate_master
def _relocate_master(self, master_id, slave_id,backup_id=None):
'''
Fore. 2014/9/29 desperated method. don't use it.
:param master_id:
:param slave_id:
:param backup_id:
'''
master_group_item = InstanceGroupItem.get_by_instance_id(self.context, master_id)
def __show_master_status(inst_id):
_instance = self.load(self.context, inst_id)
_guest = _instance.get_guest()
mStatus = _guest.ksc_show_master_status()
log_path, log_pos = mStatus['file'], mStatus['position']
return log_path, log_pos
if backup_id is None:
log_path, log_pos = __show_master_status(master_id)
else:
bk_info = Backup.get_by_id(self.context, backup_id)
if master_group_item.group_id == bk_info.group_id:
log_path, log_pos = Backup.get_binlog_info(self.context, backup_id)
else:
log_path, log_pos = __show_master_status(master_id)
LOG.debug("relocate master instance %s get binlog_path:%s binlog_pos:%s" \
%(master_id, log_path, log_pos))
group_item = master_group_item
master_host = self._get_instance_ip(master_id)
master_guest = FreshInstanceTasks.load(self.context, master_id).guest
master_port = int(master_guest.ksc_list_variables(["port"])["port"])
repl_user = CONF.rds_rpl_user
repl_password = self._gen_rpl_user_password(group_item.group_id)
master_log_file = log_path
master_log_pos = log_pos
slave_instance = self.load(self.context, slave_id)
slave_guest = slave_instance.get_guest()
slave_guest.ksc_relocate_master(master_host=master_host, master_port = master_port, repl_user=repl_user,
repl_password=repl_password, master_log_file=master_log_file,
master_log_pos=master_log_pos)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:45,代码来源:models.py
示例18: show
def show(self, req, tenant_id, id):
"""Return a single backup."""
LOG.debug("Showing a backup for tenant %s ID: '%s'"
% (tenant_id, id))
context = req.environ[wsgi.CONTEXT_KEY]
backup = Backup.get_by_id(context, id)
policy.authorize_on_target(context, 'backup:show',
{'tenant': backup.tenant_id})
return wsgi.Result(views.BackupView(backup).data(), 200)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:9,代码来源:service.py
示例19: create_backup
def create_backup(self, backup_id):
from trove.backup.models import Backup, BackupState
backup = Backup.get_by_id(context=None, backup_id=backup_id)
def finish_create_backup():
backup.state = BackupState.COMPLETED
backup.location = 'http://localhost/path/to/backup'
backup.save()
eventlet.spawn_after(1.0, finish_create_backup)
开发者ID:ReVolly,项目名称:trove,代码行数:9,代码来源:guestagent.py
示例20: create
def create(self, req, body, tenant_id):
LOG.debug("Creating a Backup for tenant '%s'" % tenant_id)
context = req.environ[wsgi.CONTEXT_KEY]
data = body["backup"]
instance = data["instance"]
name = data["name"]
desc = data.get("description")
backup = Backup.create(context, instance, name, desc)
return wsgi.Result(views.BackupView(backup).data(), 202)
开发者ID:ReVolly,项目名称:trove,代码行数:9,代码来源:service.py
注:本文中的trove.backup.models.Backup类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论