WhiteCloth 0.0.2
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/.document +5 -0
- data/.rvmrc +27 -0
- data/FluxTuna.gemspec +120 -0
- data/Gemfile +51 -0
- data/Gemfile.lock +61 -0
- data/HISTORY +33 -0
- data/LICENSE +13 -0
- data/README.rdoc +20 -0
- data/Rakefile +100 -0
- data/VERSION +1 -0
- data/bin/whitecloth +49 -0
- data/lib/LICENSE +20 -0
- data/lib/WhiteCloth.rb +24 -0
- data/lib/whitecloth/cli.rb +29 -0
- data/lib/whitecloth/cli/base.rb +102 -0
- data/lib/whitecloth/cli/commands.rb +29 -0
- data/lib/whitecloth/cli/commands/bootstrap.rb +103 -0
- data/lib/whitecloth/cli/commands/help.rb +106 -0
- data/lib/whitecloth/cli/commands/show.rb +87 -0
- data/lib/whitecloth/cli/logger.rb +88 -0
- data/test/data/bayeux/Labs/Lab1/L1_Internet.byx +536 -0
- data/test/data/bayeux/Labs/Lab1/L1_Internet.yaml +1 -0
- data/test/data/bayeux/Labs/Lab2/L2_StaticR.byx +383 -0
- data/test/data/bayeux/Labs/Lab2/L2_StaticR.yaml +1 -0
- data/test/data/bayeux/Labs/Lab3/L3_DNS.byx +943 -0
- data/test/data/bayeux/Labs/Lab3/L3_DNS.yaml +1 -0
- data/test/data/bayeux/Labs/Labs.byx +1 -0
- data/test/data/bayeux/Labs/Labs.yaml +1 -0
- data/test/data/bayeux/Resources/Resources.byx +91 -0
- data/test/data/bayeux/Resources/Resources.yaml +1 -0
- data/test/data/bayeux/Welcome.byx +49 -0
- data/test/data/bayeux/Welcome.yaml +1 -0
- data/test/data/data_test.rb +29 -0
- data/test/dir_walk/create_witness_test.rb +39 -0
- data/test/init_test.rb +26 -0
- metadata +269 -0
data/lib/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Denis Defreyne and contributors
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
20
|
+
|
data/lib/WhiteCloth.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
### Copyright (c) 2010, David Love
|
2
|
+
###
|
3
|
+
### Permission to use, copy, modify, and/or distribute this software for
|
4
|
+
### any purpose with or without fee is hereby granted, provided that the
|
5
|
+
### above copyright notice and this permission notice appear in all copies.
|
6
|
+
###
|
7
|
+
### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
###
|
15
|
+
|
16
|
+
module WhiteCloth
|
17
|
+
|
18
|
+
## Define Application Global constants
|
19
|
+
|
20
|
+
# The current WhiteCloth client version.
|
21
|
+
VERSION = '0.1'
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
### Copyright (c) 2009 Denis Defreyne, 2010-2011 David Love
|
2
|
+
###
|
3
|
+
### Permission to use, copy, modify, and/or distribute this software for
|
4
|
+
### any purpose with or without fee is hereby granted, provided that the
|
5
|
+
### above copyright notice and this permission notice appear in all copies.
|
6
|
+
###
|
7
|
+
### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
###
|
15
|
+
|
16
|
+
require 'rubygems'
|
17
|
+
|
18
|
+
# Load command line handling library
|
19
|
+
require 'cri'
|
20
|
+
|
21
|
+
# Install module for command line
|
22
|
+
# interface
|
23
|
+
module WhiteCloth:CLI
|
24
|
+
end
|
25
|
+
|
26
|
+
# Load the command line handling modules
|
27
|
+
require 'whitecloth/cli/logger'
|
28
|
+
require 'whitecloth/cli/commands'
|
29
|
+
require 'whitecloth/cli/base'
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# Copyright (c) 2009 Denis Defreyne, 2010-2011 David Love
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for
|
4
|
+
# any purpose with or without fee is hereby granted, provided that the
|
5
|
+
# above copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
#
|
15
|
+
|
16
|
+
# @author Denis Defreyne
|
17
|
+
# @author David Love
|
18
|
+
#
|
19
|
+
# The +CLI+ module acts as the gathering place for all the gloabl options
|
20
|
+
# and the sub-commands which the +whitecloth+ command can deal with.
|
21
|
+
# Sub-commands are themselves defined in the {WhiteCloth::CLI::Commands}
|
22
|
+
# module
|
23
|
+
module WhiteCloth::CLI
|
24
|
+
|
25
|
+
# @author Denis Defreyne
|
26
|
+
# @author David Love
|
27
|
+
#
|
28
|
+
# Details the global options applicable to all commands, and the code necessary
|
29
|
+
# to process those options. Each sub-command also needs to be registered with
|
30
|
+
# this class for it to work: strange things will happen if the sub-command is
|
31
|
+
# not set-up here!
|
32
|
+
#
|
33
|
+
# When creating a new sub-command, the constructor for that sub-command needs
|
34
|
+
# to be added to the {Base#initialize} function of *this* class as well. Be sure to
|
35
|
+
# also add the path to the file where the sub-command is defined to the file
|
36
|
+
# +lib/whitecloth/cli/commands.rb+, otherwise you will get warnings of unknown
|
37
|
+
# classes.
|
38
|
+
class Base < Cri::Base
|
39
|
+
|
40
|
+
# Instantiates the sub-commands by creating a single reference to each
|
41
|
+
# known sub-command.
|
42
|
+
#
|
43
|
+
# @note This means that if your sub-command is not in this constructor
|
44
|
+
# it *will not* be found, and *will not* appear as a valid sub-command.
|
45
|
+
# If something is missing from the 'help' command, check this method!
|
46
|
+
def initialize
|
47
|
+
super('whitecloth')
|
48
|
+
|
49
|
+
# Add help command
|
50
|
+
self.help_command = WhiteCloth::CLI::Commands::Help.new
|
51
|
+
add_command(self.help_command)
|
52
|
+
|
53
|
+
# Add other commands
|
54
|
+
add_command(WhiteCloth::CLI::Commands::Bootstrap.new)
|
55
|
+
add_command(WhiteCloth::CLI::Commands::Show.new)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns the list of global option definitionss.
|
59
|
+
def global_option_definitions
|
60
|
+
[
|
61
|
+
{
|
62
|
+
:long => 'help', :short => 'h', :argument => :forbidden,
|
63
|
+
:desc => 'show this help message and quit'
|
64
|
+
},
|
65
|
+
{
|
66
|
+
:long => 'no-color', :short => 'C', :argument => :forbidden,
|
67
|
+
:desc => 'disable color'
|
68
|
+
},
|
69
|
+
{
|
70
|
+
:long => 'version', :short => 'v', :argument => :forbidden,
|
71
|
+
:desc => 'show version information and quit'
|
72
|
+
},
|
73
|
+
{
|
74
|
+
:long => 'verbose', :short => 'V', :argument => :forbidden,
|
75
|
+
:desc => 'make whitecloth output more detailed'
|
76
|
+
}
|
77
|
+
]
|
78
|
+
end
|
79
|
+
|
80
|
+
# Process the global options, and set/change the application state from them
|
81
|
+
def handle_option(option)
|
82
|
+
# Handle version option
|
83
|
+
if option == :version
|
84
|
+
puts "WhiteCloth Bootstrap Client #{WhiteCloth::VERSION} (c) 2011 David Love."
|
85
|
+
puts "Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) running on #{RUBY_PLATFORM}"
|
86
|
+
exit 0
|
87
|
+
# Handle verbose option
|
88
|
+
elsif option == :verbose
|
89
|
+
WhiteCloth::CLI::Logger.instance.level = :low
|
90
|
+
# Handle no-color option
|
91
|
+
elsif option == :'no-color'
|
92
|
+
WhiteCloth::CLI::Logger.instance.color = false
|
93
|
+
# Handle help option
|
94
|
+
elsif option == :help
|
95
|
+
show_help
|
96
|
+
exit 0
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright (c) 2009 Denis Defreyne, 2010-2011 David Love
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for
|
4
|
+
# any purpose with or without fee is hereby granted, provided that the
|
5
|
+
# above copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
15
|
+
# @author David Love
|
16
|
+
#
|
17
|
+
# The +Commands+ module acts as the gathering place for all the sub-commands
|
18
|
+
# which the +whitecloth+ command can deal with. Each sub-command defines both
|
19
|
+
# the command action, options, and associated help text.
|
20
|
+
#
|
21
|
+
# All commands should live under +lib/whitecloth/cli/commands+, with the
|
22
|
+
# file-name named after the sub-command defined within it.
|
23
|
+
module WhiteCloth::CLI::Commands
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'whitecloth/cli/commands/help'
|
27
|
+
|
28
|
+
require 'whitecloth/cli/commands/bootstrap'
|
29
|
+
require 'whitecloth/cli/commands/show'
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# Copyright (c) 2009 Denis Defreyne, 2010-2011 David Love
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for
|
4
|
+
# any purpose with or without fee is hereby granted, provided that the
|
5
|
+
# above copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
15
|
+
|
16
|
+
module WhiteCloth::CLI::Commands
|
17
|
+
|
18
|
+
# @author David Love
|
19
|
+
#
|
20
|
+
# The +bootstrap+ command prepared the basic WhiteCloth realms (if
|
21
|
+
# needed), and then links the current host to those realms. The basic
|
22
|
+
# realms consists of
|
23
|
+
#
|
24
|
+
# +Realm 0+: *Namespace*. All the named realms stored in this domain.
|
25
|
+
#
|
26
|
+
# +Realm 1+: *Realm Handlers*. The basic gateways needed to create/store/update
|
27
|
+
# other realms.
|
28
|
+
#
|
29
|
+
# +Realm 5+: *Realm Code*. Libraries and other code which the realm handlers
|
30
|
+
# should use by preference when conducting operations on the realms.
|
31
|
+
#
|
32
|
+
# If the IP address of a server (or a server name) is given to as an argument
|
33
|
+
# to this command, then we will use that IP address (name) for as the WhiteCloth
|
34
|
+
# realm server to contact. Otherwise we will look for the same data from the file
|
35
|
+
# +/etc/whitecloth.conf+: aborting if the file cannot be found.
|
36
|
+
#
|
37
|
+
# Once we have made contact with the server, we look at the basic realms listed
|
38
|
+
# above, and attempt to ensure they can be found. If not, an attempt is made to
|
39
|
+
# create the basic realms: aborting if this attempt fails.
|
40
|
+
#
|
41
|
+
# Finally, once everything has been set-up, we upload the core realm code (or
|
42
|
+
# update the existing code)
|
43
|
+
class Bootstrap < Cri::Command
|
44
|
+
|
45
|
+
# The name of the sub-command (as it appears in the command line app)
|
46
|
+
def name
|
47
|
+
'bootstrap'
|
48
|
+
end
|
49
|
+
|
50
|
+
# The aliases this sub-command is known by
|
51
|
+
def aliases
|
52
|
+
[]
|
53
|
+
end
|
54
|
+
|
55
|
+
# A short help text describing the purpose of this command
|
56
|
+
def short_desc
|
57
|
+
'Create a link between this host and the whitecloth servers.'
|
58
|
+
end
|
59
|
+
|
60
|
+
# A longer description, detailing both the purpose and the
|
61
|
+
# use of this command
|
62
|
+
def long_desc
|
63
|
+
'Look for the specified server, adding the data required to link the ' +
|
64
|
+
'current host to that server. If the found server has not been set-up ' +
|
65
|
+
'then this command also performs the setup of the base realms as well. '
|
66
|
+
end
|
67
|
+
|
68
|
+
# Show the user the basic syntax of this command
|
69
|
+
def usage
|
70
|
+
"whitecloth bootstrap [-s server]"
|
71
|
+
end
|
72
|
+
|
73
|
+
# Define the options for this command
|
74
|
+
def option_definitions
|
75
|
+
[
|
76
|
+
{ :short => 's', :long => 'server', :argument => :optional }
|
77
|
+
]
|
78
|
+
end
|
79
|
+
|
80
|
+
# Execute the command
|
81
|
+
def run(options, arguments)
|
82
|
+
|
83
|
+
# The first thing we need to do is to find the relevant server. So we
|
84
|
+
# check the options and see if they can help
|
85
|
+
unless options[:server].nil? or options[:server].empty? then
|
86
|
+
#
|
87
|
+
else
|
88
|
+
|
89
|
+
# The user has not specified a server, so we will attempt to get one
|
90
|
+
# from the system configuration
|
91
|
+
if File.exists?("/etc/whitecloth.conf") then
|
92
|
+
#
|
93
|
+
|
94
|
+
# Everything has failed, so we abort
|
95
|
+
else
|
96
|
+
WhiteCloth::CLI::Logger.instance.log_level(:high, :error, "Cannot locate a WhiteCloth server. Either specify the server to connect to using the 'server' option, or create an appropriate configuration file.")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
### Copyright (c) 2009 Denis Defreyne, 2010-2011 David Love
|
2
|
+
###
|
3
|
+
### Permission to use, copy, modify, and/or distribute this software for
|
4
|
+
### any purpose with or without fee is hereby granted, provided that the
|
5
|
+
### above copyright notice and this permission notice appear in all copies.
|
6
|
+
###
|
7
|
+
### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
###
|
15
|
+
|
16
|
+
module WhiteCloth::CLI::Commands
|
17
|
+
|
18
|
+
# @author Denis Defreyne
|
19
|
+
# @author David Love
|
20
|
+
#
|
21
|
+
# The +help+ command show the user a brief summary of the available
|
22
|
+
# sub-commands, and the short description of each of those commands.
|
23
|
+
#
|
24
|
+
# Further help is available to the user, if one of the sub-commands
|
25
|
+
# is named as an argument to this command. In that case, the longer
|
26
|
+
# help for the command is displayed.
|
27
|
+
#
|
28
|
+
# @note This class is merely a helper class: the actual text, options
|
29
|
+
# and other details are drawn directly from the source code of those
|
30
|
+
# commands. In the execution of this command, we rely on the +cri+
|
31
|
+
# and +cli+ libraries to do the hard work of actually processing the
|
32
|
+
# sub-commands.
|
33
|
+
class Help < Cri::Command
|
34
|
+
|
35
|
+
# The name of the sub-command (as it appears in the command line app)
|
36
|
+
def name
|
37
|
+
'help'
|
38
|
+
end
|
39
|
+
|
40
|
+
# The aliases this sub-command is known by
|
41
|
+
def aliases
|
42
|
+
[]
|
43
|
+
end
|
44
|
+
|
45
|
+
# A short help text describing the purpose of this command
|
46
|
+
def short_desc
|
47
|
+
'Show help for a command'
|
48
|
+
end
|
49
|
+
|
50
|
+
# A longer description, detailing both the purpose and the
|
51
|
+
# use of this command
|
52
|
+
def long_desc
|
53
|
+
'Show help for the given command, or show general help. When no ' +
|
54
|
+
'command is given, a list of available commands is displayed, as ' +
|
55
|
+
'well as a list of global command-line options. When a command is ' +
|
56
|
+
'given, a command description as well as command-specific ' +
|
57
|
+
'command-line options are shown.'
|
58
|
+
end
|
59
|
+
|
60
|
+
# Show the user the basic syntax of this command
|
61
|
+
def usage
|
62
|
+
"whitecloth help [command]"
|
63
|
+
end
|
64
|
+
|
65
|
+
# Execute the command
|
66
|
+
def run(options, arguments)
|
67
|
+
# Check arguments
|
68
|
+
if arguments.size > 1
|
69
|
+
$stderr.puts "usage: #{usage}"
|
70
|
+
exit 1
|
71
|
+
end
|
72
|
+
|
73
|
+
if arguments.length == 0
|
74
|
+
# Build help text
|
75
|
+
text = ''
|
76
|
+
|
77
|
+
# Add title
|
78
|
+
text << "A command-line tool for managing WhiteCloth realms.\n"
|
79
|
+
|
80
|
+
# Add available commands
|
81
|
+
text << "\n"
|
82
|
+
text << "Available commands:\n"
|
83
|
+
text << "\n"
|
84
|
+
@base.commands.sort.each do |command|
|
85
|
+
text << sprintf(" %-20s %s\n", command.name, command.short_desc)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Add global options
|
89
|
+
text << "\n"
|
90
|
+
text << "Global options:\n"
|
91
|
+
text << "\n"
|
92
|
+
@base.global_option_definitions.sort { |x,y| x[:long] <=> y[:long] }.each do |opt_def|
|
93
|
+
text << sprintf(" -%1s --%-15s %s\n", opt_def[:short], opt_def[:long], opt_def[:desc])
|
94
|
+
end
|
95
|
+
|
96
|
+
# Display text
|
97
|
+
puts text
|
98
|
+
elsif arguments.length == 1
|
99
|
+
command = @base.command_named(arguments[0])
|
100
|
+
puts command.help
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Copyright (c) 2011 David Love
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for
|
4
|
+
# any purpose with or without fee is hereby granted, provided that the
|
5
|
+
# above copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
#
|
15
|
+
#
|
16
|
+
# @author David Love
|
17
|
+
#
|
18
|
+
|
19
|
+
module WhiteCloth::CLI::Commands
|
20
|
+
|
21
|
+
# @author David Love
|
22
|
+
#
|
23
|
+
# Displays a summary of the realm data found in the configured WhiteCloth
|
24
|
+
# server.
|
25
|
+
class Show < Cri::Command
|
26
|
+
|
27
|
+
# The name of the sub-command (as it appears in the command line app)
|
28
|
+
def name
|
29
|
+
'show-status'
|
30
|
+
end
|
31
|
+
|
32
|
+
# The aliases this sub-command is known by
|
33
|
+
def aliases
|
34
|
+
[]
|
35
|
+
end
|
36
|
+
|
37
|
+
# A short help text describing the purpose of this command
|
38
|
+
def short_desc
|
39
|
+
'Create or update information from the network'
|
40
|
+
end
|
41
|
+
|
42
|
+
# A longer description, detailing both the purpose and the
|
43
|
+
# use of this command
|
44
|
+
def long_desc
|
45
|
+
"Displays the current state of the evironemnt " +
|
46
|
+
"to update the host files (held in the 'hosts' directory). Existing " +
|
47
|
+
"information will be updated, and missing information inserted.\n"
|
48
|
+
end
|
49
|
+
|
50
|
+
# Show the user the basic syntax of this command
|
51
|
+
def usage
|
52
|
+
"bootstrap show-status"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Define the options for this command
|
56
|
+
def option_definitions
|
57
|
+
[]
|
58
|
+
end
|
59
|
+
|
60
|
+
# Execute the command
|
61
|
+
def run(options, arguments)
|
62
|
+
|
63
|
+
# Load the list of groups
|
64
|
+
group_list = YAML::load( File.open("config/groups.yaml"))
|
65
|
+
|
66
|
+
# Load the list of networks
|
67
|
+
network_list = YAML::load( File.open("config/networks.yaml"))
|
68
|
+
|
69
|
+
# Update the information in each group-network directory
|
70
|
+
gn_name_list = Array.new
|
71
|
+
|
72
|
+
network_list.each{|network|
|
73
|
+
puts network[1]
|
74
|
+
|
75
|
+
net_block = network[1]['ip4-address-block'].to_s
|
76
|
+
|
77
|
+
# Scan this network
|
78
|
+
# parser = Nmap::Parser.parsescan("nmap", "-sVC " + net_block)
|
79
|
+
|
80
|
+
puts parser
|
81
|
+
}
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|