shu-san-scripts 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
1
+ # Copyright (c) 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 David Love
17
+
18
+ # Defines a class capable of manipulating ZFS volumes. This classes uses
19
+ # the standard command line tools (+zfs+ and +zpool+), not the C API.
20
+ class ZFS
21
+
22
+ # Create a new volume, at the specified location and of the specified
23
+ # size.
24
+ #
25
+ # NOTE: This command currently only supports the creation of sparse
26
+ # volumes. If you really need pre-allocated volumes for some reason,
27
+ # this command needs to be extended
28
+ def self.new_volume(volume_path, volume_size)
29
+
30
+ # Create the volume
31
+ SANStore::CLI::Logger.instance.log_level(:low, :create, "#{volume_size} ZFS volume at #{volume_path}")
32
+ cmd = %x[zfs create -s -V #{volume_size} #{volume_path}]
33
+
34
+ end
35
+
36
+ # Delete (destroy) a volume from the ZFS pool. This command can handle
37
+ # both raw paths, and absolute paths.
38
+ def self.delete_volume(volume_path)
39
+
40
+ # Work out if this is a raw volume path, or an absolute path
41
+ if volume_path.index(/\/dev\/zvol\/rdsk/) then
42
+ # This is a relative path, so we need to split the
43
+ # device prefix off to get the volume path
44
+ volume_path = volume_path.partition(/\/dev\/zvol\/rdsk/)[2]
45
+ end
46
+
47
+ # Remove any slash prefixes
48
+ if volume_path[0] == 0x2F then
49
+ volume_path = volume_path[1..volume_path.length]
50
+ end
51
+
52
+ # Delete the volume from the system
53
+ SANStore::CLI::Logger.instance.log_level(:low, :delete, "Removing ZFS volume #{volume_path} from the file-store")
54
+ cmd = %x[zfs destroy -r -f #{volume_path}]
55
+
56
+ end
57
+
58
+ end
59
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shu-san-scripts
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Love
@@ -173,16 +173,35 @@ dependencies:
173
173
  prerelease: false
174
174
  description: See the README file.
175
175
  email: david@homeunix.org.uk
176
- executables: []
177
-
176
+ executables:
177
+ - store
178
178
  extensions: []
179
179
 
180
180
  extra_rdoc_files:
181
181
  - LICENSE.txt
182
182
  - README.rdoc
183
183
  files:
184
+ - lib/SANStore.rb
185
+ - lib/SANStore/cli.rb
186
+ - lib/SANStore/cli/base.rb
187
+ - lib/SANStore/cli/commands.rb
188
+ - lib/SANStore/cli/commands/delete_vol.rb
189
+ - lib/SANStore/cli/commands/help.rb
190
+ - lib/SANStore/cli/commands/list_vols.rb
191
+ - lib/SANStore/cli/commands/new_vol.rb
192
+ - lib/SANStore/cli/logger.rb
193
+ - lib/SANStore/cri.rb
194
+ - lib/SANStore/cri/base.rb
195
+ - lib/SANStore/cri/command.rb
196
+ - lib/SANStore/cri/core_ext.rb
197
+ - lib/SANStore/cri/core_ext/string.rb
198
+ - lib/SANStore/cri/option_parser.rb
199
+ - lib/SANStore/helpers/uuid.rb
200
+ - lib/SANStore/iSCSI/comstar.rb
201
+ - lib/SANStore/zfs/zfs.rb
184
202
  - LICENSE.txt
185
203
  - README.rdoc
204
+ - bin/store
186
205
  homepage: http://github.com/dlove24/shu-san-scripts
187
206
  licenses:
188
207
  - ISC