#!/usr/bin/env perl
use warnings;
use Switch;

use lib::taktukWrapper;
use lib::actions;

#Declaration of global variables
use vars qw( 
    $topology 
    %default 
    %nodes 
    @machines 
    @deployee 
    );

#List of availabl e actions
#   - Need to be generated automatically
my @list_of_actions = qw(all check clean deploy deps pack ping uninstall install start stop topology replicate installdeps);


# Default node settings
$default = {
    "java" =>  "/usr/lib/jvm/java-6-sun/",
    "path" => "/usr/local/ig",
    "grm" => Null,
    #grm, self, cannot be stored in this structure
    "installgrm" => True,
    "installlrm" =>  True,
    "shared" =>  Null    
};
# Set of deployment nodes
$nodes = {};
# keys(%nodes)
#@machines = [];
# List of every non shared file system node + one representand node for each share
#@deployee = [];
# File name where topology configuration resides, default is default.yml
$topology = "default";


sub main{
    #print("Welcome to ig-deployer v0.1. Powered by TakTuk.\n");
    my $numArgs = $#ARGV + 1;
    

    if ($numArgs >= 1){
        
        if ($numArgs >= 2){
            $topology = $ARGV[1];
        }
                
        action_topology();
        
        my $obj = bless {};

        if (my $call = $obj->can("action_".$ARGV[0])) {
            $call->();
        }else{
            print "Action $ARGV[0] does not exist.\n";
            print "Availabe actions are ".join(", ",@list_of_actions)."\n";
        }
    } else {
        print("Say a command..\n");
    }
}

main();
