Revision 8cd7d0df src/cli/onehost

View differences:

src/cli/onehost
79 79
            " rsync command must be installed in the frontend and nodes."
80 80
    }
81 81

  
82
    EC2_ACCESS = {
83
        :name   => "ec2access",
84
        :large  => "--ec2access id",
85
        :description => "Set the id access for EC2 Driver",
82
    TYPE = {
83
        :name  => "type",
84
        :short => "-t remote_provider",
85
        :large => "--type remote_provider",
86
        :description => "Use type to create a host using Cloud Bursting ",
86 87
        :format => String
87 88
    }
88 89

  
89
    EC2_SECRET = {
90
        :name   => "ec2secret",
91
        :large  => "--ec2secret key",
92
        :description => "Set the secret key for EC2 Driver",
93
        :format => String
94
    }
95

  
96
    CREAT_OPTIONS = [ IM, VMM, OneClusterHelper::CLUSTER, EC2_ACCESS, EC2_SECRET ]
90
    CREAT_OPTIONS = [ IM, VMM, OneClusterHelper::CLUSTER, TYPE ]
97 91
    SYNC_OPTIONS  = [ OneClusterHelper::CLUSTER, FORCE, RSYNC ]
98 92

  
99 93
    ########################################################################
......
116 110
        Creates a new Host
117 111
    EOT
118 112

  
119
    command :create, create_desc, :hostname, :options=>CREAT_OPTIONS do
113
    command :create, create_desc, :hostname, [:file, nil], :options=>CREAT_OPTIONS do
120 114
        if options[:im].nil? || options[:vm].nil?
121 115
            STDERR.puts "Drivers are mandatory to create a host:"
122 116
            STDERR.puts "\t -i information driver"
......
124 118
            exit -1
125 119
        end
126 120

  
127
        ec2_host = !options[:ec2access].nil? && !options[:ec2secret].nil?
128

  
129 121
        cid = options[:cluster] || ClusterPool::NONE_CLUSTER_ID
130 122
        helper.create_resource(options) do |host|
131
                rc = host.allocate(args[0], options[:im], options[:vm], cid)
132

  
133
                if ec2_host && !OpenNebula.is_error?(rc)
134
               	    template = "EC2_ACCESS=\"#{options[:ec2access]}\"\n"\
135
               		    "EC2_SECRET=\"#{options[:ec2secret]}\"\n"\
136

  
137
                    rc = host.update(template, true)
138
                end
123
            if !options[:type].nil?
124
                str = helper.set_hybrid(options[:type], args[1])
125
            end
126
            rc = host.allocate(args[0], options[:im], options[:vm], cid)
127
            host.update(str, true) if !OpenNebula.is_error?(rc) && !options[:type].nil?
139 128

  
140
                rc
129
            rc
141 130
        end
142 131
    end
143 132

  

Also available in: Unified diff