vgh 0.2.0 → 0.2.1
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.
- data/CHANGELOG.rdoc +3 -0
- data/lib/vgh/ec2/snapshot.rb +1 -1
- data/lib/vgh/system/lvm.rb +8 -32
- data/lib/vgh/system/mysql.rb +19 -8
- data/lib/vgh/version.rb +1 -1
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
data/lib/vgh/ec2/snapshot.rb
CHANGED
data/lib/vgh/system/lvm.rb
CHANGED
@@ -19,11 +19,6 @@ module System
|
|
19
19
|
#
|
20
20
|
class LVM
|
21
21
|
|
22
|
-
# Loads variables and checks if LVM Tools are installed
|
23
|
-
def initialize
|
24
|
-
installed?
|
25
|
-
end
|
26
|
-
|
27
22
|
# @return [String] The dmsetup system command
|
28
23
|
def dm_cmd
|
29
24
|
@dmcmd ||= '/sbin/dmsetup'
|
@@ -41,46 +36,27 @@ class LVM
|
|
41
36
|
|
42
37
|
# @return [String] A list of logical volumes present
|
43
38
|
def lvs
|
39
|
+
@lvs = []
|
44
40
|
if ( installed? and System.is_root? )
|
45
|
-
|
41
|
+
lv_list = `#{dm_cmd} ls | /bin/grep -E -v 'swap|root'`
|
42
|
+
@lvs.push(lv_list.split[0]) unless lv_list == "No devices found\n"
|
46
43
|
else
|
47
44
|
message.warn "Listing logical volume needs root privileges!"
|
48
|
-
return nil
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Test if logical volumes are present
|
53
|
-
# @return [Boolean]
|
54
|
-
def lvs_are_present?
|
55
|
-
if lvs != "No devices found\n" then
|
56
|
-
return true
|
57
|
-
else
|
58
|
-
message.info "No logical volumes found."
|
59
|
-
return false
|
60
45
|
end
|
61
|
-
|
62
|
-
|
63
|
-
# Suspend all logical volume
|
64
|
-
def suspend
|
65
|
-
suspend_lvs if lvs_are_present?
|
46
|
+
return @lvs
|
66
47
|
end
|
67
48
|
|
68
49
|
# The actual suspend action
|
69
|
-
def
|
70
|
-
for lv_name in lvs
|
50
|
+
def suspend
|
51
|
+
for lv_name in lvs
|
71
52
|
message.info "Suspending Logical Volume '#{lv_name}'..."
|
72
53
|
`#{dm_cmd} suspend #{lv_name}`
|
73
54
|
end
|
74
55
|
end
|
75
56
|
|
76
|
-
# Resume all logical volumes
|
77
|
-
def resume
|
78
|
-
resume_lvs if lvs_are_present?
|
79
|
-
end
|
80
|
-
|
81
57
|
# The actual resume action
|
82
|
-
def
|
83
|
-
for lv_name in lvs
|
58
|
+
def resume
|
59
|
+
for lv_name in lvs
|
84
60
|
message.info "Resuming Logical Volume '#{lv_name}'..."
|
85
61
|
`#{dm_cmd} resume #{lv_name}`
|
86
62
|
end
|
data/lib/vgh/system/mysql.rb
CHANGED
@@ -16,8 +16,8 @@ class MySQL
|
|
16
16
|
|
17
17
|
# Load defaults
|
18
18
|
def initialize
|
19
|
-
@
|
20
|
-
@
|
19
|
+
@mysqladmin_cmd = '/usr/bin/mysqladmin'
|
20
|
+
@mysql_cmd = '/usr/bin/mysql'
|
21
21
|
end
|
22
22
|
|
23
23
|
# Get MySQL user
|
@@ -32,17 +32,27 @@ class MySQL
|
|
32
32
|
@mysql_password ||= config[:mysql_password]
|
33
33
|
end
|
34
34
|
|
35
|
+
# Check if server is running and we have the right credentials
|
36
|
+
# @return [Boolean]
|
37
|
+
def commands_present?
|
38
|
+
commands_present = false
|
39
|
+
if File.exists?(@mysqladmin_cmd) and File.exists?(@mysqladmin_cmd)
|
40
|
+
commands_present = true
|
41
|
+
end
|
42
|
+
return commands_present
|
43
|
+
end
|
35
44
|
|
36
45
|
# Check if server is running and we have the right credentials
|
37
46
|
# @return [Boolean]
|
38
47
|
def mysql_exists?
|
39
48
|
mysql_exists = false
|
40
|
-
if
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
49
|
+
server_present = system "#{@mysqladmin_cmd} -s ping" if commands_present?
|
50
|
+
if server_present and mysql_user.nil? and mysql_password.nil?
|
51
|
+
message.warn 'WARNING: MySQL exists but no credentials were found!'
|
52
|
+
elsif ! server_present and ! mysql_user.nil? and ! mysql_password.nil?
|
53
|
+
message.warn 'WARNING: MySQL credentials exist but no local server was found!'
|
54
|
+
elsif server_present and ! mysql_user.nil? and ! mysql_password.nil?
|
55
|
+
mysql_exists = true
|
46
56
|
end
|
47
57
|
return mysql_exists
|
48
58
|
end
|
@@ -69,3 +79,4 @@ end # module VGH
|
|
69
79
|
|
70
80
|
require 'vgh/output'
|
71
81
|
require 'vgh/configuration'
|
82
|
+
|
data/lib/vgh/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vgh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -185,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
segments:
|
187
187
|
- 0
|
188
|
-
hash:
|
188
|
+
hash: 1008001245
|
189
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
190
|
none: false
|
191
191
|
requirements:
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
segments:
|
196
196
|
- 0
|
197
|
-
hash:
|
197
|
+
hash: 1008001245
|
198
198
|
requirements: []
|
199
199
|
rubyforge_project:
|
200
200
|
rubygems_version: 1.8.23
|