Module: VGH

Defined in:
lib/vgh.rb,
lib/vgh/cli.rb,
lib/vgh/ec2.rb,
lib/vgh/apps.rb,
lib/vgh/output.rb,
lib/vgh/system.rb,
lib/vgh/logging.rb,
lib/vgh/version.rb,
lib/vgh/ec2/volume.rb,
lib/vgh/system/lvm.rb,
lib/vgh/ec2/metadata.rb,
lib/vgh/ec2/snapshot.rb,
lib/vgh/system/mysql.rb,
lib/vgh/configuration.rb,
lib/vgh/apps/checkpoint.rb,
lib/vgh/apps/ec2_backup.rb

Overview

See the README file.

Defined Under Namespace

Modules: APPS, EC2, System Classes: CLI, Configuration, Logging, Output

Constant Summary collapse

VERSION =

Version number

"0.2.6"

Instance Method Summary collapse

Instance Method Details

#appString

Returns the app name specified in the command line

Returns:

  • (String)


13
14
15
# File 'lib/vgh/cli.rb', line 13

def app
  $app ||= cli[:app]
end

#cliHash

Returns a global collection of options.

Returns:

  • (Hash)


7
8
9
# File 'lib/vgh/cli.rb', line 7

def cli
  $cli ||= CLI.new.options
end

#configHash

Global config method

Returns:

  • (Hash)


10
11
12
# File 'lib/vgh/configuration.rb', line 10

def config
  $config ||= Configuration.new.config
end

#ec2Object

Creates a global ec2 method.



6
7
8
# File 'lib/vgh/ec2.rb', line 6

def ec2
  $ec2 = AWS::EC2.new
end

#fqdnString

Returns the FQDN (either the one specified in the configuration file or the system’s one)

Returns:

  • (String)


6
7
8
9
10
11
12
13
# File 'lib/vgh/system.rb', line 6

def fqdn
  remote_fqdn = config[:fqdn]
  if remote_fqdn
    $fqdn ||= remote_fqdn
  else
    $fqdn ||= System.fqdn
  end
end

#instance_idString

Looks for the instance id in the configuration. If it does not exist then it queries the API server for it.

Returns:

  • (String)


8
9
10
11
12
13
14
15
16
# File 'lib/vgh/ec2/metadata.rb', line 8

def instance_id
    remote_instance = config[:instance]
    if remote_instance
      $instance_id ||= remote_instance
    else
      $instance_id ||= VGH::EC2::MetaData.new.instance_id
    end
    return $instance_id
end

#logObject

Log message



6
7
8
9
10
11
12
# File 'lib/vgh/logging.rb', line 6

def log
  if logging?
    $log ||= Logging.new.log
  else
    $log ||= Logger.new('/dev/null')
  end
end

#logging?Boolean

Returns logging

Returns:

  • (Boolean)


25
26
27
# File 'lib/vgh/cli.rb', line 25

def logging?
  $logging = cli[:logging]
end

#messageObject

Creates a global message method



4
5
6
# File 'lib/vgh/output.rb', line 4

def message
  $message ||= Output.new
end

#runObject

The main run method



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vgh.rb', line 22

def run

  # Display header
  show_header

  # Run apps
  case app
  when 'ec2-backup'
    APPS::EC2_Backup.new.run
  when 'checkpoint'
    APPS::Checkpoint.new.run
  end

  # Display footer
  show_footer

end

Returns the footer



46
47
48
# File 'lib/vgh.rb', line 46

def show_footer
  message.footer
end

#show_headerObject

Returns the header



41
42
43
# File 'lib/vgh.rb', line 41

def show_header
  message.header
end

#verbose?Boolean

Returns verbosity

Returns:

  • (Boolean)


19
20
21
# File 'lib/vgh/cli.rb', line 19

def verbose?
  $verbose = cli[:verbose]
end

#versionObject

Returns the version number



6
7
8
# File 'lib/vgh/version.rb', line 6

def version
  VERSION
end