#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
This script destroys a virtual cluster in synnefo.

@author: Ioannis Stenos, Nick Vrionis
'''
from sys import argv
from create_cluster import destroy_cluster
import logging
from optparse import OptionParser


def main(opts):
    '''
    The main function calls the destroy cluster with cluster_name and
    auth token given.
    '''
    cluster_name = opts.name
    auth = opts.token
    destroy_cluster(cluster_name, auth)

if __name__ == '__main__':

    kw = {}
    kw['usage'] = '%prog [options]'
    kw['description'] = '%prog deletes a cluster on Synnefo w. kamaki'

    parser = OptionParser(**kw)
    parser.disable_interspersed_args()
    parser.add_option('--name',
                      action='store', type='string', dest='name',
                      metavar="CLUSTER NAME",
                      help='The name of the cluster')
    parser.add_option('--token',
                      action='store', type='string', dest='token',
                      metavar='AUTH TOKEN',
                      help='Synnefo authentication token')
    
    opts, args = parser.parse_args(argv[1:])
    logging.addLevelName(25, "REPORT")
    logger = logging.getLogger("report")



    
    logging_level = 25
    logging.basicConfig(format='%(asctime)s:%(levelname)s:%(message)s',
                            level=logging_level, datefmt='%H:%M:%S')
    main(opts)

@@ -201,16 +201,24 @@
 _cluster
+, REPORT
 %0Aimport 
@@ -1097,21 +1097,17 @@
 token')%0A
-    
 %0A
+
     opts
@@ -1168,18 +1168,22 @@
 velName(
-25
+REPORT
 , %22REPOR
@@ -1232,15 +1232,8 @@
 %22)%0A%0A
-%0A%0A    %0A
     
@@ -1252,10 +1252,14 @@
 l = 
-25
+REPORT
 %0A   
@@ -1327,20 +1327,16 @@
 age)s',%0A
-    
         
@@ -1407,8 +1407,9 @@
 n(opts)%0A
+%0A

call destroy cluster from create_cluster script