#!/usr/bin/env python2.7
from ebspin import base, configuration
import argparse, logging, sys

logging.basicConfig(level=logging.INFO)

if __name__ == '__main__':

    parser = argparse.ArgumentParser()
    parser.add_argument('-u', '--uuid', required=True, help='The UUID tag')

    parser.add_argument('-d', '--device', default='/dev/xvdf', help='The device to use')
    parser.add_argument('-s', '--size', default=10, type=int, help='The volume size')
    parser.add_argument('-t', '--type', default='standard', help='The volume type')
    parser.add_argument('-i', '--interval', default='daily', help='The snapshot interval')
    parser.add_argument('-n', '--nopreserve', action='store_false', default=True, help="Don't Preserve the volume from deletion")

    parser.add_argument('-a', '--tags', nargs='+', default=None, help='List of AWS tags to add, e.g. Key1=Value1 Key2=Value2')


    args = parser.parse_args()

    # convert tags Key=Value to dictionary
    tags = {}
    if args.tags:
        for tag in args.tags:
            key, value = tag.split('=')
            tags[key] = value
    args.tags = tags

    c = configuration.Configuration()
    metadata = c.metadata()

    b = base.Base(args, metadata)

    b.attach()

    # TODO this part
    #b.snapshot()
    #b.tag()
