class Mercury::CLI::Commands::Bootstrap

@author David Love

The bootstrap command prepared the basic Mercury realms (if needed), and then links the current host to those realms. The basic realms consists of

+Realm 0+: Namespace. All the named realms stored in this domain.

+Realm 1+: *Realm Handlers*. The basic gateways needed to create/store/update other realms.

+Realm 5+: *Realm Code*. Libraries and other code which the realm handlers should use by preference when conducting operations on the realms.

If the IP address of a server (or a server name) is given to as an argument to this command, then we will use that IP address (name) for as the Mercury realm server to contact. Otherwise we will look for the same data from the file /etc/mercury.conf: aborting if the file cannot be found.

Once we have made contact with the server, we look at the basic realms listed above, and attempt to ensure they can be found. If not, an attempt is made to create the basic realms: aborting if this attempt fails.

Finally, once everything has been set-up, we upload the core realm code (or update the existing code)

Public Instance Methods

aliases() click to toggle source

The aliases this sub-command is known by

# File lib/mercury/cli/commands/bootstrap.rb, line 51
def aliases
  []
end
long_desc() click to toggle source

A longer description, detailing both the purpose and the use of this command

# File lib/mercury/cli/commands/bootstrap.rb, line 62
def long_desc
  'Look for the specified server, adding the data required to link the ' +
  'current host to that server. If the found server has not been set-up ' +
  'then this command also performs the setup of the base realms as well. '
end
name() click to toggle source

The name of the sub-command (as it appears in the command line app)

# File lib/mercury/cli/commands/bootstrap.rb, line 46
def name
  'bootstrap'
end
option_definitions() click to toggle source

Define the options for this command

# File lib/mercury/cli/commands/bootstrap.rb, line 74
def option_definitions
  [
    { :short => 's', :long => 'server', :argument => :optional }
  ]
end
run(options, arguments) click to toggle source

Execute the command

# File lib/mercury/cli/commands/bootstrap.rb, line 81
def run(options, arguments)
  
  # The first thing we need to do is to find the relevant server. So we
  # check the options and see if they can help
  unless options[:server].nil? or options[:server].empty? then
    #
  else
  
    # The user has not specified a server, so we will attempt to get one
    # from the system configuration
    if File.exists?("/etc/mercury.conf") then
      #
    
    # Everything has failed, so we abort
    else
      Mercury::CLI::Logger.instance.log_level(:high, :error, "Cannot locate a Mercury server. Either specify the server to connect to using the 'server' option, or create an appropriate configuration file.")
    end
  end  
end
short_desc() click to toggle source

A short help text describing the purpose of this command

# File lib/mercury/cli/commands/bootstrap.rb, line 56
def short_desc
  'Create a link between this host and the mercury servers.'
end
usage() click to toggle source

Show the user the basic syntax of this command

# File lib/mercury/cli/commands/bootstrap.rb, line 69
def usage
  "mercury bootstrap [-s server]"
end