This file is indexed.

/usr/bin/onezone is in opennebula 3.4.1-4.1ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env ruby

# -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
#                                                                            #
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
# not use this file except in compliance with the License. You may obtain    #
# a copy of the License at                                                   #
#                                                                            #
# http://www.apache.org/licenses/LICENSE-2.0                                 #
#                                                                            #
# Unless required by applicable law or agreed to in writing, software        #
# distributed under the License is distributed on an "AS IS" BASIS,          #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
# See the License for the specific language governing permissions and        #
# limitations under the License.                                             #
#--------------------------------------------------------------------------- #

ONE_LOCATION=ENV["ONE_LOCATION"]

if !ONE_LOCATION
    RUBY_LIB_LOCATION="/usr/lib/one/ruby"
else
    RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
end

$: << RUBY_LIB_LOCATION
$: << RUBY_LIB_LOCATION+"/cli"

require 'command_parser'
require 'ozones_helper/zones_helper.rb'


class Hash
  def self.transform_keys_to_strings(value)
    return value if not value.is_a?(Hash)
    hash = value.inject({}){|memo,(k,v)| memo[k.to_s] = Hash.transform_keys_to_strings(v); memo}
    return hash
  end
end

cmd=CommandParser::CmdParser.new(ARGV) do
    usage "`onezone` <command> [<args>] [<options>]"
    version OpenNebulaHelper::ONE_VERSION

    set :format, :zoneid, "Zone ID" do |arg|
        arg.match(/^[0123456789]+$/) ? [0,arg] : [-1]
    end

    ########################################################################
    # Global Options
    ########################################################################
    set :option, CommandParser::OPTIONS

    begin
        helper = ZonesHelper.new "zone"
    rescue Exception => e
        warn e.message
        exit -1
    end

    command :create, 'Create a new Zone', :file do
        helper.create_resource(args[0])
    end

    show_desc = <<-EOT.unindent
        Show information of a particular Zone
        Available resources: host, vm, image, vnet, vmtemplate,
                             user, cluster, datastore
        Examples:
          onezone show 4
          onezone show 4 host
    EOT

    command :show, show_desc, :zoneid, [:resource, nil],
    :options => OZonesHelper::JSON do
        zone = helper.show_resource(args[0],options)[1]

        #manually print here
        if options[:json]
            puts zone
        end

        if !args[1] then next 0 end

        case args[1]
        when "host"
            aux_helper  = OneHostHelper.new
        when "vm"
            aux_helper  = OneVMHelper.new
        when "image"
            aux_helper  = OneImageHelper.new
        when "vnet"
            aux_helper  = OneVNetHelper.new
        when "vmtemplate"
            aux_helper  = OneTemplateHelper.new
        when "user"
            aux_helper  = OneUserHelper.new
        when "cluster"
            aux_helper  = OneClusterHelper.new
        when "datastore"
            aux_helper  = OneDatastoreHelper.new
        else
            puts "\n:!: Pool #{args[1]} doesn't exist or is not supported\n\n"
            next 0
        end

        pool_hash_data = helper.get_resource_pool("zone", args[0], args[1],
                                                  options)
        if pool_hash_data[0] != 0
            puts "\nError retrieving information for pool #{args[1]}. Reason: " + pool_hash_data[1] + "\n\n"
            next 0
        end

        if !pool_hash_data[1]
            next 0
        end

        if options[:json]
            puts pool_hash_data[1]
            next 0
        end

        if pool_hash_data[1].is_a?(Hash)
            pool_hash_data[1]=[Hash.transform_keys_to_strings(pool_hash_data[1])]
        else
            pool_hash_data[1].each{|hash| hash.replace(Hash.transform_keys_to_strings(hash))}
        end

        puts
        str_h1="%-61s"
        CLIHelper.print_header(str_h1 % ["ZONE VIEW - #{args[1]}"],false)

        table = aux_helper.format_pool(options)
        table.show(pool_hash_data[1])

        0
    end

    command :list, 'Lists Zones in the pool', :options=>OZonesHelper::JSON do
        helper.list_pool(options)
    end

    command :delete, 'Deletes a Zone', :zoneid do
        helper.delete_resource(args[0],options)
    end
end