Skip to content

Commit

Permalink
Merge pull request #38 from exula/master
Browse files Browse the repository at this point in the history
Created a command line option --tag
  • Loading branch information
wefixit-AT committed Apr 4, 2017
2 parents ed08239 + 041735a commit a4a74d5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def create_argparser():
action="store_true",
default=False,
)
vmg.add_argument(
"--tag",
help="define the tag used to override the list of VM's that should"
" be backed up",
dest="vm_tag",
default=False,
)
vmg.add_argument(
"--vm-names",
help="List of names which VMs should be backed up",
Expand Down Expand Up @@ -211,7 +218,15 @@ def main(argv):
# Update config file
if opts.config_file.name != "<stdin>":
config.write_update(opts.config_file.name)


# Add VM's with the tag to the vm list
if opts.vm_tag:
vms=api.vms.list(max=400, query="tag="+opts.vm_tag)
config.set_vm_names([vm.name for vm in vms])
# Update config file
if opts.config_file.name != "<stdin>":
config.write_update(opts.config_file.name)

# Test if config export_domain is valid
if api.storagedomains.get(config.get_export_domain()) is None:
logger.error("!!! Check the export_domain in the config")
Expand Down

0 comments on commit a4a74d5

Please sign in to comment.