Add backup create client support for freezer

Currently, freezer client doesnt support backup create command,
it is not so convenient. This patch add this command for debug.

Change-Id: I0313f431f066a59b6d57130b81e943bce300511b
This commit is contained in:
gecong1973
2018-10-18 18:39:28 -07:00
parent 3cfaed0515
commit 2614d6de09
2 changed files with 17 additions and 0 deletions

View File

@ -59,6 +59,7 @@ class FreezerCommandManager(commandmanager.CommandManager):
'backup-list': backups.BackupList,
'backup-show': backups.BackupShow,
'backup-delete': backups.BackupDelete,
'backup-create': backups.BackupCreate,
'session-list': sessions.SessionList,
'session-show': sessions.SessionShow,
'session-create': sessions.SessionCreate,

View File

@ -117,3 +117,19 @@ class BackupDelete(command.Command):
def take_action(self, parsed_args):
self.app.client.backups.delete(parsed_args.backup_uuid)
logging.info('Backup {0} deleted'.format(parsed_args.backup_uuid))
class BackupCreate(command.Command):
"""Create an backup from a file"""
def get_parser(self, prog_name):
parser = super(BackupCreate, self).get_parser(prog_name)
parser.add_argument('--file',
dest='file',
required=True,
help='Path to json file with the backup')
return parser
def take_action(self, parsed_args):
backup = utils.doc_from_json_file(parsed_args.file)
backup_id = self.app.client.backups.create(backup)
logging.info('Backup {0} created'.format(backup_id))