opennebula-cli 5.3.80.beta1 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/bin/onehost +13 -24
 - data/bin/oneuser +14 -2
 - data/lib/one_helper.rb +0 -14
 - data/lib/one_helper/onehost_helper.rb +36 -0
 - data/lib/one_helper/oneimage_helper.rb +2 -2
 - data/lib/one_helper/oneuser_helper.rb +15 -6
 - data/lib/one_helper/onevm_helper.rb +1 -1
 - data/lib/one_helper/onezone_helper.rb +26 -5
 - metadata +22 -24
 - data/bin/oneuser.backup +0 -522
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8548f70bb2a40ff7eea3a067c31d288e412ad206
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5a869b56b4726a7c875922741f94fabd703f7eeb
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 429fa23813dfdf1d8374bcd5448aff4692284040b0148d00dacf491f7520ed8bda4f454a8aa4e4476c513184acf1505f076e76f4720920a7d3203cb91d5f9fbc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 639c78f877b042775a9c5b7baa493f0efda0314572293358f35292076b53f4fe80f204cb526b7fb8436b35acabde32e819ba9f87478030396fdac92fedac23ab
         
     | 
    
        data/bin/onehost
    CHANGED
    
    | 
         @@ -79,21 +79,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do 
     | 
|
| 
       79 
79 
     | 
    
         
             
                        " rsync command must be installed in the frontend and nodes."
         
     | 
| 
       80 
80 
     | 
    
         
             
                }
         
     | 
| 
       81 
81 
     | 
    
         | 
| 
       82 
     | 
    
         
            -
                 
     | 
| 
       83 
     | 
    
         
            -
                    :name 
     | 
| 
       84 
     | 
    
         
            -
                    : 
     | 
| 
       85 
     | 
    
         
            -
                    : 
     | 
| 
      
 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 
     | 
    
         
            -
                 
     | 
| 
       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,7 +110,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do 
     | 
|
| 
       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,20 +118,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do 
     | 
|
| 
       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 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       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 
     | 
    
         
            -
             
     | 
| 
      
 129 
     | 
    
         
            +
                        rc
         
     | 
| 
       141 
130 
     | 
    
         
             
                    end
         
     | 
| 
       142 
131 
     | 
    
         
             
                end
         
     | 
| 
       143 
132 
     | 
    
         | 
    
        data/bin/oneuser
    CHANGED
    
    | 
         @@ -33,14 +33,26 @@ require 'one_helper/onequota_helper' 
     | 
|
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
            require 'uri'
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
            cmd=CommandParser::CmdParser.new(ARGV) do
         
     | 
| 
      
 36 
     | 
    
         
            +
            cmd = CommandParser::CmdParser.new(ARGV) do
         
     | 
| 
       37 
37 
     | 
    
         
             
                usage "`oneuser` <command> [<args>] [<options>]"
         
     | 
| 
       38 
38 
     | 
    
         
             
                version OpenNebulaHelper::ONE_VERSION
         
     | 
| 
       39 
39 
     | 
    
         | 
| 
       40 
40 
     | 
    
         
             
                helper = OneUserHelper.new
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
                before_proc do
         
     | 
| 
       43 
     | 
    
         
            -
                     
     | 
| 
      
 43 
     | 
    
         
            +
                    if ![:key].include?(@comm_name)
         
     | 
| 
      
 44 
     | 
    
         
            +
                        begin
         
     | 
| 
      
 45 
     | 
    
         
            +
                            helper.set_client(options)
         
     | 
| 
      
 46 
     | 
    
         
            +
                        rescue Exception => e
         
     | 
| 
      
 47 
     | 
    
         
            +
                            STDERR.puts e.message
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                            if e.message != OpenNebula::Client::NO_ONE_AUTH_ERROR
         
     | 
| 
      
 50 
     | 
    
         
            +
                                STDERR.puts e.backtrace
         
     | 
| 
      
 51 
     | 
    
         
            +
                            end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                            exit 1
         
     | 
| 
      
 54 
     | 
    
         
            +
                        end
         
     | 
| 
      
 55 
     | 
    
         
            +
                    end
         
     | 
| 
       44 
56 
     | 
    
         
             
                end
         
     | 
| 
       45 
57 
     | 
    
         | 
| 
       46 
58 
     | 
    
         
             
                ########################################################################
         
     | 
    
        data/lib/one_helper.rb
    CHANGED
    
    | 
         @@ -492,20 +492,6 @@ EOT 
     | 
|
| 
       492 
492 
     | 
    
         
             
                    end
         
     | 
| 
       493 
493 
     | 
    
         | 
| 
       494 
494 
     | 
    
         | 
| 
       495 
     | 
    
         
            -
                    # receive a object key => value format
         
     | 
| 
       496 
     | 
    
         
            -
                    # returns hashed values
         
     | 
| 
       497 
     | 
    
         
            -
                    def encrypt(opts, token)
         
     | 
| 
       498 
     | 
    
         
            -
                        res = {}
         
     | 
| 
       499 
     | 
    
         
            -
                        opts.each do |key, value|
         
     | 
| 
       500 
     | 
    
         
            -
                            cipher = OpenSSL::Cipher::AES.new(256,:CBC)
         
     | 
| 
       501 
     | 
    
         
            -
                            cipher.encrypt.key = token[0..31]
         
     | 
| 
       502 
     | 
    
         
            -
                            encrypted = cipher.update(value) + cipher.final
         
     | 
| 
       503 
     | 
    
         
            -
                            res[key] = Base64::encode64(encrypted) 
         
     | 
| 
       504 
     | 
    
         
            -
                        end
         
     | 
| 
       505 
     | 
    
         
            -
                        
         
     | 
| 
       506 
     | 
    
         
            -
                        return res
         
     | 
| 
       507 
     | 
    
         
            -
                    end
         
     | 
| 
       508 
     | 
    
         
            -
             
     | 
| 
       509 
495 
     | 
    
         
             
                    def list_pool(options, top=false, filter_flag=nil)
         
     | 
| 
       510 
496 
     | 
    
         
             
                        if options[:describe]
         
     | 
| 
       511 
497 
     | 
    
         
             
                            table = format_pool(options)
         
     | 
| 
         @@ -20,6 +20,32 @@ require 'rubygems' 
     | 
|
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            class OneHostHelper < OpenNebulaHelper::OneHelper
         
     | 
| 
       22 
22 
     | 
    
         
             
                TEMPLATE_XPATH  = '//HOST/TEMPLATE'
         
     | 
| 
      
 23 
     | 
    
         
            +
                HYBRID = {
         
     | 
| 
      
 24 
     | 
    
         
            +
                    :ec2 => {
         
     | 
| 
      
 25 
     | 
    
         
            +
                        :help => <<-EOT.unindent,
         
     | 
| 
      
 26 
     | 
    
         
            +
                            #-----------------------------------------------------------------------
         
     | 
| 
      
 27 
     | 
    
         
            +
                            # Supported EC2 AUTH ATTRIBUTTES:
         
     | 
| 
      
 28 
     | 
    
         
            +
                            #
         
     | 
| 
      
 29 
     | 
    
         
            +
                            #  REGION_NAME = <the name of the ec2 region>
         
     | 
| 
      
 30 
     | 
    
         
            +
                            #
         
     | 
| 
      
 31 
     | 
    
         
            +
                            #  EC2_ACCESS = <Your ec2 access key id>
         
     | 
| 
      
 32 
     | 
    
         
            +
                            #  EC2_SECRET = <Your ec2 secret key>
         
     | 
| 
      
 33 
     | 
    
         
            +
                            #
         
     | 
| 
      
 34 
     | 
    
         
            +
                            #  CAPACITY = [
         
     | 
| 
      
 35 
     | 
    
         
            +
                            #    M1SMALL  = <number of machines m1.small>,
         
     | 
| 
      
 36 
     | 
    
         
            +
                            #    M1XLARGE = <number of machines m1.xlarge>,
         
     | 
| 
      
 37 
     | 
    
         
            +
                            #    M1LARGE  = <number of machines m1.large>
         
     | 
| 
      
 38 
     | 
    
         
            +
                            #  ]
         
     | 
| 
      
 39 
     | 
    
         
            +
                            #
         
     | 
| 
      
 40 
     | 
    
         
            +
                            # You can set any machine type supported by ec2
         
     | 
| 
      
 41 
     | 
    
         
            +
                            # See your ec2_driver.conf for more information
         
     | 
| 
      
 42 
     | 
    
         
            +
                            #
         
     | 
| 
      
 43 
     | 
    
         
            +
                            #-----------------------------------------------------------------------
         
     | 
| 
      
 44 
     | 
    
         
            +
                            EOT
         
     | 
| 
      
 45 
     | 
    
         
            +
                    }
         
     | 
| 
      
 46 
     | 
    
         
            +
                }
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
       23 
49 
     | 
    
         
             
                VERSION_XPATH   = "#{TEMPLATE_XPATH}/VERSION"
         
     | 
| 
       24 
50 
     | 
    
         | 
| 
       25 
51 
     | 
    
         
             
                def self.rname
         
     | 
| 
         @@ -164,6 +190,12 @@ class OneHostHelper < OpenNebulaHelper::OneHelper 
     | 
|
| 
       164 
190 
     | 
    
         
             
                    table
         
     | 
| 
       165 
191 
     | 
    
         
             
                end
         
     | 
| 
       166 
192 
     | 
    
         | 
| 
      
 193 
     | 
    
         
            +
                def set_hybrid(type, path)
         
     | 
| 
      
 194 
     | 
    
         
            +
                    k = type.to_sym
         
     | 
| 
      
 195 
     | 
    
         
            +
                    if HYBRID.key?(k)
         
     | 
| 
      
 196 
     | 
    
         
            +
                        str = path.nil? ?  OpenNebulaHelper.editor_input(HYBRID[k][:help]): File.read(path)
         
     | 
| 
      
 197 
     | 
    
         
            +
                    end
         
     | 
| 
      
 198 
     | 
    
         
            +
                end
         
     | 
| 
       167 
199 
     | 
    
         | 
| 
       168 
200 
     | 
    
         
             
                NUM_THREADS = 15
         
     | 
| 
       169 
201 
     | 
    
         
             
                def sync(host_ids, options)
         
     | 
| 
         @@ -230,10 +262,14 @@ class OneHostHelper < OpenNebulaHelper::OneHelper 
     | 
|
| 
       230 
262 
     | 
    
         | 
| 
       231 
263 
     | 
    
         
             
                        vm_mad = host['VM_MAD'].downcase
         
     | 
| 
       232 
264 
     | 
    
         
             
                        remote_remotes = host['TEMPLATE/REMOTE_REMOTES']
         
     | 
| 
      
 265 
     | 
    
         
            +
                        state = host['STATE']
         
     | 
| 
       233 
266 
     | 
    
         | 
| 
       234 
267 
     | 
    
         
             
                        # Skip this host from remote syncing if it's a PUBLIC_CLOUD host
         
     | 
| 
       235 
268 
     | 
    
         
             
                        next if host['TEMPLATE/PUBLIC_CLOUD'] == 'YES'
         
     | 
| 
       236 
269 
     | 
    
         | 
| 
      
 270 
     | 
    
         
            +
                        # Skip this host from remote syncing if it's OFFLINE
         
     | 
| 
      
 271 
     | 
    
         
            +
                        next if Host::HOST_STATES[state.to_i] == 'OFFLINE'
         
     | 
| 
      
 272 
     | 
    
         
            +
             
     | 
| 
       237 
273 
     | 
    
         
             
                        host_version=host['TEMPLATE/VERSION']
         
     | 
| 
       238 
274 
     | 
    
         | 
| 
       239 
275 
     | 
    
         
             
                        begin
         
     | 
| 
         @@ -290,7 +290,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper 
     | 
|
| 
       290 
290 
     | 
    
         
             
                        puts str % [e,  mask]
         
     | 
| 
       291 
291 
     | 
    
         
             
                    }
         
     | 
| 
       292 
292 
     | 
    
         | 
| 
       293 
     | 
    
         
            -
                    if image.has_elements?("/IMAGE/SNAPSHOTS")
         
     | 
| 
      
 293 
     | 
    
         
            +
                    if image.has_elements?("/IMAGE/SNAPSHOTS/SNAPSHOT")
         
     | 
| 
       294 
294 
     | 
    
         
             
                        puts
         
     | 
| 
       295 
295 
     | 
    
         
             
                        CLIHelper.print_header(str_h1 % "IMAGE SNAPSHOTS",false)
         
     | 
| 
       296 
296 
     | 
    
         
             
                        format_snapshots(image)
         
     | 
| 
         @@ -361,7 +361,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper 
     | 
|
| 
       361 
361 
     | 
    
         | 
| 
       362 
362 
     | 
    
         
             
                    # Convert snapshot data to an array
         
     | 
| 
       363 
363 
     | 
    
         
             
                    image_hash = image.to_hash
         
     | 
| 
       364 
     | 
    
         
            -
                    image_snapshots = [image_hash['IMAGE']['SNAPSHOTS']].flatten 
     | 
| 
      
 364 
     | 
    
         
            +
                    image_snapshots = [image_hash['IMAGE']['SNAPSHOTS']['SNAPSHOT']].flatten
         
     | 
| 
       365 
365 
     | 
    
         
             
                    table.show(image_snapshots)
         
     | 
| 
       366 
366 
     | 
    
         
             
                end
         
     | 
| 
       367 
367 
     | 
    
         | 
| 
         @@ -27,11 +27,14 @@ class TokenAuth 
     | 
|
| 
       27 
27 
     | 
    
         
             
            end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
            class OneUserHelper < OpenNebulaHelper::OneHelper
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                    ONE_AUTH = ENV['HOME']+'/.one/one_auth'
         
     | 
| 
      
 30 
     | 
    
         
            +
                if ENV['ONE_AUTH']
         
     | 
| 
      
 31 
     | 
    
         
            +
                    ONE_AUTH = ENV['ONE_AUTH']
         
     | 
| 
       33 
32 
     | 
    
         
             
                else
         
     | 
| 
       34 
     | 
    
         
            -
                     
     | 
| 
      
 33 
     | 
    
         
            +
                    if ENV['HOME']
         
     | 
| 
      
 34 
     | 
    
         
            +
                        ONE_AUTH = ENV['HOME']+'/.one/one_auth'
         
     | 
| 
      
 35 
     | 
    
         
            +
                    else
         
     | 
| 
      
 36 
     | 
    
         
            +
                        ONE_AUTH = "/var/lib/one/.one/one_auth"
         
     | 
| 
      
 37 
     | 
    
         
            +
                    end
         
     | 
| 
       35 
38 
     | 
    
         
             
                end
         
     | 
| 
       36 
39 
     | 
    
         | 
| 
       37 
40 
     | 
    
         
             
                def self.rname
         
     | 
| 
         @@ -206,12 +209,14 @@ class OneUserHelper < OpenNebulaHelper::OneHelper 
     | 
|
| 
       206 
209 
     | 
    
         | 
| 
       207 
210 
     | 
    
         
             
                    return -1, token_oned.message if OpenNebula.is_error?(token_oned)
         
     | 
| 
       208 
211 
     | 
    
         | 
| 
      
 212 
     | 
    
         
            +
                    token_info = "Authentication Token is:\n#{username}:#{token_oned}"
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
       209 
214 
     | 
    
         
             
                    #-----------------------------------------------------------------------
         
     | 
| 
       210 
215 
     | 
    
         
             
                    # Check that ONE_AUTH target can be written
         
     | 
| 
       211 
216 
     | 
    
         
             
                    #-----------------------------------------------------------------------
         
     | 
| 
       212 
217 
     | 
    
         
             
                    if File.file?(ONE_AUTH) && !options[:force]
         
     | 
| 
       213 
218 
     | 
    
         
             
                            return 0, "File #{ONE_AUTH} exists, use --force to overwrite."\
         
     | 
| 
       214 
     | 
    
         
            -
                            "\ 
     | 
| 
      
 219 
     | 
    
         
            +
                            "\n#{token_info}"
         
     | 
| 
       215 
220 
     | 
    
         
             
                    end
         
     | 
| 
       216 
221 
     | 
    
         | 
| 
       217 
222 
     | 
    
         
             
                    #-----------------------------------------------------------------------
         
     | 
| 
         @@ -228,7 +233,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper 
     | 
|
| 
       228 
233 
     | 
    
         | 
| 
       229 
234 
     | 
    
         
             
                    File.chmod(0600, ONE_AUTH)
         
     | 
| 
       230 
235 
     | 
    
         | 
| 
       231 
     | 
    
         
            -
                    return 0,  
     | 
| 
      
 236 
     | 
    
         
            +
                    return 0, token_info
         
     | 
| 
       232 
237 
     | 
    
         
             
                end
         
     | 
| 
       233 
238 
     | 
    
         | 
| 
       234 
239 
     | 
    
         
             
                def format_pool(options)
         
     | 
| 
         @@ -459,6 +464,10 @@ class OneUserHelper < OpenNebulaHelper::OneHelper 
     | 
|
| 
       459 
464 
     | 
    
         
             
                        username = args[0]
         
     | 
| 
       460 
465 
     | 
    
         
             
                        use_client = false
         
     | 
| 
       461 
466 
     | 
    
         
             
                    else
         
     | 
| 
      
 467 
     | 
    
         
            +
                        if !defined?(@@client)
         
     | 
| 
      
 468 
     | 
    
         
            +
                            return -1, "No username in the argument or valid ONE_AUTH found."
         
     | 
| 
      
 469 
     | 
    
         
            +
                        end
         
     | 
| 
      
 470 
     | 
    
         
            +
             
     | 
| 
       462 
471 
     | 
    
         
             
                        user = self.get_client_user
         
     | 
| 
       463 
472 
     | 
    
         
             
                        username = user['NAME']
         
     | 
| 
       464 
473 
     | 
    
         
             
                        use_client = true
         
     | 
| 
         @@ -578,7 +578,7 @@ in the frontend machine. 
     | 
|
| 
       578 
578 
     | 
    
         
             
                        vm_disks = [vm_hash['VM']['TEMPLATE']['DISK']].flatten
         
     | 
| 
       579 
579 
     | 
    
         
             
                    end
         
     | 
| 
       580 
580 
     | 
    
         | 
| 
       581 
     | 
    
         
            -
                    if vm.has_elements?("/VM/TEMPLATE/CONTEXT")
         
     | 
| 
      
 581 
     | 
    
         
            +
                    if vm.has_elements?("/VM/TEMPLATE/CONTEXT") && vm["/VM/HISTORY_RECORDS/HISTORY[1]/VM_MAD"] != 'vcenter'
         
     | 
| 
       582 
582 
     | 
    
         
             
                        context_disk = vm_hash['VM']['TEMPLATE']['CONTEXT']
         
     | 
| 
       583 
583 
     | 
    
         | 
| 
       584 
584 
     | 
    
         
             
                        context_disk["IMAGE"]     = "CONTEXT"
         
     | 
| 
         @@ -147,14 +147,34 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper 
     | 
|
| 
       147 
147 
     | 
    
         
             
                                 when "3" then "leader"
         
     | 
| 
       148 
148 
     | 
    
         
             
                                 else "-"
         
     | 
| 
       149 
149 
     | 
    
         
             
                             end
         
     | 
| 
       150 
     | 
    
         
            -
                            s["TERM"] 
     | 
| 
      
 150 
     | 
    
         
            +
                            s["TERM"]      = xml_doc.root.at_xpath("TERM").text
         
     | 
| 
       151 
151 
     | 
    
         
             
                            s["VOTEDFOR"]  = xml_doc.root.at_xpath("VOTEDFOR").text
         
     | 
| 
       152 
152 
     | 
    
         
             
                            s["COMMIT"]    = xml_doc.root.at_xpath("COMMIT").text
         
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
                            s["LOG_INDEX"]    = xml_doc.root.at_xpath("LOG_INDEX").text
         
     | 
| 
      
 155 
     | 
    
         
            +
                            s["FEDLOG_INDEX"] = xml_doc.root.at_xpath("FEDLOG_INDEX").text
         
     | 
| 
       154 
156 
     | 
    
         
             
                        }
         
     | 
| 
       155 
157 
     | 
    
         | 
| 
       156 
158 
     | 
    
         
             
                        puts
         
     | 
| 
       157 
     | 
    
         
            -
                        CLIHelper.print_header(str_h1 % "SERVERS",false)
         
     | 
| 
      
 159 
     | 
    
         
            +
                        CLIHelper.print_header(str_h1 % "ZONE SERVERS",false)
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
                        CLIHelper::ShowTable.new(nil, self) do
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                            column :"ID", "", :size=>2 do |d|
         
     | 
| 
      
 164 
     | 
    
         
            +
                                d["ID"] if !d.nil?
         
     | 
| 
      
 165 
     | 
    
         
            +
                            end
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
                            column :"NAME", "", :left, :size=>15 do |d|
         
     | 
| 
      
 168 
     | 
    
         
            +
                                d["NAME"] if !d.nil?
         
     | 
| 
      
 169 
     | 
    
         
            +
                            end
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
                            column :"ENDPOINT", "", :left, :size=>63 do |d|
         
     | 
| 
      
 172 
     | 
    
         
            +
                                d["ENDPOINT"] if !d.nil?
         
     | 
| 
      
 173 
     | 
    
         
            +
                            end
         
     | 
| 
      
 174 
     | 
    
         
            +
                        end.show([zone_hash['ZONE']['SERVER_POOL']['SERVER']].flatten, {})
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
                        puts
         
     | 
| 
      
 177 
     | 
    
         
            +
                        CLIHelper.print_header(str_h1 % "HA & FEDERATION SYNC STATUS",false)
         
     | 
| 
       158 
178 
     | 
    
         | 
| 
       159 
179 
     | 
    
         
             
                        CLIHelper::ShowTable.new(nil, self) do
         
     | 
| 
       160 
180 
     | 
    
         | 
| 
         @@ -186,9 +206,10 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper 
     | 
|
| 
       186 
206 
     | 
    
         
             
                                d["VOTEDFOR"] if !d.nil?
         
     | 
| 
       187 
207 
     | 
    
         
             
                            end
         
     | 
| 
       188 
208 
     | 
    
         | 
| 
       189 
     | 
    
         
            -
                            column :" 
     | 
| 
       190 
     | 
    
         
            -
                                d[" 
     | 
| 
      
 209 
     | 
    
         
            +
                            column :"FED_INDEX", "", :left, :size=>10 do |d|
         
     | 
| 
      
 210 
     | 
    
         
            +
                                d["FEDLOG_INDEX"] if !d.nil?
         
     | 
| 
       191 
211 
     | 
    
         
             
                            end
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
       192 
213 
     | 
    
         
             
                        end.show([zone_hash['ZONE']['SERVER_POOL']['SERVER']].flatten, {})
         
     | 
| 
       193 
214 
     | 
    
         
             
                    end
         
     | 
| 
       194 
215 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: opennebula-cli
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 5. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 5.4.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - OpenNebula
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-07-19 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: opennebula
         
     | 
| 
         @@ -16,40 +16,39 @@ dependencies: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - '='
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: 5. 
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 5.4.0
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
24 
     | 
    
         
             
                - - '='
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: 5. 
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 5.4.0
         
     | 
| 
       27 
27 
     | 
    
         
             
            description: Commands used to talk to OpenNebula
         
     | 
| 
       28 
28 
     | 
    
         
             
            email: contact@opennebula.org
         
     | 
| 
       29 
29 
     | 
    
         
             
            executables:
         
     | 
| 
       30 
     | 
    
         
            -
            -  
     | 
| 
       31 
     | 
    
         
            -
            -  
     | 
| 
       32 
     | 
    
         
            -
            - oneacl
         
     | 
| 
       33 
     | 
    
         
            -
            - onecluster
         
     | 
| 
       34 
     | 
    
         
            -
            - onedatastore
         
     | 
| 
       35 
     | 
    
         
            -
            - oneflow
         
     | 
| 
      
 30 
     | 
    
         
            +
            - onehost
         
     | 
| 
      
 31 
     | 
    
         
            +
            - onevcenter
         
     | 
| 
       36 
32 
     | 
    
         
             
            - oneflow-template
         
     | 
| 
       37 
     | 
    
         
            -
            - onegroup
         
     | 
| 
       38 
     | 
    
         
            -
            - oneimage
         
     | 
| 
       39 
     | 
    
         
            -
            - onemarket
         
     | 
| 
       40 
     | 
    
         
            -
            - onemarketapp
         
     | 
| 
       41 
     | 
    
         
            -
            - onesecgroup
         
     | 
| 
       42 
     | 
    
         
            -
            - oneshowback
         
     | 
| 
       43 
     | 
    
         
            -
            - onetemplate
         
     | 
| 
       44 
33 
     | 
    
         
             
            - oneuser
         
     | 
| 
       45 
     | 
    
         
            -
            - onevcenter
         
     | 
| 
       46 
34 
     | 
    
         
             
            - onevdc
         
     | 
| 
       47 
     | 
    
         
            -
            -  
     | 
| 
       48 
     | 
    
         
            -
            -  
     | 
| 
      
 35 
     | 
    
         
            +
            - onesecgroup
         
     | 
| 
      
 36 
     | 
    
         
            +
            - oneacct
         
     | 
| 
      
 37 
     | 
    
         
            +
            - oneflow
         
     | 
| 
       49 
38 
     | 
    
         
             
            - onevnet
         
     | 
| 
      
 39 
     | 
    
         
            +
            - oneshowback
         
     | 
| 
       50 
40 
     | 
    
         
             
            - onevrouter
         
     | 
| 
      
 41 
     | 
    
         
            +
            - onevmgroup
         
     | 
| 
      
 42 
     | 
    
         
            +
            - onemarket
         
     | 
| 
       51 
43 
     | 
    
         
             
            - onezone
         
     | 
| 
       52 
     | 
    
         
            -
            -  
     | 
| 
      
 44 
     | 
    
         
            +
            - onecluster
         
     | 
| 
      
 45 
     | 
    
         
            +
            - oneacl
         
     | 
| 
      
 46 
     | 
    
         
            +
            - onemarketapp
         
     | 
| 
      
 47 
     | 
    
         
            +
            - onedatastore
         
     | 
| 
      
 48 
     | 
    
         
            +
            - onevm
         
     | 
| 
      
 49 
     | 
    
         
            +
            - onegroup
         
     | 
| 
      
 50 
     | 
    
         
            +
            - onetemplate
         
     | 
| 
      
 51 
     | 
    
         
            +
            - oneimage
         
     | 
| 
       53 
52 
     | 
    
         
             
            extensions: []
         
     | 
| 
       54 
53 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       55 
54 
     | 
    
         
             
            files:
         
     | 
| 
         @@ -70,7 +69,6 @@ files: 
     | 
|
| 
       70 
69 
     | 
    
         
             
            - bin/oneshowback
         
     | 
| 
       71 
70 
     | 
    
         
             
            - bin/onetemplate
         
     | 
| 
       72 
71 
     | 
    
         
             
            - bin/oneuser
         
     | 
| 
       73 
     | 
    
         
            -
            - bin/oneuser.backup
         
     | 
| 
       74 
72 
     | 
    
         
             
            - bin/onevcenter
         
     | 
| 
       75 
73 
     | 
    
         
             
            - bin/onevdc
         
     | 
| 
       76 
74 
     | 
    
         
             
            - bin/onevm
         
     | 
| 
         @@ -115,9 +113,9 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       115 
113 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       116 
114 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       117 
115 
     | 
    
         
             
              requirements:
         
     | 
| 
       118 
     | 
    
         
            -
              - - " 
     | 
| 
      
 116 
     | 
    
         
            +
              - - ">="
         
     | 
| 
       119 
117 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       120 
     | 
    
         
            -
                  version:  
     | 
| 
      
 118 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
       121 
119 
     | 
    
         
             
            requirements: []
         
     | 
| 
       122 
120 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       123 
121 
     | 
    
         
             
            rubygems_version: 2.6.11
         
     | 
    
        data/bin/oneuser.backup
    DELETED
    
    | 
         @@ -1,522 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #!/usr/bin/env ruby
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # -------------------------------------------------------------------------- #
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright 2002-2015, OpenNebula Project, OpenNebula Systems                #
         
     | 
| 
       5 
     | 
    
         
            -
            #                                                                            #
         
     | 
| 
       6 
     | 
    
         
            -
            # Licensed under the Apache License, Version 2.0 (the "License"); you may    #
         
     | 
| 
       7 
     | 
    
         
            -
            # not use this file except in compliance with the License. You may obtain    #
         
     | 
| 
       8 
     | 
    
         
            -
            # a copy of the License at                                                   #
         
     | 
| 
       9 
     | 
    
         
            -
            #                                                                            #
         
     | 
| 
       10 
     | 
    
         
            -
            # http://www.apache.org/licenses/LICENSE-2.0                                 #
         
     | 
| 
       11 
     | 
    
         
            -
            #                                                                            #
         
     | 
| 
       12 
     | 
    
         
            -
            # Unless required by applicable law or agreed to in writing, software        #
         
     | 
| 
       13 
     | 
    
         
            -
            # distributed under the License is distributed on an "AS IS" BASIS,          #
         
     | 
| 
       14 
     | 
    
         
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
         
     | 
| 
       15 
     | 
    
         
            -
            # See the License for the specific language governing permissions and        #
         
     | 
| 
       16 
     | 
    
         
            -
            # limitations under the License.                                             #
         
     | 
| 
       17 
     | 
    
         
            -
            #--------------------------------------------------------------------------- #
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            ONE_LOCATION=ENV["ONE_LOCATION"]
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
            if !ONE_LOCATION
         
     | 
| 
       22 
     | 
    
         
            -
                RUBY_LIB_LOCATION="/usr/lib/one/ruby"
         
     | 
| 
       23 
     | 
    
         
            -
            else
         
     | 
| 
       24 
     | 
    
         
            -
                RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
         
     | 
| 
       25 
     | 
    
         
            -
            end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
            $: << RUBY_LIB_LOCATION
         
     | 
| 
       28 
     | 
    
         
            -
            $: << RUBY_LIB_LOCATION+"/cli"
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
            require 'command_parser'
         
     | 
| 
       31 
     | 
    
         
            -
            require 'one_helper/oneuser_helper'
         
     | 
| 
       32 
     | 
    
         
            -
            require 'one_helper/onequota_helper'
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            require 'uri'
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
            cmd=CommandParser::CmdParser.new(ARGV) do
         
     | 
| 
       37 
     | 
    
         
            -
                usage "`oneuser` <command> [<args>] [<options>]"
         
     | 
| 
       38 
     | 
    
         
            -
                version OpenNebulaHelper::ONE_VERSION
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                helper = OneUserHelper.new
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                before_proc do
         
     | 
| 
       43 
     | 
    
         
            -
                    helper.set_client(options) if ![:login, :key].include?(@comm_name)
         
     | 
| 
       44 
     | 
    
         
            -
                end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                ########################################################################
         
     | 
| 
       47 
     | 
    
         
            -
                # Global Options
         
     | 
| 
       48 
     | 
    
         
            -
                ########################################################################
         
     | 
| 
       49 
     | 
    
         
            -
                set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                list_options = CLIHelper::OPTIONS
         
     | 
| 
       52 
     | 
    
         
            -
                list_options << OpenNebulaHelper::XML
         
     | 
| 
       53 
     | 
    
         
            -
                list_options << OpenNebulaHelper::NUMERIC
         
     | 
| 
       54 
     | 
    
         
            -
                list_options << OpenNebulaHelper::DESCRIBE
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                READ_FILE={
         
     | 
| 
       57 
     | 
    
         
            -
                    :name => "read_file",
         
     | 
| 
       58 
     | 
    
         
            -
                    :short => "-r",
         
     | 
| 
       59 
     | 
    
         
            -
                    :large => "--read-file",
         
     | 
| 
       60 
     | 
    
         
            -
                    :description => "Read password from file"
         
     | 
| 
       61 
     | 
    
         
            -
                }
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                SHA1={
         
     | 
| 
       64 
     | 
    
         
            -
                    :name => "sha1",
         
     | 
| 
       65 
     | 
    
         
            -
                    :large => "--sha1",
         
     | 
| 
       66 
     | 
    
         
            -
                    :description => "The password will be hashed using the sha1\n"<<
         
     | 
| 
       67 
     | 
    
         
            -
                                    " "*31<<"algorithm"
         
     | 
| 
       68 
     | 
    
         
            -
                }
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                SSH={
         
     | 
| 
       71 
     | 
    
         
            -
                    :name => "ssh",
         
     | 
| 
       72 
     | 
    
         
            -
                    :large => "--ssh",
         
     | 
| 
       73 
     | 
    
         
            -
                    :description => "SSH Auth system",
         
     | 
| 
       74 
     | 
    
         
            -
                    :proc => lambda { |o, options|
         
     | 
| 
       75 
     | 
    
         
            -
                        options[:driver] = OpenNebula::User::SSH_AUTH
         
     | 
| 
       76 
     | 
    
         
            -
                    }
         
     | 
| 
       77 
     | 
    
         
            -
                }
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
                X509={
         
     | 
| 
       80 
     | 
    
         
            -
                    :name => "x509",
         
     | 
| 
       81 
     | 
    
         
            -
                    :large => "--x509",
         
     | 
| 
       82 
     | 
    
         
            -
                    :description => "x509 Auth system for x509 certificates",
         
     | 
| 
       83 
     | 
    
         
            -
                    :proc => lambda { |o, options|
         
     | 
| 
       84 
     | 
    
         
            -
                        options[:driver] = OpenNebula::User::X509_AUTH
         
     | 
| 
       85 
     | 
    
         
            -
                    }
         
     | 
| 
       86 
     | 
    
         
            -
                }
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
                X509_PROXY={
         
     | 
| 
       89 
     | 
    
         
            -
                    :name => "x509_proxy",
         
     | 
| 
       90 
     | 
    
         
            -
                    :large => "--x509_proxy",
         
     | 
| 
       91 
     | 
    
         
            -
                    :description => "x509 Auth system based on x509 proxy certificates",
         
     | 
| 
       92 
     | 
    
         
            -
                    :proc => lambda { |o, options|
         
     | 
| 
       93 
     | 
    
         
            -
                        options[:driver] = OpenNebula::User::X509_PROXY_AUTH
         
     | 
| 
       94 
     | 
    
         
            -
                    }
         
     | 
| 
       95 
     | 
    
         
            -
                }
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
                KEY={
         
     | 
| 
       98 
     | 
    
         
            -
                    :name => "key",
         
     | 
| 
       99 
     | 
    
         
            -
                    :short => "-k path_to_private_key_pem",
         
     | 
| 
       100 
     | 
    
         
            -
                    :large => "--key path_to_private_key_pem",
         
     | 
| 
       101 
     | 
    
         
            -
                    :format => String,
         
     | 
| 
       102 
     | 
    
         
            -
                    :description => "Path to the Private Key of the User"
         
     | 
| 
       103 
     | 
    
         
            -
                }
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
                CERT={
         
     | 
| 
       106 
     | 
    
         
            -
                    :name => "cert",
         
     | 
| 
       107 
     | 
    
         
            -
                    :short => "-c path_to_user_cert_pem",
         
     | 
| 
       108 
     | 
    
         
            -
                    :large => "--cert path_to_user_cert_pem",
         
     | 
| 
       109 
     | 
    
         
            -
                    :format => String,
         
     | 
| 
       110 
     | 
    
         
            -
                    :description => "Path to the Certificate of the User"
         
     | 
| 
       111 
     | 
    
         
            -
                }
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
                PROXY={
         
     | 
| 
       114 
     | 
    
         
            -
                    :name => "proxy",
         
     | 
| 
       115 
     | 
    
         
            -
                    :large => "--proxy path_to_user_proxy_pem",
         
     | 
| 
       116 
     | 
    
         
            -
                    :format => String,
         
     | 
| 
       117 
     | 
    
         
            -
                    :description => "Path to the user proxy certificate"
         
     | 
| 
       118 
     | 
    
         
            -
                }
         
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
                TIME={
         
     | 
| 
       121 
     | 
    
         
            -
                    :name  => "time",
         
     | 
| 
       122 
     | 
    
         
            -
                    :large => "--time x",
         
     | 
| 
       123 
     | 
    
         
            -
                    :format => Integer,
         
     | 
| 
       124 
     | 
    
         
            -
                    :description => "Token duration in seconds, defaults to 36000 (10 h). "\
         
     | 
| 
       125 
     | 
    
         
            -
                                    "To reset the token set time to 0." \
         
     | 
| 
       126 
     | 
    
         
            -
                                    "To generate a non-expiring token use -1"\
         
     | 
| 
       127 
     | 
    
         
            -
                                    " (not valid for ssh and x509 tokens). "\
         
     | 
| 
       128 
     | 
    
         
            -
                }
         
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
                DRIVER={
         
     | 
| 
       131 
     | 
    
         
            -
                    :name => "driver",
         
     | 
| 
       132 
     | 
    
         
            -
                    :large => "--driver driver",
         
     | 
| 
       133 
     | 
    
         
            -
                    :format => String,
         
     | 
| 
       134 
     | 
    
         
            -
                    :description => "Driver to autehnticate this user"
         
     | 
| 
       135 
     | 
    
         
            -
                }
         
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
                FORCE = {
         
     | 
| 
       138 
     | 
    
         
            -
                    :name   => "force",
         
     | 
| 
       139 
     | 
    
         
            -
                    :large  => "--force" ,
         
     | 
| 
       140 
     | 
    
         
            -
                    :description => "Force one_auth file rewrite"
         
     | 
| 
       141 
     | 
    
         
            -
                }
         
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
                create_options = [READ_FILE, SHA1, SSH, X509, KEY, CERT, DRIVER]
         
     | 
| 
       144 
     | 
    
         
            -
                login_options  = [SSH, X509, X509_PROXY, KEY, CERT, PROXY, TIME, FORCE]
         
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
                ########################################################################
         
     | 
| 
       147 
     | 
    
         
            -
                # Formatters for arguments
         
     | 
| 
       148 
     | 
    
         
            -
                ########################################################################
         
     | 
| 
       149 
     | 
    
         
            -
                set :format, :groupid, OpenNebulaHelper.rname_to_id_desc("GROUP") do |arg|
         
     | 
| 
       150 
     | 
    
         
            -
                    OpenNebulaHelper.rname_to_id(arg, "GROUP")
         
     | 
| 
       151 
     | 
    
         
            -
                end
         
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
                set :format, :userid, OneUserHelper.to_id_desc do |arg|
         
     | 
| 
       154 
     | 
    
         
            -
                    helper.to_id(arg)
         
     | 
| 
       155 
     | 
    
         
            -
                end
         
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
                set :format, :userid_list, OneUserHelper.list_to_id_desc do |arg|
         
     | 
| 
       158 
     | 
    
         
            -
                    helper.list_to_id(arg)
         
     | 
| 
       159 
     | 
    
         
            -
                end
         
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
                set :format, :password, OneUserHelper.password_to_str_desc do |arg|
         
     | 
| 
       162 
     | 
    
         
            -
                    OneUserHelper.password_to_str(arg, options)
         
     | 
| 
       163 
     | 
    
         
            -
                end
         
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
                ########################################################################
         
     | 
| 
       166 
     | 
    
         
            -
                # Commands
         
     | 
| 
       167 
     | 
    
         
            -
                ########################################################################
         
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
                create_desc = <<-EOT.unindent
         
     | 
| 
       170 
     | 
    
         
            -
                    Creates a new User
         
     | 
| 
       171 
     | 
    
         
            -
                    Examples:
         
     | 
| 
       172 
     | 
    
         
            -
                      oneuser create my_user my_password
         
     | 
| 
       173 
     | 
    
         
            -
                      oneuser create my_user -r /tmp/mypass
         
     | 
| 
       174 
     | 
    
         
            -
                      oneuser create my_user --ssh --key /tmp/id_rsa
         
     | 
| 
       175 
     | 
    
         
            -
                      oneuser create my_user --ssh -r /tmp/public_key
         
     | 
| 
       176 
     | 
    
         
            -
                      oneuser create my_user --x509 --cert /tmp/my_cert.pem
         
     | 
| 
       177 
     | 
    
         
            -
                EOT
         
     | 
| 
       178 
     | 
    
         
            -
             
     | 
| 
       179 
     | 
    
         
            -
                command :create, create_desc, :username, [:password, nil],
         
     | 
| 
       180 
     | 
    
         
            -
                        :options=>create_options do
         
     | 
| 
       181 
     | 
    
         
            -
                    if args[1]
         
     | 
| 
       182 
     | 
    
         
            -
                        pass = args[1]
         
     | 
| 
       183 
     | 
    
         
            -
                    else
         
     | 
| 
       184 
     | 
    
         
            -
                        rc = helper.password(options)
         
     | 
| 
       185 
     | 
    
         
            -
                        if rc.first == 0
         
     | 
| 
       186 
     | 
    
         
            -
                            pass = rc[1]
         
     | 
| 
       187 
     | 
    
         
            -
                        else
         
     | 
| 
       188 
     | 
    
         
            -
                            exit_with_code *rc
         
     | 
| 
       189 
     | 
    
         
            -
                        end
         
     | 
| 
       190 
     | 
    
         
            -
                    end
         
     | 
| 
       191 
     | 
    
         
            -
             
     | 
| 
       192 
     | 
    
         
            -
                    driver = options[:driver] || OpenNebula::User::CORE_AUTH
         
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
       194 
     | 
    
         
            -
                    helper.create_resource(options) do |user|
         
     | 
| 
       195 
     | 
    
         
            -
                        user.allocate(args[0], pass, driver)
         
     | 
| 
       196 
     | 
    
         
            -
                    end
         
     | 
| 
       197 
     | 
    
         
            -
                end
         
     | 
| 
       198 
     | 
    
         
            -
             
     | 
| 
       199 
     | 
    
         
            -
                update_desc = <<-EOT.unindent
         
     | 
| 
       200 
     | 
    
         
            -
                    Update the template contents. If a path is not provided the editor will
         
     | 
| 
       201 
     | 
    
         
            -
                    be launched to modify the current content.
         
     | 
| 
       202 
     | 
    
         
            -
                EOT
         
     | 
| 
       203 
     | 
    
         
            -
             
     | 
| 
       204 
     | 
    
         
            -
                command :update, update_desc, :userid, [:file, nil],
         
     | 
| 
       205 
     | 
    
         
            -
                :options=>OpenNebulaHelper::APPEND do
         
     | 
| 
       206 
     | 
    
         
            -
                    helper.perform_action(args[0],options,"modified") do |obj|
         
     | 
| 
       207 
     | 
    
         
            -
                        if options[:append]
         
     | 
| 
       208 
     | 
    
         
            -
                            str = OpenNebulaHelper.append_template(args[0], obj, args[1])
         
     | 
| 
       209 
     | 
    
         
            -
                        else
         
     | 
| 
       210 
     | 
    
         
            -
                            str = OpenNebulaHelper.update_template(args[0], obj, args[1])
         
     | 
| 
       211 
     | 
    
         
            -
                        end
         
     | 
| 
       212 
     | 
    
         
            -
             
     | 
| 
       213 
     | 
    
         
            -
                        helper.set_client(options)
         
     | 
| 
       214 
     | 
    
         
            -
                        obj = helper.retrieve_resource(obj.id)
         
     | 
| 
       215 
     | 
    
         
            -
             
     | 
| 
       216 
     | 
    
         
            -
                        obj.update(str, options[:append])
         
     | 
| 
       217 
     | 
    
         
            -
                    end
         
     | 
| 
       218 
     | 
    
         
            -
                end
         
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
       220 
     | 
    
         
            -
                quota_desc = <<-EOT.unindent
         
     | 
| 
       221 
     | 
    
         
            -
                    Set the quota limits for the user. If a path is not provided the editor
         
     | 
| 
       222 
     | 
    
         
            -
                    will be launched to modify the current quotas.
         
     | 
| 
       223 
     | 
    
         
            -
                EOT
         
     | 
| 
       224 
     | 
    
         
            -
             
     | 
| 
       225 
     | 
    
         
            -
                command :quota, quota_desc, :userid, [:file, nil] do
         
     | 
| 
       226 
     | 
    
         
            -
                    helper.perform_action(args[0], options, "modified") do |user|
         
     | 
| 
       227 
     | 
    
         
            -
                        rc = user.info
         
     | 
| 
       228 
     | 
    
         
            -
             
     | 
| 
       229 
     | 
    
         
            -
                        if OpenNebula.is_error?(rc)
         
     | 
| 
       230 
     | 
    
         
            -
                            puts rc.message
         
     | 
| 
       231 
     | 
    
         
            -
                            exit -1
         
     | 
| 
       232 
     | 
    
         
            -
                        end
         
     | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
       234 
     | 
    
         
            -
                        str = OneQuotaHelper.set_quota(user, args[1])
         
     | 
| 
       235 
     | 
    
         
            -
             
     | 
| 
       236 
     | 
    
         
            -
                        helper.set_client(options)
         
     | 
| 
       237 
     | 
    
         
            -
                        user = helper.retrieve_resource(user.id)
         
     | 
| 
       238 
     | 
    
         
            -
             
     | 
| 
       239 
     | 
    
         
            -
                        rc  = user.set_quota(str)
         
     | 
| 
       240 
     | 
    
         
            -
             
     | 
| 
       241 
     | 
    
         
            -
                        if OpenNebula.is_error?(rc)
         
     | 
| 
       242 
     | 
    
         
            -
                            puts rc.message
         
     | 
| 
       243 
     | 
    
         
            -
                            exit -1
         
     | 
| 
       244 
     | 
    
         
            -
                        end
         
     | 
| 
       245 
     | 
    
         
            -
                    end
         
     | 
| 
       246 
     | 
    
         
            -
                end
         
     | 
| 
       247 
     | 
    
         
            -
             
     | 
| 
       248 
     | 
    
         
            -
                batchquota_desc = <<-EOT.unindent
         
     | 
| 
       249 
     | 
    
         
            -
                    Sets the quota limits in batch for various users. If a path is not
         
     | 
| 
       250 
     | 
    
         
            -
                    provided the editor will be launched to create new quotas.
         
     | 
| 
       251 
     | 
    
         
            -
                EOT
         
     | 
| 
       252 
     | 
    
         
            -
             
     | 
| 
       253 
     | 
    
         
            -
                command :batchquota, batchquota_desc, [:range, :userid_list],
         
     | 
| 
       254 
     | 
    
         
            -
                        [:file, nil] do
         
     | 
| 
       255 
     | 
    
         
            -
                    batch_str = OneQuotaHelper.get_batch_quota(args[1])
         
     | 
| 
       256 
     | 
    
         
            -
             
     | 
| 
       257 
     | 
    
         
            -
                    helper.perform_actions(args[0], options, "modified") do |user|
         
     | 
| 
       258 
     | 
    
         
            -
                        str = OneQuotaHelper.merge_quota(user, batch_str)
         
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
       260 
     | 
    
         
            -
                        if OpenNebula.is_error?(str)
         
     | 
| 
       261 
     | 
    
         
            -
                            str
         
     | 
| 
       262 
     | 
    
         
            -
                        else
         
     | 
| 
       263 
     | 
    
         
            -
                            helper.set_client(options)
         
     | 
| 
       264 
     | 
    
         
            -
                            user = helper.retrieve_resource(user.id)
         
     | 
| 
       265 
     | 
    
         
            -
             
     | 
| 
       266 
     | 
    
         
            -
                            rc  = user.set_quota(str)
         
     | 
| 
       267 
     | 
    
         
            -
                            rc
         
     | 
| 
       268 
     | 
    
         
            -
                        end
         
     | 
| 
       269 
     | 
    
         
            -
                    end
         
     | 
| 
       270 
     | 
    
         
            -
                end
         
     | 
| 
       271 
     | 
    
         
            -
             
     | 
| 
       272 
     | 
    
         
            -
                defaultquota_desc = <<-EOT.unindent
         
     | 
| 
       273 
     | 
    
         
            -
                    Sets the default quota limits for the users. If a path is not provided
         
     | 
| 
       274 
     | 
    
         
            -
                    the editor will be launched to modify the current default quotas.
         
     | 
| 
       275 
     | 
    
         
            -
                EOT
         
     | 
| 
       276 
     | 
    
         
            -
             
     | 
| 
       277 
     | 
    
         
            -
                command :defaultquota, defaultquota_desc, [:file, nil] do
         
     | 
| 
       278 
     | 
    
         
            -
                    system = System.new(OneUserHelper.get_client(options))
         
     | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
       280 
     | 
    
         
            -
                    default_quotas = system.get_user_quotas()
         
     | 
| 
       281 
     | 
    
         
            -
             
     | 
| 
       282 
     | 
    
         
            -
                    if OpenNebula.is_error?(default_quotas)
         
     | 
| 
       283 
     | 
    
         
            -
                        puts default_quotas.message
         
     | 
| 
       284 
     | 
    
         
            -
                        exit(-1)
         
     | 
| 
       285 
     | 
    
         
            -
                    end
         
     | 
| 
       286 
     | 
    
         
            -
             
     | 
| 
       287 
     | 
    
         
            -
                    str = OneQuotaHelper.set_quota(default_quotas, args[0], true)
         
     | 
| 
       288 
     | 
    
         
            -
             
     | 
| 
       289 
     | 
    
         
            -
                    system = System.new(OneUserHelper.get_client(options))
         
     | 
| 
       290 
     | 
    
         
            -
                    rc  = system.set_user_quotas(str)
         
     | 
| 
       291 
     | 
    
         
            -
             
     | 
| 
       292 
     | 
    
         
            -
                    if OpenNebula.is_error?(rc)
         
     | 
| 
       293 
     | 
    
         
            -
                        puts rc.message
         
     | 
| 
       294 
     | 
    
         
            -
                        exit(-1)
         
     | 
| 
       295 
     | 
    
         
            -
                    end
         
     | 
| 
       296 
     | 
    
         
            -
             
     | 
| 
       297 
     | 
    
         
            -
                    exit 0
         
     | 
| 
       298 
     | 
    
         
            -
                end
         
     | 
| 
       299 
     | 
    
         
            -
             
     | 
| 
       300 
     | 
    
         
            -
                umask_desc = <<-EOT.unindent
         
     | 
| 
       301 
     | 
    
         
            -
                    Changes the umask used to create the default permissions. In a similar
         
     | 
| 
       302 
     | 
    
         
            -
                    way to the Unix umask command, the expected value is a three-digit
         
     | 
| 
       303 
     | 
    
         
            -
                    base-8 number. Each digit is a mask that disables permissions for the
         
     | 
| 
       304 
     | 
    
         
            -
                    owner, group and other, respectively.
         
     | 
| 
       305 
     | 
    
         
            -
             
     | 
| 
       306 
     | 
    
         
            -
                    If mask is not given, or if it is an empty string, the umask will
         
     | 
| 
       307 
     | 
    
         
            -
                    be unset
         
     | 
| 
       308 
     | 
    
         
            -
                EOT
         
     | 
| 
       309 
     | 
    
         
            -
             
     | 
| 
       310 
     | 
    
         
            -
                command :umask, umask_desc, [:range, :userid_list], [:mask, nil] do
         
     | 
| 
       311 
     | 
    
         
            -
                    helper.perform_actions(args[0],options,
         
     | 
| 
       312 
     | 
    
         
            -
                            "umask changed") do |user|
         
     | 
| 
       313 
     | 
    
         
            -
             
     | 
| 
       314 
     | 
    
         
            -
                        rc = user.info
         
     | 
| 
       315 
     | 
    
         
            -
             
     | 
| 
       316 
     | 
    
         
            -
                        if OpenNebula.is_error?(rc)
         
     | 
| 
       317 
     | 
    
         
            -
                            puts rc.message
         
     | 
| 
       318 
     | 
    
         
            -
                            exit -1
         
     | 
| 
       319 
     | 
    
         
            -
                        end
         
     | 
| 
       320 
     | 
    
         
            -
             
     | 
| 
       321 
     | 
    
         
            -
                        user.delete_element('/USER/TEMPLATE/UMASK')
         
     | 
| 
       322 
     | 
    
         
            -
             
     | 
| 
       323 
     | 
    
         
            -
                        tmp_str = user.template_str
         
     | 
| 
       324 
     | 
    
         
            -
             
     | 
| 
       325 
     | 
    
         
            -
                        if !args[1].nil? && args[1] != ""
         
     | 
| 
       326 
     | 
    
         
            -
                            tmp_str << "\nUMASK = #{args[1]}"
         
     | 
| 
       327 
     | 
    
         
            -
                        end
         
     | 
| 
       328 
     | 
    
         
            -
             
     | 
| 
       329 
     | 
    
         
            -
                        user.update(tmp_str)
         
     | 
| 
       330 
     | 
    
         
            -
                    end
         
     | 
| 
       331 
     | 
    
         
            -
                end
         
     | 
| 
       332 
     | 
    
         
            -
             
     | 
| 
       333 
     | 
    
         
            -
                login_desc = <<-EOT.unindent
         
     | 
| 
       334 
     | 
    
         
            -
                    Creates the login token for authentication. The token can be used
         
     | 
| 
       335 
     | 
    
         
            -
                    together with any authentication driver. The token will be stored in
         
     | 
| 
       336 
     | 
    
         
            -
                    $HOME/.one/one_auth, and can be used subsequently to authenticate with
         
     | 
| 
       337 
     | 
    
         
            -
                    oned through API, CLI or Sunstone.
         
     | 
| 
       338 
     | 
    
         
            -
             
     | 
| 
       339 
     | 
    
         
            -
                    Example, request a valid token for a generic driver (e.g. core auth, LDAP...):
         
     | 
| 
       340 
     | 
    
         
            -
                      oneuser login my_user --time 3600
         
     | 
| 
       341 
     | 
    
         
            -
             
     | 
| 
       342 
     | 
    
         
            -
                    Example, generate and set a token for SSH based authentication:
         
     | 
| 
       343 
     | 
    
         
            -
                      oneuser login my_user --ssh --key /tmp/id_rsa --time 72000
         
     | 
| 
       344 
     | 
    
         
            -
             
     | 
| 
       345 
     | 
    
         
            -
                    Example, same using X509 certificates:
         
     | 
| 
       346 
     | 
    
         
            -
                      oneuser login my_user --x509 --cert /tmp/my_cert.pem
         
     | 
| 
       347 
     | 
    
         
            -
                                            --key /tmp/my_key.pk --time 72000
         
     | 
| 
       348 
     | 
    
         
            -
             
     | 
| 
       349 
     | 
    
         
            -
                    Example, now with a X509 proxy certificate
         
     | 
| 
       350 
     | 
    
         
            -
                      oneuser login my_user --x509_proxy --proxy /tmp/my_cert.pem
         
     | 
| 
       351 
     | 
    
         
            -
                                            --time 72000
         
     | 
| 
       352 
     | 
    
         
            -
                EOT
         
     | 
| 
       353 
     | 
    
         
            -
             
     | 
| 
       354 
     | 
    
         
            -
                command :login, login_desc, :username, :options=>login_options do
         
     | 
| 
       355 
     | 
    
         
            -
             
     | 
| 
       356 
     | 
    
         
            -
                    options[:time] ||= 36000
         
     | 
| 
       357 
     | 
    
         
            -
             
     | 
| 
       358 
     | 
    
         
            -
                    helper.login(args[0], options)
         
     | 
| 
       359 
     | 
    
         
            -
                end
         
     | 
| 
       360 
     | 
    
         
            -
             
     | 
| 
       361 
     | 
    
         
            -
                key_desc = <<-EOT.unindent
         
     | 
| 
       362 
     | 
    
         
            -
                    Shows a public key from a private SSH key. Use it as password
         
     | 
| 
       363 
     | 
    
         
            -
                    for the SSH authentication mechanism.
         
     | 
| 
       364 
     | 
    
         
            -
                EOT
         
     | 
| 
       365 
     | 
    
         
            -
             
     | 
| 
       366 
     | 
    
         
            -
                command :key, key_desc, :options=>[KEY] do
         
     | 
| 
       367 
     | 
    
         
            -
                    require 'opennebula/ssh_auth'
         
     | 
| 
       368 
     | 
    
         
            -
             
     | 
| 
       369 
     | 
    
         
            -
                    options[:key] ||= ENV['HOME']+'/.ssh/id_rsa'
         
     | 
| 
       370 
     | 
    
         
            -
             
     | 
| 
       371 
     | 
    
         
            -
                    begin
         
     | 
| 
       372 
     | 
    
         
            -
                        sshauth = SshAuth.new(:private_key=>options[:key])
         
     | 
| 
       373 
     | 
    
         
            -
                    rescue Exception => e
         
     | 
| 
       374 
     | 
    
         
            -
                        exit_with_code -1, e.message
         
     | 
| 
       375 
     | 
    
         
            -
                    end
         
     | 
| 
       376 
     | 
    
         
            -
             
     | 
| 
       377 
     | 
    
         
            -
                    puts sshauth.password
         
     | 
| 
       378 
     | 
    
         
            -
                    exit_with_code 0
         
     | 
| 
       379 
     | 
    
         
            -
                end
         
     | 
| 
       380 
     | 
    
         
            -
             
     | 
| 
       381 
     | 
    
         
            -
             
     | 
| 
       382 
     | 
    
         
            -
                delete_desc = <<-EOT.unindent
         
     | 
| 
       383 
     | 
    
         
            -
                    Deletes the given User
         
     | 
| 
       384 
     | 
    
         
            -
                EOT
         
     | 
| 
       385 
     | 
    
         
            -
             
     | 
| 
       386 
     | 
    
         
            -
                command :delete, delete_desc, [:range, :userid_list] do
         
     | 
| 
       387 
     | 
    
         
            -
                    helper.perform_actions(args[0], options, "deleted") do |user|
         
     | 
| 
       388 
     | 
    
         
            -
                        user.delete
         
     | 
| 
       389 
     | 
    
         
            -
                    end
         
     | 
| 
       390 
     | 
    
         
            -
                end
         
     | 
| 
       391 
     | 
    
         
            -
             
     | 
| 
       392 
     | 
    
         
            -
                passwd_desc = <<-EOT.unindent
         
     | 
| 
       393 
     | 
    
         
            -
                    Changes the given User's password
         
     | 
| 
       394 
     | 
    
         
            -
                EOT
         
     | 
| 
       395 
     | 
    
         
            -
             
     | 
| 
       396 
     | 
    
         
            -
                command :passwd, passwd_desc, :userid, [:password, nil],
         
     | 
| 
       397 
     | 
    
         
            -
                        :options=>create_options do
         
     | 
| 
       398 
     | 
    
         
            -
                    if args[1]
         
     | 
| 
       399 
     | 
    
         
            -
                        pass = args[1]
         
     | 
| 
       400 
     | 
    
         
            -
                    else
         
     | 
| 
       401 
     | 
    
         
            -
                        rc = helper.password(options)
         
     | 
| 
       402 
     | 
    
         
            -
                        if rc.first == 0
         
     | 
| 
       403 
     | 
    
         
            -
                            pass = rc[1]
         
     | 
| 
       404 
     | 
    
         
            -
                        else
         
     | 
| 
       405 
     | 
    
         
            -
                            exit_with_code *rc
         
     | 
| 
       406 
     | 
    
         
            -
                        end
         
     | 
| 
       407 
     | 
    
         
            -
                    end
         
     | 
| 
       408 
     | 
    
         
            -
             
     | 
| 
       409 
     | 
    
         
            -
                    helper.perform_action(args[0],options,"Password changed") do |user|
         
     | 
| 
       410 
     | 
    
         
            -
                        user.passwd(pass)
         
     | 
| 
       411 
     | 
    
         
            -
                    end
         
     | 
| 
       412 
     | 
    
         
            -
                end
         
     | 
| 
       413 
     | 
    
         
            -
             
     | 
| 
       414 
     | 
    
         
            -
                chgrp_desc = <<-EOT.unindent
         
     | 
| 
       415 
     | 
    
         
            -
                    Changes the User's primary group
         
     | 
| 
       416 
     | 
    
         
            -
                EOT
         
     | 
| 
       417 
     | 
    
         
            -
             
     | 
| 
       418 
     | 
    
         
            -
                command :chgrp, chgrp_desc, [:range, :userid_list], :groupid do
         
     | 
| 
       419 
     | 
    
         
            -
                    helper.perform_actions(args[0],options,"Group changed") do |user|
         
     | 
| 
       420 
     | 
    
         
            -
                        user.chgrp(args[1].to_i)
         
     | 
| 
       421 
     | 
    
         
            -
                    end
         
     | 
| 
       422 
     | 
    
         
            -
                end
         
     | 
| 
       423 
     | 
    
         
            -
             
     | 
| 
       424 
     | 
    
         
            -
                addgroup_desc = <<-EOT.unindent
         
     | 
| 
       425 
     | 
    
         
            -
                    Adds the User to a secondary group
         
     | 
| 
       426 
     | 
    
         
            -
                EOT
         
     | 
| 
       427 
     | 
    
         
            -
             
     | 
| 
       428 
     | 
    
         
            -
                command :addgroup, addgroup_desc, [:range, :userid_list], :groupid do
         
     | 
| 
       429 
     | 
    
         
            -
                    gid = args[1]
         
     | 
| 
       430 
     | 
    
         
            -
             
     | 
| 
       431 
     | 
    
         
            -
                    helper.perform_actions(args[0],options,"group added") do |user|
         
     | 
| 
       432 
     | 
    
         
            -
                        user.addgroup( gid )
         
     | 
| 
       433 
     | 
    
         
            -
                    end
         
     | 
| 
       434 
     | 
    
         
            -
                end
         
     | 
| 
       435 
     | 
    
         
            -
             
     | 
| 
       436 
     | 
    
         
            -
                delgroup_desc = <<-EOT.unindent
         
     | 
| 
       437 
     | 
    
         
            -
                    Removes the User from a secondary group
         
     | 
| 
       438 
     | 
    
         
            -
                EOT
         
     | 
| 
       439 
     | 
    
         
            -
             
     | 
| 
       440 
     | 
    
         
            -
                command :delgroup, delgroup_desc, [:range, :userid_list], :groupid do
         
     | 
| 
       441 
     | 
    
         
            -
                    gid = args[1]
         
     | 
| 
       442 
     | 
    
         
            -
             
     | 
| 
       443 
     | 
    
         
            -
                    helper.perform_actions(args[0],options,"group deleted") do |user|
         
     | 
| 
       444 
     | 
    
         
            -
                        user.delgroup( gid )
         
     | 
| 
       445 
     | 
    
         
            -
                    end
         
     | 
| 
       446 
     | 
    
         
            -
                end
         
     | 
| 
       447 
     | 
    
         
            -
             
     | 
| 
       448 
     | 
    
         
            -
                chauth_desc = <<-EOT.unindent
         
     | 
| 
       449 
     | 
    
         
            -
                    Changes the User's auth driver and its password (optional)
         
     | 
| 
       450 
     | 
    
         
            -
                    Examples:
         
     | 
| 
       451 
     | 
    
         
            -
                      oneuser chauth my_user core
         
     | 
| 
       452 
     | 
    
         
            -
                      oneuser chauth my_user core new_password
         
     | 
| 
       453 
     | 
    
         
            -
                      oneuser chauth my_user core -r /tmp/mypass
         
     | 
| 
       454 
     | 
    
         
            -
                      oneuser chauth my_user --ssh --key /home/oneadmin/.ssh/id_rsa
         
     | 
| 
       455 
     | 
    
         
            -
                      oneuser chauth my_user --ssh -r /tmp/public_key
         
     | 
| 
       456 
     | 
    
         
            -
                      oneuser chauth my_user --x509 --cert /tmp/my_cert.pem
         
     | 
| 
       457 
     | 
    
         
            -
                EOT
         
     | 
| 
       458 
     | 
    
         
            -
             
     | 
| 
       459 
     | 
    
         
            -
                command :chauth, chauth_desc, :userid, [:auth, nil], [:password, nil],
         
     | 
| 
       460 
     | 
    
         
            -
                        :options=>create_options do
         
     | 
| 
       461 
     | 
    
         
            -
                    if options[:driver]
         
     | 
| 
       462 
     | 
    
         
            -
                        driver = options[:driver]
         
     | 
| 
       463 
     | 
    
         
            -
                    elsif args[1]
         
     | 
| 
       464 
     | 
    
         
            -
                        driver = args[1]
         
     | 
| 
       465 
     | 
    
         
            -
                    else
         
     | 
| 
       466 
     | 
    
         
            -
                        exit_with_code 0, "An Auth driver should be specified"
         
     | 
| 
       467 
     | 
    
         
            -
                    end
         
     | 
| 
       468 
     | 
    
         
            -
             
     | 
| 
       469 
     | 
    
         
            -
                    if args[2]
         
     | 
| 
       470 
     | 
    
         
            -
                        pass = args[2]
         
     | 
| 
       471 
     | 
    
         
            -
                    else
         
     | 
| 
       472 
     | 
    
         
            -
                        rc = helper.password(options)
         
     | 
| 
       473 
     | 
    
         
            -
                        if rc.first == 0
         
     | 
| 
       474 
     | 
    
         
            -
                            pass = rc[1]
         
     | 
| 
       475 
     | 
    
         
            -
                        else
         
     | 
| 
       476 
     | 
    
         
            -
                            pass = ""
         
     | 
| 
       477 
     | 
    
         
            -
                        end
         
     | 
| 
       478 
     | 
    
         
            -
                    end
         
     | 
| 
       479 
     | 
    
         
            -
             
     | 
| 
       480 
     | 
    
         
            -
                    helper.perform_action(args[0],
         
     | 
| 
       481 
     | 
    
         
            -
                                        options,
         
     | 
| 
       482 
     | 
    
         
            -
                                        "Auth driver and password changed") do |user|
         
     | 
| 
       483 
     | 
    
         
            -
                        user.chauth(driver, pass)
         
     | 
| 
       484 
     | 
    
         
            -
                    end
         
     | 
| 
       485 
     | 
    
         
            -
                end
         
     | 
| 
       486 
     | 
    
         
            -
             
     | 
| 
       487 
     | 
    
         
            -
                list_desc = <<-EOT.unindent
         
     | 
| 
       488 
     | 
    
         
            -
                    Lists Users in the pool
         
     | 
| 
       489 
     | 
    
         
            -
                EOT
         
     | 
| 
       490 
     | 
    
         
            -
             
     | 
| 
       491 
     | 
    
         
            -
                command :list, list_desc, :options=>list_options do
         
     | 
| 
       492 
     | 
    
         
            -
                    helper.list_pool(options)
         
     | 
| 
       493 
     | 
    
         
            -
                end
         
     | 
| 
       494 
     | 
    
         
            -
             
     | 
| 
       495 
     | 
    
         
            -
                show_desc = <<-EOT.unindent
         
     | 
| 
       496 
     | 
    
         
            -
                    Shows information for the given User
         
     | 
| 
       497 
     | 
    
         
            -
                EOT
         
     | 
| 
       498 
     | 
    
         
            -
             
     | 
| 
       499 
     | 
    
         
            -
                command :show, show_desc, [:userid, nil],
         
     | 
| 
       500 
     | 
    
         
            -
                        :options=>OpenNebulaHelper::XML do
         
     | 
| 
       501 
     | 
    
         
            -
                    user=args[0] || OpenNebula::User::SELF
         
     | 
| 
       502 
     | 
    
         
            -
                    helper.show_resource(user,options)
         
     | 
| 
       503 
     | 
    
         
            -
                end
         
     | 
| 
       504 
     | 
    
         
            -
             
     | 
| 
       505 
     | 
    
         
            -
                show_desc = <<-EOT.unindent
         
     | 
| 
       506 
     | 
    
         
            -
                    Encodes user and password to use it with ldap
         
     | 
| 
       507 
     | 
    
         
            -
                EOT
         
     | 
| 
       508 
     | 
    
         
            -
             
     | 
| 
       509 
     | 
    
         
            -
                command :encode, show_desc, :username, [:password, nil] do
         
     | 
| 
       510 
     | 
    
         
            -
                    ar=args.compact
         
     | 
| 
       511 
     | 
    
         
            -
             
     | 
| 
       512 
     | 
    
         
            -
                    if defined?(URI::Parser)
         
     | 
| 
       513 
     | 
    
         
            -
                        parser=URI::Parser.new
         
     | 
| 
       514 
     | 
    
         
            -
                    else
         
     | 
| 
       515 
     | 
    
         
            -
                        parser=URI
         
     | 
| 
       516 
     | 
    
         
            -
                    end
         
     | 
| 
       517 
     | 
    
         
            -
             
     | 
| 
       518 
     | 
    
         
            -
                    puts ar.map{|a| parser.escape(a) }.join(':')
         
     | 
| 
       519 
     | 
    
         
            -
             
     | 
| 
       520 
     | 
    
         
            -
                    0
         
     | 
| 
       521 
     | 
    
         
            -
                end
         
     | 
| 
       522 
     | 
    
         
            -
            end
         
     |