abiquo-etk 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.6.2
@@ -12,6 +12,10 @@ if ARGV[0] == 'set'
12
12
  load File.dirname(__FILE__) + "/set168.ext"
13
13
  elsif rel_info =~ /Version: 1\.8/
14
14
  load File.dirname(__FILE__) + "/set18.ext"
15
+ elsif rel_info =~ /Version: 2\.0/
16
+ load File.dirname(__FILE__) + "/set20.ext"
17
+ elsif rel_info =~ /Version: 2\.2/
18
+ load File.dirname(__FILE__) + "/set22.ext"
15
19
  else
16
20
  $stderr.puts "Abiquo release version not found. Unsupported installation."
17
21
  exit
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env ruby
2
+ require 'iniparse'
3
+ require 'uri'
4
+
5
+ if not File.directory? ABIQUO_BASE_DIR
6
+ $stderr.puts "\n'abicli set' command is used to configure the Abiquo Platform.\nUnfortunately, I can't find the Abiquo Platform installed in this server.\n\nTry other commands.\n\n"
7
+ help
8
+ exit 1
9
+ end
10
+
11
+ def set_database_host(val)
12
+ url = "jdbc:mysql://#{val}:3306/kinton?autoReconnect=true&useUnicode=true&characterEncoding=UTF8"
13
+ [TOMCAT_API_BUILTIN_CONFIG, TOMCAT_API_CONFIG].each do |f|
14
+ if File.exist?(f)
15
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'url', url, true)
16
+ end
17
+ end
18
+
19
+ [TOMCAT_SERVER_CONFIG, TOMCAT_SERVER_BUILTIN_CONFIG].each do |f|
20
+ if File.exist?(f)
21
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'url', url,true)
22
+ config_set_attribute(f, 'Resource[@name="jdbc/heartbeatDB"]', 'url', url, true)
23
+ end
24
+ end
25
+ set_property('server', 'abiquo.database.host', val)
26
+ end
27
+
28
+ def set_database_user(val)
29
+ [TOMCAT_API_BUILTIN_CONFIG, TOMCAT_API_CONFIG].each do |f|
30
+ if File.exist?(f)
31
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'username', val, true)
32
+ end
33
+ end
34
+ [TOMCAT_SERVER_CONFIG, TOMCAT_SERVER_BUILTIN_CONFIG].each do |f|
35
+ if File.exist?(f)
36
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'username', val, true)
37
+ config_set_attribute(f, 'Resource[@name="jdbc/heartbeatDB"]', 'username', val, true)
38
+ end
39
+ end
40
+ set_property('server', 'abiquo.database.user', val)
41
+ end
42
+
43
+ def set_database_password(val)
44
+ [TOMCAT_API_BUILTIN_CONFIG, TOMCAT_API_CONFIG].each do |f|
45
+ if File.exist?(f)
46
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'password', val, true)
47
+ end
48
+ end
49
+ [TOMCAT_SERVER_CONFIG, TOMCAT_SERVER_BUILTIN_CONFIG].each do |f|
50
+ if File.exist?(f)
51
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'password', val, true)
52
+ config_set_attribute(f, 'Resource[@name="jdbc/heartbeatDB"]', 'password', val, true)
53
+ end
54
+ end
55
+ set_property('server', 'abiquo.database.password', val)
56
+ end
57
+
58
+ def set_nfs_repository(val)
59
+ begin
60
+ nfs_url = val
61
+ if nfs_url !~ /^nfs:\/\//
62
+ nfs_url = "nfs://#{val}"
63
+ end
64
+ uri = URI.parse(nfs_url)
65
+ host = uri.host
66
+ path = uri.path
67
+ raise Exception.new if (path.nil? or host.nil?)
68
+ rescue
69
+ $stderr.puts 'ERROR: Invalid NFS/CIFS URI'
70
+ return
71
+ end
72
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
73
+ config.save('/opt/abiquo/config/abiquo.properties.bak')
74
+ config['remote-services']['abiquo.appliancemanager.repositoryLocation'] = val
75
+ config['remote-services']['abiquo.virtualfactory.xenserver.repositoryLocation'] = val
76
+ config.save('/opt/abiquo/config/abiquo.properties')
77
+ end
78
+
79
+ def set_cifs_repository(val)
80
+ begin
81
+ cifs_url = val
82
+ if cifs_url !~ /^cifs:/
83
+ cifs_url = "cifs:#{val}"
84
+ end
85
+ uri = URI.parse(cifs_url)
86
+ host = uri.host
87
+ path = uri.path
88
+ raise Exception.new if (path.nil? or host.nil?)
89
+ rescue
90
+ $stderr.puts 'ERROR: Invalid NFS/CIFS URI'
91
+ return
92
+ end
93
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
94
+ config.save('/opt/abiquo/config/abiquo.properties.bak')
95
+ cifs_uri = "//#{host}#{path}"
96
+ config['remote-services']['abiquo.virtualfactory.hyperv.repositoryLocation'] = cifs_uri
97
+ config.save('/opt/abiquo/config/abiquo.properties')
98
+ end
99
+
100
+ def set_aim_redis_host(val)
101
+ if not File.exist? '/etc/abiquo-aim.ini'
102
+ raise Exception.new('Abiquo AIM config file not available')
103
+ end
104
+ config = IniParse.parse(File.read('/etc/abiquo-aim.ini'))
105
+ config.save('/etc/abiquo-aim.ini.bak')
106
+ if config['monitor'].nil?
107
+ raise Exception.new('Invalid Abiquo AIM config file')
108
+ end
109
+ config['monitor']['redisHost'] = val
110
+ config.save('/etc/abiquo-aim.ini')
111
+ end
112
+
113
+ def set_ontap_user(val)
114
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
115
+ config['remote-services']['abiquo.storagemanager.netapp.user'] = val
116
+ config.save('/opt/abiquo/config/abiquo.properties')
117
+ end
118
+
119
+ def set_ontap_password(val)
120
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
121
+ config['remote-services']['abiquo.storagemanager.netapp.password'] = val
122
+ config.save('/opt/abiquo/config/abiquo.properties')
123
+ end
124
+
125
+ def set_property(section, key, val)
126
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
127
+ config.save('/opt/abiquo/config/abiquo.properties.bak')
128
+ config[section][key] = val
129
+ config.save('/opt/abiquo/config/abiquo.properties')
130
+ end
131
+
132
+ def get_property(section, key)
133
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
134
+ config[section][key] rescue nil
135
+ end
136
+
137
+ $command_mappings = {
138
+ 'rabbitmq-host' => Proc.new do |val|
139
+ if get_property('remote-services', 'abiquo.rabbitmq.host')
140
+ set_property('remote-services', 'abiquo.rabbitmq.host', val)
141
+ end
142
+ if get_property('server', 'abiquo.rabbitmq.host')
143
+ set_property('server', 'abiquo.rabbitmq.host', val)
144
+ end
145
+ end,
146
+ 'session-timeout' => ['server', 'sessionTimeout'],
147
+ 'mail-server' => ['server', 'mail/server'],
148
+ 'mail-server-user' => ['server', 'mail/user'],
149
+ 'mail-server-password' => ['server', 'mail/password'],
150
+ 'nfs-repository' => Proc.new { |val| set_nfs_repository(val) },
151
+ 'cifs-repository' => Proc.new do |val|
152
+ set_cifs_repository val
153
+ end,
154
+ 'storagelink-address' => Proc.new do |val|
155
+ if get_property 'remote-services', 'abiquo.virtualfactory.storagelink.address'
156
+ set_property('remote-services', 'abiquo.virtualfactory.storagelink.address', val)
157
+ end
158
+ end,
159
+ 'storagelink-user' => Proc.new do |val|
160
+ if get_property 'remote-services', 'abiquo.virtualfactory.storagelink.user'
161
+ set_property('remote-services', 'abiquo.virtualfactory.storagelink.user', val)
162
+ end
163
+ end,
164
+ 'storagelink-password' => Proc.new do |val|
165
+ if get_property 'remote-services', 'abiquo.virtualfactory.storagelink.password'
166
+ set_property('remote-services', 'abiquo.virtualfactory.storagelink.password', val)
167
+ end
168
+ end,
169
+ 'database-host' => Proc.new { |val| set_database_host(val) },
170
+ 'database-user' => Proc.new { |val| set_database_user(val) },
171
+ 'database-password' => Proc.new { |val| set_database_password(val) },
172
+ 'ontap-user' => Proc.new { |val| set_ontap_user(val) },
173
+ 'ontap-password' => Proc.new { |val| set_ontap_password(val) },
174
+ 'aim-redis-host' => Proc.new { |val| set_aim_redis_host(val) }
175
+ }
176
+
177
+ def mapping_exist?(key)
178
+ $command_mappings.has_key? key
179
+ end
180
+
181
+ def mapping_has_proc?(comp)
182
+ $command_mappings[comp].is_a? Proc
183
+ end
184
+
185
+ def help
186
+ puts "\nSet Abiquo Platform properties\n\n"
187
+ puts "Available subcommands:"
188
+ $command_mappings.keys.sort.each do |cmd,proc|
189
+ puts " #{cmd}"
190
+ end
191
+ end
192
+
193
+
194
+ comp = ARGV[1]
195
+ path = ARGV[2]
196
+ val = ARGV[3]
197
+ file = nil
198
+ begin
199
+ if mapping_exist? comp
200
+ val = path
201
+ if mapping_has_proc? comp
202
+ $command_mappings[comp].call(val)
203
+ else
204
+ comp, path = $command_mappings[comp]
205
+ end
206
+ else
207
+ help
208
+ end
209
+ rescue NoMethodError => e
210
+ $stderr.puts e.message
211
+ $stderr.puts e.backtrace
212
+ $stderr.puts "\nproperty not found in component #{comp.bold}\n\n"
213
+ rescue Exception => e
214
+ $stderr.puts e.message
215
+ end
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env ruby
2
+ require 'iniparse'
3
+ require 'uri'
4
+
5
+ if not File.directory? ABIQUO_BASE_DIR
6
+ $stderr.puts "\n'abicli set' command is used to configure the Abiquo Platform.\nUnfortunately, I can't find the Abiquo Platform installed in this server.\n\nTry other commands.\n\n"
7
+ help
8
+ exit 1
9
+ end
10
+
11
+ def set_database_host(val)
12
+ url = "jdbc:mysql://#{val}:3306/kinton?autoReconnect=true&useUnicode=true&characterEncoding=UTF8"
13
+ [TOMCAT_API_BUILTIN_CONFIG, TOMCAT_API_CONFIG].each do |f|
14
+ if File.exist?(f)
15
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'url', url, true)
16
+ end
17
+ end
18
+
19
+ [TOMCAT_SERVER_CONFIG, TOMCAT_SERVER_BUILTIN_CONFIG].each do |f|
20
+ if File.exist?(f)
21
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'url', url,true)
22
+ config_set_attribute(f, 'Resource[@name="jdbc/heartbeatDB"]', 'url', url, true)
23
+ end
24
+ end
25
+ set_property('server', 'abiquo.database.host', val)
26
+ end
27
+
28
+ def set_database_user(val)
29
+ [TOMCAT_API_BUILTIN_CONFIG, TOMCAT_API_CONFIG].each do |f|
30
+ if File.exist?(f)
31
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'username', val, true)
32
+ end
33
+ end
34
+ [TOMCAT_SERVER_CONFIG, TOMCAT_SERVER_BUILTIN_CONFIG].each do |f|
35
+ if File.exist?(f)
36
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'username', val, true)
37
+ config_set_attribute(f, 'Resource[@name="jdbc/heartbeatDB"]', 'username', val, true)
38
+ end
39
+ end
40
+ set_property('server', 'abiquo.database.user', val)
41
+ end
42
+
43
+ def set_database_password(val)
44
+ [TOMCAT_API_BUILTIN_CONFIG, TOMCAT_API_CONFIG].each do |f|
45
+ if File.exist?(f)
46
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'password', val, true)
47
+ end
48
+ end
49
+ [TOMCAT_SERVER_CONFIG, TOMCAT_SERVER_BUILTIN_CONFIG].each do |f|
50
+ if File.exist?(f)
51
+ config_set_attribute(f, 'Resource[@name="jdbc/abiquoDB"]', 'password', val, true)
52
+ config_set_attribute(f, 'Resource[@name="jdbc/heartbeatDB"]', 'password', val, true)
53
+ end
54
+ end
55
+ set_property('server', 'abiquo.database.password', val)
56
+ end
57
+
58
+ def set_nfs_repository(val)
59
+ begin
60
+ nfs_url = val
61
+ if nfs_url !~ /^nfs:\/\//
62
+ nfs_url = "nfs://#{val}"
63
+ end
64
+ uri = URI.parse(nfs_url)
65
+ host = uri.host
66
+ path = uri.path
67
+ raise Exception.new if (path.nil? or host.nil?)
68
+ rescue
69
+ $stderr.puts 'ERROR: Invalid NFS/CIFS URI'
70
+ return
71
+ end
72
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
73
+ config.save('/opt/abiquo/config/abiquo.properties.bak')
74
+ config['remote-services']['abiquo.appliancemanager.repositoryLocation'] = val
75
+ config['remote-services']['abiquo.virtualfactory.xenserver.repositoryLocation'] = val
76
+ config.save('/opt/abiquo/config/abiquo.properties')
77
+ end
78
+
79
+ def set_cifs_repository(val)
80
+ begin
81
+ cifs_url = val
82
+ if cifs_url !~ /^cifs:/
83
+ cifs_url = "cifs:#{val}"
84
+ end
85
+ uri = URI.parse(cifs_url)
86
+ host = uri.host
87
+ path = uri.path
88
+ raise Exception.new if (path.nil? or host.nil?)
89
+ rescue
90
+ $stderr.puts 'ERROR: Invalid NFS/CIFS URI'
91
+ return
92
+ end
93
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
94
+ config.save('/opt/abiquo/config/abiquo.properties.bak')
95
+ cifs_uri = "//#{host}#{path}"
96
+ config['remote-services']['abiquo.virtualfactory.hyperv.repositoryLocation'] = cifs_uri
97
+ config.save('/opt/abiquo/config/abiquo.properties')
98
+ end
99
+
100
+ def set_aim_redis_host(val)
101
+ if not File.exist? '/etc/abiquo-aim.ini'
102
+ raise Exception.new('Abiquo AIM config file not available')
103
+ end
104
+ config = IniParse.parse(File.read('/etc/abiquo-aim.ini'))
105
+ config.save('/etc/abiquo-aim.ini.bak')
106
+ if config['monitor'].nil?
107
+ raise Exception.new('Invalid Abiquo AIM config file')
108
+ end
109
+ config['monitor']['redisHost'] = val
110
+ config.save('/etc/abiquo-aim.ini')
111
+ end
112
+
113
+ def set_ontap_user(val)
114
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
115
+ config['remote-services']['abiquo.storagemanager.netapp.user'] = val
116
+ config.save('/opt/abiquo/config/abiquo.properties')
117
+ end
118
+
119
+ def set_ontap_password(val)
120
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
121
+ config['remote-services']['abiquo.storagemanager.netapp.password'] = val
122
+ config.save('/opt/abiquo/config/abiquo.properties')
123
+ end
124
+
125
+ def set_property(section, key, val)
126
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
127
+ config.save('/opt/abiquo/config/abiquo.properties.bak')
128
+ config[section][key] = val
129
+ config.save('/opt/abiquo/config/abiquo.properties')
130
+ end
131
+
132
+ def get_property(section, key)
133
+ config = IniParse.parse(File.read('/opt/abiquo/config/abiquo.properties'))
134
+ config[section][key] rescue nil
135
+ end
136
+
137
+ $command_mappings = {
138
+ 'rabbitmq-host' => Proc.new do |val|
139
+ if get_property('remote-services', 'abiquo.rabbitmq.host')
140
+ set_property('remote-services', 'abiquo.rabbitmq.host', val)
141
+ end
142
+ if get_property('server', 'abiquo.rabbitmq.host')
143
+ set_property('server', 'abiquo.rabbitmq.host', val)
144
+ end
145
+ end,
146
+ 'session-timeout' => ['server', 'sessionTimeout'],
147
+ 'mail-server' => ['server', 'mail/server'],
148
+ 'mail-server-user' => ['server', 'mail/user'],
149
+ 'mail-server-password' => ['server', 'mail/password'],
150
+ 'nfs-repository' => Proc.new { |val| set_nfs_repository(val) },
151
+ 'cifs-repository' => Proc.new do |val|
152
+ set_cifs_repository val
153
+ end,
154
+ 'storagelink-address' => Proc.new do |val|
155
+ if get_property 'remote-services', 'abiquo.virtualfactory.storagelink.address'
156
+ set_property('remote-services', 'abiquo.virtualfactory.storagelink.address', val)
157
+ end
158
+ end,
159
+ 'storagelink-user' => Proc.new do |val|
160
+ if get_property 'remote-services', 'abiquo.virtualfactory.storagelink.user'
161
+ set_property('remote-services', 'abiquo.virtualfactory.storagelink.user', val)
162
+ end
163
+ end,
164
+ 'storagelink-password' => Proc.new do |val|
165
+ if get_property 'remote-services', 'abiquo.virtualfactory.storagelink.password'
166
+ set_property('remote-services', 'abiquo.virtualfactory.storagelink.password', val)
167
+ end
168
+ end,
169
+ 'database-host' => Proc.new { |val| set_database_host(val) },
170
+ 'database-user' => Proc.new { |val| set_database_user(val) },
171
+ 'database-password' => Proc.new { |val| set_database_password(val) },
172
+ 'ontap-user' => Proc.new { |val| set_ontap_user(val) },
173
+ 'ontap-password' => Proc.new { |val| set_ontap_password(val) },
174
+ 'aim-redis-host' => Proc.new { |val| set_aim_redis_host(val) }
175
+ }
176
+
177
+ def mapping_exist?(key)
178
+ $command_mappings.has_key? key
179
+ end
180
+
181
+ def mapping_has_proc?(comp)
182
+ $command_mappings[comp].is_a? Proc
183
+ end
184
+
185
+ def help
186
+ puts "\nSet Abiquo Platform properties\n\n"
187
+ puts "Available subcommands:"
188
+ $command_mappings.keys.sort.each do |cmd,proc|
189
+ puts " #{cmd}"
190
+ end
191
+ end
192
+
193
+
194
+ comp = ARGV[1]
195
+ path = ARGV[2]
196
+ val = ARGV[3]
197
+ file = nil
198
+ begin
199
+ if mapping_exist? comp
200
+ val = path
201
+ if mapping_has_proc? comp
202
+ $command_mappings[comp].call(val)
203
+ else
204
+ comp, path = $command_mappings[comp]
205
+ end
206
+ else
207
+ help
208
+ end
209
+ rescue NoMethodError => e
210
+ $stderr.puts e.message
211
+ $stderr.puts e.backtrace
212
+ $stderr.puts "\nproperty not found in component #{comp.bold}\n\n"
213
+ rescue Exception => e
214
+ $stderr.puts e.message
215
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abiquo-etk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 1
10
- version: 0.6.1
9
+ - 2
10
+ version: 0.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Rubio
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-14 00:00:00 Z
18
+ date: 2012-07-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: nokogiri
@@ -96,8 +96,8 @@ dependencies:
96
96
  description: Tools to troubleshoot and manage your Abiquo installation
97
97
  email: srubio@abiquo.com
98
98
  executables:
99
- - abiquo-check-install
100
99
  - ciab-setup
100
+ - abiquo-check-install
101
101
  - abiquo-check-16-install
102
102
  - abicli
103
103
  extensions: []
@@ -131,6 +131,8 @@ files:
131
131
  - lib/abicli/commands/set168.ext
132
132
  - lib/abicli/commands/set17.ext
133
133
  - lib/abicli/commands/set18.ext
134
+ - lib/abicli/commands/set20.ext
135
+ - lib/abicli/commands/set22.ext
134
136
  - lib/abicli/commands/smoketest.rb
135
137
  - lib/abicli/commands/upload-template.rb
136
138
  - lib/abicli/commands/version.rb