Module: VGH::System

Defined in:
lib/vgh/system.rb,
lib/vgh/system/lvm.rb,
lib/vgh/system/mysql.rb

Overview

This is a parent class for different system actions performed by the scripts included in this gem. For more information see the classes defined under this namespace.

Usage

fqdn = System.fqdn

Defined Under Namespace

Classes: LVM, MySQL

Class Method Summary collapse

Class Method Details

.fqdnString

Returns the current system’s FQDN

Returns:

  • (String)


38
39
40
# File 'lib/vgh/system.rb', line 38

def self.fqdn
  $fqdn ||= `hostname -f`.strip
end

.is_root?Boolean

Check if the script is run as root

Returns:

  • (Boolean)


28
29
30
31
32
33
34
# File 'lib/vgh/system.rb', line 28

def self.is_root?
  if Process.uid == 0
    return true
  else
    return false
  end
end

.lockString

Returns the current system’s FQDN

Returns:

  • (String)


44
45
46
47
48
49
# File 'lib/vgh/system.rb', line 44

def self.lock
  unless remotely?
    mysql.flush
    lvm.suspend
  end
end

.lvmObject

Initializes the LVM class



77
78
79
# File 'lib/vgh/system.rb', line 77

def self.lvm
  lvm ||= System::LVM.new
end

.mysqlObject

Initializes the MySQL class



72
73
74
# File 'lib/vgh/system.rb', line 72

def self.mysql
  mysql ||= System::MySQL.new
end

.remotely?Boolean

Checks if this script is run remotely.

Returns:

  • (Boolean)


62
63
64
65
66
67
68
69
# File 'lib/vgh/system.rb', line 62

def self.remotely?
  cfg = config
  if cfg[:instance] or cfg[:fqdn]
    return true
  else
    return false
  end
end

.unlockString

Returns the current system’s FQDN

Returns:

  • (String)


53
54
55
56
57
58
# File 'lib/vgh/system.rb', line 53

def self.unlock
  unless remotely?
    mysql.unlock
    lvm.resume
  end
end