shu-san-scripts 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rvmrc ADDED
@@ -0,0 +1,27 @@
1
+ ruby_string="ruby-1.8.7-p352"
2
+ gemset_name="san-scripts"
3
+
4
+ if rvm list strings | grep -q "${ruby_string}" ; then
5
+
6
+ # Load or create the specified environment
7
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
8
+ && -s "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}" ]] ; then
9
+ \. "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}"
10
+ else
11
+ rvm --create "${ruby_string}@${gemset_name}"
12
+ fi
13
+
14
+ # Ensure that Bundler is installed, install it if it is not.
15
+ if ! command -v bundle ; then
16
+ gem install bundler
17
+ fi
18
+
19
+ # Bundle while reducing excess noise.
20
+ bundle | grep -v 'Using' | grep -v 'complete' | sed '/^$/d'
21
+
22
+ else
23
+
24
+ # Notify the user to install the desired interpreter before proceeding.
25
+ echo "${ruby_string} was not found, please run 'rvm install ${ruby_string}' and then cd back into the project directory."
26
+
27
+ fi
data/Gemfile ADDED
@@ -0,0 +1,34 @@
1
+ ###
2
+ ### Sources
3
+ ###
4
+
5
+ # Main Ruby Gems site
6
+ source "http://rubygems.org"
7
+
8
+ ###
9
+ ### Core Gems. These are required in _all_ environments (additional environments
10
+ ### follow).
11
+ ###
12
+
13
+ # Command Line Interface Library
14
+ gem "cri", "~> 2.0.2"
15
+
16
+ ###
17
+ ### Development Gems. All _additional_ gems required by development (as opposed to
18
+ ### production environments). If it is required at run-time, it
19
+ ### belongs above.
20
+ group :development do
21
+
22
+ # Gem management tools
23
+ gem "bundler", "~> 1.0.0"
24
+ gem "jeweler", "~> 1.6.0"
25
+
26
+ # Documentation Tools
27
+ gem "yard", "~> 0.6.0"
28
+ gem "vclog", "~> 1.8.1"
29
+
30
+ # Testing Tools
31
+ gem "minitest", ">= 0"
32
+ gem "riot"
33
+
34
+ end
@@ -0,0 +1,32 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ ansi (1.3.0)
5
+ cri (2.0.2)
6
+ facets (2.9.2)
7
+ git (1.2.5)
8
+ jeweler (1.6.4)
9
+ bundler (~> 1.0)
10
+ git (>= 1.2.5)
11
+ rake
12
+ minitest (2.6.0)
13
+ rake (0.9.2)
14
+ riot (0.12.5)
15
+ rr
16
+ rr (1.0.4)
17
+ vclog (1.8.1)
18
+ ansi (>= 1.2)
19
+ facets (>= 2.4)
20
+ yard (0.6.8)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ bundler (~> 1.0.0)
27
+ cri (~> 2.0.2)
28
+ jeweler (~> 1.6.0)
29
+ minitest
30
+ riot
31
+ vclog (~> 1.8.1)
32
+ yard (~> 0.6.0)
data/HISTORY ADDED
@@ -0,0 +1,29 @@
1
+ RELEASE HISTORY
2
+
3
+ v0.0.2 / 2011-09-23
4
+
5
+ Regenerate gemspec for version 0.0.2 (David Love david@homeunix.org.uk)
6
+
7
+ Changes:
8
+
9
+ * 3 General Enhancements
10
+
11
+ * Version bump to 0.0.1
12
+ * Version bump to 0.0.0
13
+ * Initial commit to shu-san-scripts.
14
+
15
+ * 1 Patch Enhancements
16
+
17
+ * Version bump to 0.0.2. Added infrastructure needed for minimally working version
18
+
19
+
20
+ HEAD / 2011-09-24
21
+
22
+ Current Development (David Love)
23
+
24
+ Changes:
25
+
26
+ * 1 General Enhancements
27
+
28
+ * Regenerate gemspec for version 0.0.2
29
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 David Love
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ = SHU SAN Scripts
2
+
3
+ Together these scripts define a ''store'' command, used to simplify the
4
+ task of creating iSCSI targets on OpenSolaris (Solaris > 11) based
5
+ hosts. It has been tested on Nexenta NCP and Open Indiana, but with some
6
+ modification it could be made to work on FreeBSD as well.
7
+
8
+ The user interface is deliberately as simple as possible: we assume the
9
+ user has no underlying knowledge of (Open)Solaris, ZFS and not all that
10
+ much of iSCSI. Instead the scripts aim to get iSCSI targets up and
11
+ running as quickly as possible. Much more complex set-ups are indeed
12
+ possible: see the relevant Oracle ZFS administrator's guides for more
13
+ inspiration.
14
+
15
+ == Using the Scripts
16
+
17
+ Assuming Ruby Gems has been installed
18
+
19
+ gem install shu-san-scripts
20
+
21
+ should install everything you need. A brief summary of the commands
22
+ available can be obtained by
23
+
24
+ store --help
25
+
26
+ once everything has been installed.
27
+
28
+ **Note:** The scripts assume they are running (or at least have access to)
29
+ the ''root'' user role, as they will manipulate your ZFS volumes. You
30
+ can either install them with the appropriate privileges, or install the
31
+ ''sudo'' command to make life easier. With ''sudo''
32
+
33
+ sudo store --help
34
+
35
+ should get you started.
36
+
37
+ **Warning:** We use these scripts in a *teaching* environment, and so we
38
+ assume the host they are running on is somewhat disposable. Your needs
39
+ may differ...
40
+
41
+ == Contributing to the SHU SAN Scripts
42
+
43
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
44
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
45
+ * Fork the project
46
+ * Start a feature/bugfix branch
47
+ * Commit and push until you are happy with your contribution
48
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
49
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
50
+
51
+ == Copyright
52
+
53
+ Copyright (c) 2011 David Love. See LICENSE.txt for
54
+ further details.
55
+
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "shu-san-scripts"
18
+ gem.homepage = "http://github.com/dlove24/shu-san-scripts"
19
+ gem.license = "ISC"
20
+ gem.summary = %Q{Scripts used to set-up and manage iSCSI targets on OpenSolaris (ZFS) systems.}
21
+ gem.description = %Q{See the README file.}
22
+ gem.email = "david@homeunix.org.uk"
23
+ gem.authors = ["David Love"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ task :default => :test
36
+
37
+ require 'rake/rdoctask'
38
+ Rake::RDocTask.new do |rdoc|
39
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "shu-san-scripts #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ### Copyright (c) 2011 David Love <david@homeunix.org.uk>
4
+ ###
5
+ ### Permission to use, copy, modify, and/or distribute this software for
6
+ ### any purpose with or without fee is hereby granted, provided that the
7
+ ### above copyright notice and this permission notice appear in all copies.
8
+ ###
9
+ ### THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ ### WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ ### MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ### ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ ### WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ### ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ ### OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+ ###
17
+
18
+ ### @author David Love
19
+ ###
20
+ ### Boot straping Command. Used to initalize various aspects of the Mercury
21
+ ### environment.
22
+ ###
23
+ ### @note The sub-commands provided by the bootstrap command assume (at-least)
24
+ ### a minimally working Ruby environment, with the required gems installed. Various
25
+ ### 'First Boot' scripts are available in the `scripts` directory for different
26
+ ### platforms which will achieve at least this minimal state
27
+ ###
28
+
29
+ # Add lib to load path
30
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
31
+
32
+ # Load the rubygems library
33
+ require 'rubygems'
34
+
35
+ # Load core application library
36
+ require 'SANStore'
37
+
38
+ # Load command line handler
39
+ require 'SANStore/cri'
40
+ require 'SANStore/cli'
41
+
42
+ # Load the commands from the cmds dir
43
+ plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../cmds')
44
+
45
+ Dir[plugin_dir + '/*.rb'].sort.each{|file|
46
+ require file
47
+ }
48
+
49
+ # Run base
50
+ SANStore::CLI::Base.new.run(ARGV)
@@ -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 SANStore
17
+
18
+ ## Define Application Global constants
19
+
20
+ # The current SANStore 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 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'
@@ -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 +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