From e4b0f8c035288081024a0a7d1663dc728290831f Mon Sep 17 00:00:00 2001 From: gecong1973 Date: Mon, 5 Nov 2018 22:54:37 -0800 Subject: [PATCH] Add backup create for api v1 At present, freezer client only support backup-create for v2, the patch add v1 support Change-Id: If8e8b28705bf1b5ee8c0f01e1ad2a0f368753b42 --- freezerclient/v1/backups.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/freezerclient/v1/backups.py b/freezerclient/v1/backups.py index 7f1f37b..fcce6dc 100644 --- a/freezerclient/v1/backups.py +++ b/freezerclient/v1/backups.py @@ -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))