opennebula-cli 4.4.0 → 4.5.80.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09217c63aeee7abd11ea62bbce95d89aebf56bbf
4
- data.tar.gz: d7f49893d15771de27179a3abbdf5df268b2f395
3
+ metadata.gz: 0d0a7a6d4a5861896dcea19d5bd0901864e93cf8
4
+ data.tar.gz: 3348c3fbf038afce1e154ed5d17cf94819c663a1
5
5
  SHA512:
6
- metadata.gz: 9c3429402c0d4d1dddc85d22d31318b6572839b54f87383f42c7e96c6708e90b3d6d689a7ad4e0cf9372fcd44416d8c191387cedd82ad9e1892fcc629e805f72
7
- data.tar.gz: 939acfc80e9e32485bcebbec3944f77b059ad1e4344bce722fc79dfa75df8234a84b7747a1ad319174e050fcd4fa4e67d2f00f60f485ef12386545ca2f56d848
6
+ metadata.gz: 30d8c96ff0feaffd28f8c13a180d4118e40e12c95f994d4336d72efff7a6fb2f58cd69aa28bb9955c17bba52d51e8c2a95386d33f2777e5997151279c2c94c89
7
+ data.tar.gz: 3f283c2538ee84ff6f5d4341f8b9f0ff854731de9e358489f73a9be7ba7a6a69dc7573b3340101ea12ae4ed3810c21944d4510a0863db77a1ad0193a89daf3c5
data/NOTICE CHANGED
@@ -1,6 +1,6 @@
1
1
  OpenNebula Open Source Project
2
2
  --------------------------------------------------------------------------------
3
- Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
3
+ Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs
4
4
  --------------------------------------------------------------------------------
5
5
 
6
6
  You can find more information about the project, release notes and
data/bin/oneacct CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -44,9 +44,15 @@ cmd = CommandParser::CmdParser.new(ARGV) do
44
44
  end
45
45
 
46
46
  option AcctHelper::ACCT_OPTIONS + CommandParser::OPTIONS +
47
+ [OpenNebulaHelper::DESCRIBE, CLIHelper::LIST, CLIHelper::CSV] +
47
48
  OpenNebulaHelper::CLIENT_OPTIONS
48
49
 
49
50
  main do
51
+ if options[:describe]
52
+ AcctHelper::ACCT_TABLE.describe_columns
53
+ exit(0)
54
+ end
55
+
50
56
  filter_flag = (options[:userfilter] || VirtualMachinePool::INFO_ALL)
51
57
  start_time = options[:start_time] ? options[:start_time].to_i : -1
52
58
  end_time = options[:end_time] ? options[:end_time].to_i : -1
@@ -81,7 +87,10 @@ cmd = CommandParser::CmdParser.new(ARGV) do
81
87
  else
82
88
  order_by = Hash.new
83
89
  order_by[:order_by_1] = 'VM/UID'
84
- order_by[:order_by_2] = 'VM/ID' if options[:split]
90
+
91
+ if options[:split] && !options[:csv]
92
+ order_by[:order_by_2] = 'VM/ID'
93
+ end
85
94
 
86
95
  acct_hash = pool.accounting(filter_flag,
87
96
  common_opts.merge(order_by))
@@ -90,6 +99,21 @@ cmd = CommandParser::CmdParser.new(ARGV) do
90
99
  exit -1
91
100
  end
92
101
 
102
+ if options[:csv]
103
+ a=Array.new
104
+ acct_hash.each do |user_id, value|
105
+ value['HISTORY_RECORDS']['HISTORY'].each do |l|
106
+ l['UID']=user_id
107
+ a << l
108
+ end
109
+ end
110
+
111
+ cols=AcctHelper::ACCT_TABLE.default_columns
112
+ AcctHelper::ACCT_TABLE.default(:UID, *cols)
113
+
114
+ AcctHelper::ACCT_TABLE.show(a, options)
115
+ exit(0)
116
+ end
93
117
 
94
118
  if ( start_time != -1 or end_time != -1 )
95
119
  AcctHelper.print_start_end_time_header(start_time, end_time)
@@ -102,13 +126,13 @@ cmd = CommandParser::CmdParser.new(ARGV) do
102
126
  # Use one table for each VM
103
127
  value.each { |vm_id, history_array|
104
128
  array = history_array['HISTORY_RECORDS']['HISTORY']
105
- AcctHelper::ACCT_TABLE.show(array)
129
+ AcctHelper::ACCT_TABLE.show(array, options)
106
130
  puts
107
131
  }
108
132
  else
109
133
  # Use the same table for all the VMs
110
134
  array = value['HISTORY_RECORDS']['HISTORY']
111
- AcctHelper::ACCT_TABLE.show(array)
135
+ AcctHelper::ACCT_TABLE.show(array, options)
112
136
  puts
113
137
  end
114
138
  }
data/bin/oneacl CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -69,10 +69,10 @@ cmd = CommandParser::CmdParser.new(ARGV) do
69
69
  if OpenNebula.is_error?(new_args)
70
70
  next -1, new_args.message
71
71
  end
72
- when 3
72
+ when 3, 4
73
73
  new_args=args
74
74
  else
75
- next -1, "Wrong number of arguments, must be 1 or 3"
75
+ next -1, "Wrong number of arguments, must be 1 or 4"
76
76
  end
77
77
 
78
78
  helper.create_resource(options) do |rule|
data/bin/onecluster CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onedatastore CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/oneflow CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2010-2013, C12G Labs S.L. #
4
+ # Copyright 2010-2014, C12G Labs S.L. #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/oneflow-template CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2010-2013, C12G Labs S.L. #
4
+ # Copyright 2010-2014, C12G Labs S.L. #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onegroup CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -61,20 +61,89 @@ cmd=CommandParser::CmdParser.new(ARGV) do
61
61
  helper.list_to_id(arg)
62
62
  end
63
63
 
64
+ set :format, :clusterid, OpenNebulaHelper.rname_to_id_desc("CLUSTER") do |arg|
65
+ OpenNebulaHelper.rname_to_id(arg, "CLUSTER")
66
+ end
67
+
68
+ set :format, :zoneid, OpenNebulaHelper.rname_to_id_desc("ZONE") do |arg|
69
+ OpenNebulaHelper.rname_to_id(arg, "ZONE")
70
+ end
71
+
64
72
  ########################################################################
65
73
  # Commands
66
74
  ########################################################################
67
75
 
68
76
  create_desc = <<-EOT.unindent
69
- Creates a new Group
77
+ Creates a new Group. A group name can be passed as the only argument,
78
+ or a file containing a group template or via command line arguments
79
+
80
+ Examples:
81
+
82
+ - using a template description file:
83
+
84
+ onegroup create group_description.tmpl
85
+
86
+ - create a group with admin group, admin user and allow group users
87
+ to only create new templates and VMs, and group admins to manage
88
+ templates, vms, images and virtual networks
89
+
90
+ onegroup create --name groupA --admin_group admin_groupA
91
+ --admin_user admin_userA --admin_password somestr
92
+ --resource TEMPLATE+VM
93
+ --admin_resources TEMPLATE+VM+IMAGE+NET
94
+
70
95
  EOT
71
96
 
72
- command :create, create_desc, :name do
73
- helper.create_resource(options) do |group|
74
- group.allocate(args[0])
97
+ command :create, create_desc, [:group_name, nil], :options =>
98
+ OpenNebulaHelper::GROUP_OPTIONS do
99
+
100
+
101
+ if !args[0] && options.empty?
102
+ STDERR.puts "Please use either a group name or command arguments"
103
+ next -1
104
+ end
105
+
106
+ if options && options[:admin_user]
107
+ if !options[:admin_password]
108
+ STDERR.puts "Admin user needs password"
109
+ next -1
110
+ end
111
+
112
+ admin_user=Hash.new
113
+ admin_user[:name] = options[:admin_user]
114
+ admin_user[:password] = options[:admin_password]
115
+ if options[:admin_driver]
116
+ admin_user[:auth_driver] = options[:admin_driver]
117
+ end
118
+ options[:user] = admin_user
119
+ end
120
+
121
+ if !options.empty?
122
+ helper.create_complete_resource(options)
123
+ elsif args[0]
124
+ options[:name] = args[0]
125
+ helper.create_complete_resource(options)
75
126
  end
76
127
  end
77
128
 
129
+ update_desc = <<-EOT.unindent
130
+ Update the template contents. If a path is not provided the editor will
131
+ be launched to modify the current content.
132
+ EOT
133
+
134
+ command :update, update_desc, :groupid, [:file, nil],
135
+ :options=>OpenNebulaHelper::APPEND do
136
+ helper.perform_action(args[0],options,"modified") do |obj|
137
+ if options[:append]
138
+ str = OpenNebulaHelper.append_template(args[0], obj, args[1])
139
+ else
140
+ str = OpenNebulaHelper.update_template(args[0], obj, args[1])
141
+ end
142
+
143
+ obj.update(str, options[:append])
144
+ end
145
+ end
146
+
78
147
  delete_desc = <<-EOT.unindent
79
148
  Deletes the given Group
80
149
  EOT
@@ -174,4 +243,33 @@ cmd=CommandParser::CmdParser.new(ARGV) do
174
243
 
175
244
  exit 0
176
245
  end
246
+
247
+ add_provider_desc = <<-EOT.unindent
248
+ Adds a resource provider (cluster of a zone) to the given group.
249
+ clusterid can be set to ALL
250
+ EOT
251
+
252
+ command :add_provider, add_provider_desc, [:range, :groupid_list], :zoneid, :clusterid do
253
+ if args[2] and args[2].class != Fixnum and args[2].upcase == "ALL"
254
+ args[2]=10
255
+ end
256
+
257
+ helper.perform_actions(args[0],options,"resource provider added") do |obj|
258
+ obj.add_provider(args[1].to_i, args[2].to_i)
259
+ end
260
+ end
261
+
262
+ del_provider_desc = <<-EOT.unindent
263
+ Deletes a resource provider (cluster of a zone) from the given group
264
+ clusterid can be set to ALL
265
+ EOT
266
+
267
+ command :del_provider, del_provider_desc, [:range, :groupid_list], :zoneid, :clusterid do
268
+ if args[2] and args[2].class != Fixnum and args[2].upcase == "ALL"
269
+ args[2]=10
270
+ end
271
+ helper.perform_actions(args[0],options,"resource provider deleted") do |obj|
272
+ obj.del_provider(args[1].to_i, args[2].to_i)
273
+ end
274
+ end
177
275
  end
data/bin/onehost CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -20,7 +20,7 @@ ONE_LOCATION=ENV["ONE_LOCATION"]
20
20
 
21
21
  if !ONE_LOCATION
22
22
  RUBY_LIB_LOCATION="/usr/lib/one/ruby"
23
- REMOTES_LOCATION="/var/lib/one/remotes"
23
+ REMOTES_LOCATION="/var/lib/one/remotes/"
24
24
  else
25
25
  RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
26
26
  REMOTES_LOCATION=ONE_LOCATION+"/var/remotes/"
data/bin/oneimage CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onetemplate CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/oneuser CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -40,7 +40,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
40
40
  helper = OneUserHelper.new
41
41
 
42
42
  before_proc do
43
- helper.set_client(options)
43
+ helper.set_client(options) if @comm_name != :login
44
44
  end
45
45
 
46
46
  ########################################################################
data/bin/onevm CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onevnet CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
data/bin/onezone ADDED
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # -------------------------------------------------------------------------- #
4
+ # Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
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/onezone_helper'
32
+
33
+ cmd=CommandParser::CmdParser.new(ARGV) do
34
+ usage "`onezone` <command> [<args>] [<options>]"
35
+ version OpenNebulaHelper::ONE_VERSION
36
+
37
+ helper = OneZoneHelper.new
38
+
39
+ before_proc do
40
+ helper.set_client(options)
41
+ end
42
+
43
+ ########################################################################
44
+ # Global Options
45
+ ########################################################################
46
+ set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
47
+
48
+ list_options = CLIHelper::OPTIONS
49
+ list_options << OpenNebulaHelper::XML
50
+ list_options << OpenNebulaHelper::NUMERIC
51
+ list_options << OpenNebulaHelper::DESCRIBE
52
+
53
+ ########################################################################
54
+ # Formatters for arguments
55
+ ########################################################################
56
+ set :format, :zoneid, OneZoneHelper.to_id_desc do |arg|
57
+ helper.to_id(arg)
58
+ end
59
+
60
+ set :format, :zoneid_list, OneZoneHelper.list_to_id_desc do |arg|
61
+ helper.list_to_id(arg)
62
+ end
63
+
64
+ ########################################################################
65
+ # Commands
66
+ ########################################################################
67
+
68
+ create_desc = <<-EOT.unindent
69
+ Creates a new Zone
70
+ EOT
71
+
72
+ command :create, create_desc, :file do
73
+ helper.create_resource(options) do |zone|
74
+ begin
75
+ template = File.read(args[0])
76
+ zone.allocate(template)
77
+ rescue => e
78
+ STDERR.puts e.message
79
+ exit -1
80
+ end
81
+ end
82
+ end
83
+
84
+ rename_desc = <<-EOT.unindent
85
+ Renames the Zone
86
+ EOT
87
+
88
+ command :rename, rename_desc, :zoneid, :name do
89
+ helper.perform_action(args[0],options,"renamed") do |o|
90
+ o.rename(args[1])
91
+ end
92
+ end
93
+
94
+ update_desc = <<-EOT.unindent
95
+ Update the template contents. If a path is not provided the editor will
96
+ be launched to modify the current content.
97
+ EOT
98
+
99
+ command :update, update_desc, :zoneid, [:file, nil],
100
+ :options=>OpenNebulaHelper::APPEND do
101
+ helper.perform_action(args[0],options,"modified") do |obj|
102
+ if options[:append]
103
+ str = OpenNebulaHelper.append_template(args[0], obj, args[1])
104
+ else
105
+ str = OpenNebulaHelper.update_template(args[0], obj, args[1])
106
+ end
107
+
108
+ obj.update(str, options[:append])
109
+ end
110
+ end
111
+
112
+ delete_desc = <<-EOT.unindent
113
+ Deletes the given Zone
114
+ EOT
115
+
116
+ command :delete, delete_desc, [:range, :zoneid_list] do
117
+ helper.perform_actions(args[0],options,"deleted") do |obj|
118
+ obj.delete
119
+ end
120
+ end
121
+
122
+ list_desc = <<-EOT.unindent
123
+ Lists Zones in the pool
124
+ EOT
125
+
126
+ command :list, list_desc, :options=>list_options do
127
+ helper.list_pool(options)
128
+ end
129
+
130
+ show_desc = <<-EOT.unindent
131
+ Shows information for the given Zone
132
+ EOT
133
+
134
+ command :show, show_desc,:zoneid, :options=>OpenNebulaHelper::XML do
135
+ helper.show_resource(args[0],options)
136
+ end
137
+
138
+ set_desc = <<-EOT.unindent
139
+ Set shell session access point for the CLI to the given Zone
140
+ EOT
141
+
142
+ command :set, set_desc,:zoneid do
143
+ helper.set_zone(args[0])
144
+ end
145
+ end