shu-san-scripts 0.1.0 → 0.1.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/README.rdoc +54 -0
- metadata +33 -46
- data/.document +0 -5
- data/.rvmrc +0 -27
- data/Gemfile +0 -40
- data/Gemfile.lock +0 -35
- data/HISTORY +0 -41
- data/Rakefile +0 -45
- data/VERSION +0 -1
- data/bin/store +0 -50
- data/lib/SANStore.rb +0 -24
- data/lib/SANStore/cli.rb +0 -29
- data/lib/SANStore/cli/base.rb +0 -102
- data/lib/SANStore/cli/commands.rb +0 -30
- data/lib/SANStore/cli/commands/help.rb +0 -106
- data/lib/SANStore/cli/commands/list_vols.rb +0 -87
- data/lib/SANStore/cli/commands/new_vol.rb +0 -119
- data/lib/SANStore/cli/logger.rb +0 -88
- data/lib/SANStore/cri.rb +0 -12
- data/lib/SANStore/cri/base.rb +0 -153
- data/lib/SANStore/cri/command.rb +0 -104
- data/lib/SANStore/cri/core_ext.rb +0 -8
- data/lib/SANStore/cri/core_ext/string.rb +0 -41
- data/lib/SANStore/cri/option_parser.rb +0 -186
- data/lib/SANStore/helpers/uuid.rb +0 -35
- data/lib/SANStore/iSCSI/comstar.rb +0 -45
- data/lib/SANStore/zfs/zfs.rb +0 -36
- data/shu-san-scripts.gemspec +0 -94
- data/test/helper.rb +0 -18
- data/test/test_shu-san-scripts.rb +0 -7
data/lib/SANStore.rb
DELETED
@@ -1,24 +0,0 @@
|
|
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 SANStore
|
17
|
-
|
18
|
-
## Define Application Global constants
|
19
|
-
|
20
|
-
# The current SANStore client version.
|
21
|
-
VERSION = '0.1'
|
22
|
-
|
23
|
-
end
|
24
|
-
|
data/lib/SANStore/cli.rb
DELETED
@@ -1,29 +0,0 @@
|
|
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 SANStore:CLI
|
24
|
-
end
|
25
|
-
|
26
|
-
# Load the command line handling modules
|
27
|
-
require 'SANStore/cli/logger'
|
28
|
-
require 'SANStore/cli/commands'
|
29
|
-
require 'SANStore/cli/base'
|
data/lib/SANStore/cli/base.rb
DELETED
@@ -1,102 +0,0 @@
|
|
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 +SANStore+ command can deal with.
|
21
|
-
# Sub-commands are themselves defined in the {SANStore::CLI::Commands}
|
22
|
-
# module
|
23
|
-
module SANStore::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/SANStore/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('SANStore')
|
48
|
-
|
49
|
-
# Add help command
|
50
|
-
self.help_command = SANStore::CLI::Commands::Help.new
|
51
|
-
add_command(self.help_command)
|
52
|
-
|
53
|
-
# Add other commands
|
54
|
-
add_command(SANStore::CLI::Commands::NewVol.new)
|
55
|
-
#add_command(SANStore::CLI::Commands::ListVols.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 store command 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 "SANStore Bootstrap Client #{SANStore::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
|
-
SANStore::CLI::Logger.instance.level = :low
|
90
|
-
# Handle no-color option
|
91
|
-
elsif option == :'no-color'
|
92
|
-
SANStore::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
|
@@ -1,30 +0,0 @@
|
|
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 +store+ 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/SANStore/cli/commands+, with the
|
22
|
-
# file-name named after the sub-command defined within it.
|
23
|
-
|
24
|
-
module SANStore::CLI::Commands
|
25
|
-
end
|
26
|
-
|
27
|
-
require 'SANStore/cli/commands/help'
|
28
|
-
|
29
|
-
require 'SANStore/cli/commands/new_vol'
|
30
|
-
#require 'SANStore/cli/commands/list_vols'
|
@@ -1,106 +0,0 @@
|
|
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 SANStore::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
|
-
"store 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 iSCSI targets on OpenSolaris.\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
|
@@ -1,87 +0,0 @@
|
|
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
|
@@ -1,119 +0,0 @@
|
|
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
|
-
# Volume names are based on RFC 4122 UUIDs
|
16
|
-
require "uuidtools"
|
17
|
-
|
18
|
-
# Use the ZFS library
|
19
|
-
require "SANStore/zfs/zfs"
|
20
|
-
|
21
|
-
# Use the COMStar iSCSI library
|
22
|
-
require "SANStore/iSCSI/comstar.rb"
|
23
|
-
|
24
|
-
module SANStore::CLI::Commands
|
25
|
-
|
26
|
-
# @author David Love
|
27
|
-
#
|
28
|
-
# The +new_vol+ command adds a new ZFS volume to the specified volume
|
29
|
-
# store, and sets it up as an iSCSI target. Defaults are supplied to
|
30
|
-
# all arguments, but can be overridden by the user for slightly
|
31
|
-
# customised set-up of the volume store. However, the user interface
|
32
|
-
# should be kept as simple as possible.
|
33
|
-
class NewVol < Cri::Command
|
34
|
-
|
35
|
-
# The name of the sub-command (as it appears in the command line app)
|
36
|
-
def name
|
37
|
-
'new_vol'
|
38
|
-
end
|
39
|
-
|
40
|
-
# The aliases this sub-command is known by
|
41
|
-
def aliases
|
42
|
-
[
|
43
|
-
"new", "add", "add_vol"
|
44
|
-
]
|
45
|
-
end
|
46
|
-
|
47
|
-
# A short help text describing the purpose of this command
|
48
|
-
def short_desc
|
49
|
-
'Create a new iSCSI volume in the SAN volume store.'
|
50
|
-
end
|
51
|
-
|
52
|
-
# A longer description, detailing both the purpose and the
|
53
|
-
# use of this command
|
54
|
-
def long_desc
|
55
|
-
'By default, this command creates a 20G ZFS volume, and marks it for ' +
|
56
|
-
'sharing as an iSCSI target on the local network.' + "\n\n" +
|
57
|
-
'Warning: By default this commands sets up the iSCSI target with NO ' +
|
58
|
-
'security. This is fine for testing and use in the labs, but obviously ' +
|
59
|
-
'is not ideal if you care about the data stored on this new volume...'
|
60
|
-
end
|
61
|
-
|
62
|
-
# Show the user the basic syntax of this command
|
63
|
-
def usage
|
64
|
-
"store new_volume [--volume-store ZFS_PATH][--name GUID] [--size INTEGER]"
|
65
|
-
end
|
66
|
-
|
67
|
-
# Define the options for this command
|
68
|
-
def option_definitions
|
69
|
-
[
|
70
|
-
{ :short => 'v', :long => 'volume_store', :argument => :optional,
|
71
|
-
:desc => 'specifify the ZFS root of the new iSCSI volume. Defaults to "store/volumes".'
|
72
|
-
},
|
73
|
-
{ :short => 'n', :long => 'name', :argument => :optional,
|
74
|
-
:desc => 'the name of the new volume. This must be a valid ZFS volume name, and defaults to ' +
|
75
|
-
'an RFC 4122 GUID.'
|
76
|
-
},
|
77
|
-
{ :short => 's', :long => 'size', :argument => :optional,
|
78
|
-
:desc => 'the size of the new iSCSI volume. Note that while ZFS allows you to change the size ' +
|
79
|
-
'of the new volume relatively easily, because the iSCSI initiator sees this volume as a raw ' +
|
80
|
-
'device changing the size later may be very easy or very difficult depending on the initiators ' +
|
81
|
-
'operating system (and the specific file system being used). In other words, choose with care: ' +
|
82
|
-
'by default this command uses a size of 20G, which should be enough for most tasks in the labs.'
|
83
|
-
},
|
84
|
-
]
|
85
|
-
end
|
86
|
-
|
87
|
-
# Execute the command
|
88
|
-
def run(options, arguments)
|
89
|
-
|
90
|
-
# Look at the options, and if we don't find any (or some are
|
91
|
-
# missing), set them to the default values
|
92
|
-
if options[:volume_store].nil? or options[:volume_store].empty? then
|
93
|
-
volume_store = "store/volumes"
|
94
|
-
options[:volume_store] = volume_store
|
95
|
-
end
|
96
|
-
|
97
|
-
if options[:name].nil? or options[:name].empty? then
|
98
|
-
name = UUIDTools::UUID.timestamp_create
|
99
|
-
options[:name] = name.to_s
|
100
|
-
end
|
101
|
-
|
102
|
-
if options[:size].nil? or options[:size].empty? then
|
103
|
-
size = "20G"
|
104
|
-
options[:size] = size
|
105
|
-
end
|
106
|
-
|
107
|
-
# Ask for a new volume
|
108
|
-
ZFS.new_volume(options[:volume_store] + "/" + options[:name], options[:size])
|
109
|
-
|
110
|
-
# Set the volume up as an iSCSI target
|
111
|
-
target_name = COMStar.new_target(options[:volume_store] + "/" + options[:name])
|
112
|
-
|
113
|
-
# Tell the caller what the new volume name is
|
114
|
-
puts target_name
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|