net_app_manageability 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 12e9bc7a7c8b1d17e7a3557e9b15368ba29ab827
4
+ data.tar.gz: 803b7f6d60916bab77a87794947f5adc0ea4f50d
5
+ SHA512:
6
+ metadata.gz: 31c7a4e272673efde95fe8afea55dd7b5ceaefbc2b8708b117696de7afb3440c65fc0470edb8df2f53ddc149b31ca532e9d35d5c8444d9f3d06b8ff46d556174
7
+ data.tar.gz: e672edf77f9cd6472e15aa57ac06dc9f5da6c7c2740cbe3890f613b12a39f1727b5ce4e4c8860c253bd533445076443d85a1f50c24a3a5dcc89d6064e9145d17
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.so
11
+ *.bundle
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in net_app_manageability.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Red Hat, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,76 @@
1
+ # NetAppManageability
2
+
3
+ Ruby binding to NetApp Manageability SDK.
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/net_app_manageability.svg)](http://badge.fury.io/rb/net_app_manageability)
6
+ [![Code Climate](http://img.shields.io/codeclimate/github/ManageIQ/net_app_manageability.svg)](https://codeclimate.com/github/ManageIQ/net_app_manageability)
7
+ [![Dependency Status](https://gemnasium.com/ManageIQ/net_app_manageability.svg)](https://gemnasium.com/ManageIQ/net_app_manageability)
8
+
9
+ ## Installation
10
+
11
+ First, install the NetApp Manageability SDK.
12
+
13
+ - This is only provided by NetApp directly. For the next steps, we will assume these files are located in `$INSTALL_DIR`.
14
+
15
+ - Create symlinks for libssl and libcrypto, if necessary.
16
+
17
+ ```sh
18
+ ln -s libssl.so $INSTALL_DIR/lib/linux-64/libssl.so.0.9.8
19
+ ln -s libcrypto.so $INSTALL_DIR/lib/linux-64/libcrypto.so.0.9.8
20
+ ```
21
+
22
+ Next, if using bundler
23
+
24
+ - Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem 'net_app_manageability'
28
+ ```
29
+
30
+ - If the NetApp Manageability SDK is not available on the normal compile paths, then execute:
31
+
32
+ ```sh
33
+ bundle config build.net_app_manageability --with-netapp-manageability-sdk-include=$INSTALL_DIR/include --with-netapp-manageability-sdk-lib=$INSTALL_DIR/lib/linux-64
34
+ ```
35
+
36
+ - And finally execute:
37
+
38
+ ```sh
39
+ bundle
40
+ ```
41
+
42
+ Otherwise, if not using bundler
43
+
44
+ - If the NetApp Manageability SDK is not available on the normal compile paths, then execute:
45
+
46
+ ```sh
47
+ gem install net_app_manageability --with-netapp-manageability-sdk-include=$INSTALL_DIR/include --with-netapp-manageability-sdk-lib=$INSTALL_DIR/lib/linux-64
48
+ ```
49
+
50
+ - Otherwise execute:
51
+
52
+ ```sh
53
+ gem install net_app_manageability
54
+ ```
55
+
56
+ ## Usage
57
+
58
+ For examples of usage, see the [examples](examples).
59
+
60
+ ## Development
61
+
62
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to compile the gem and run the tests. If you want to just compile the gem, use `rake compile`. If the NetApp Manageability SDK is not accessible via the normal compile paths, you make have to pass those locations to `rake compile` as follows:
63
+
64
+ rake compile -- --with-netapp-manageability-sdk-include=$INSTALL_DIR/include --with-netapp-manageability-sdk-lib=$INSTALL_DIR/lib/linux-64
65
+
66
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
67
+
68
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
69
+
70
+ ## Contributing
71
+
72
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ManageIQ/net_app_manageability.
73
+
74
+ ## License
75
+
76
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/extensiontask'
4
+ Rake::ExtensionTask.new do |ext|
5
+ ext.name = 'net_app_manageability'
6
+ ext.ext_dir = 'ext/net_app_manageability'
7
+ ext.lib_dir = 'lib/net_app_manageability'
8
+ end
9
+
10
+ require "rspec/core/rake_task"
11
+ RSpec::Core::RakeTask.new(:spec => :compile)
12
+
13
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "net_app_manageability"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ require "net_app_manageability"
2
+ svr = NetAppManageability::API.server_open(SERVER, 1, 1)
3
+ NetAppManageability::API.server_style(svr, NetAppManageability::API::NA_STYLE_LOGIN_PASSWORD)
4
+ NetAppManageability::API.server_adminuser(svr, USERNAME, PASSWORD)
5
+ rv = NetAppManageability::API.server_invoke(svr, "volume-list-info", :volume => "vol1")
6
+
7
+ puts "RV: #{rv.inspect}"
@@ -0,0 +1,45 @@
1
+ require 'net_app_manageability'
2
+ require 'logger'
3
+
4
+ SERVER = raise "please define server"
5
+ USERNAME = ""
6
+ PASSWORD = ""
7
+
8
+ netapp_client = NetAppManageability::Client.new do
9
+ server SERVER
10
+ auth_style NetAppManageability::Client::NA_STYLE_LOGIN_PASSWORD
11
+ username USERNAME
12
+ password PASSWORD
13
+ end
14
+
15
+ puts
16
+ puts "*** No options - list info for all volumes:"
17
+ rv = netapp_client.volume_list_info
18
+ puts rv.inspect
19
+
20
+ #
21
+ # Different ways of mking the same call.
22
+ #
23
+ puts
24
+ puts "*** List info for a specific volume V1:"
25
+ rv = netapp_client.volume_list_info(:volume => "vol1")
26
+ puts rv.inspect
27
+
28
+ puts
29
+ puts "*** List info for a specific volume V2:"
30
+ rv = netapp_client.volume_list_info(:volume, "vol1")
31
+ puts rv.inspect
32
+
33
+ puts
34
+ puts "*** List info for a specific volume V3:"
35
+ rv = netapp_client.volume_list_info do
36
+ volume "vol1"
37
+ end
38
+ puts rv.inspect
39
+
40
+ puts
41
+ puts "*** List info for a specific volume V4:"
42
+ rv = netapp_client.volume_list_info do |vla|
43
+ vla.volume = "vol1"
44
+ end
45
+ puts rv.inspect
@@ -0,0 +1,96 @@
1
+ require 'net_app_manageability'
2
+ require 'logger'
3
+
4
+ SERVER = raise "please define server"
5
+ USERNAME = ""
6
+ PASSWORD = ""
7
+
8
+ GB = 1024 * 1024 *1024
9
+ CONTAINING_AGGR = "aggr1"
10
+ NEW_VOLUME = "api_test_vol1"
11
+ VOL_SIZE_GB = 10
12
+ NFS_PATH = "/vol/#{NEW_VOLUME}"
13
+ ROOT_HOSTS = [ HOST1, HOST2 ]
14
+
15
+ NetAppManageability.logger = Logger.new(STDOUT)
16
+ NetAppManageability.wire_dump = false
17
+
18
+ netapp_client = NetAppManageability::Client.new do
19
+ server SERVER
20
+ auth_style NetAppManageability::Client::NA_STYLE_LOGIN_PASSWORD
21
+ username USERNAME
22
+ password PASSWORD
23
+ end
24
+
25
+ #
26
+ # Ensure the volume doesn't already exist.
27
+ #
28
+ err = false
29
+ begin
30
+ netapp_client.volume_list_info(:volume, NEW_VOLUME)
31
+ err = true
32
+ rescue
33
+ # Ignore expected failure
34
+ end
35
+ raise "Volume #{NEW_VOLUME} already exists" if err
36
+
37
+ #
38
+ # Make sure there's enough free space in the aggregate for the new volume.
39
+ #
40
+ rv = netapp_client.aggr_list_info(:aggregate, CONTAINING_AGGR)
41
+ aggr_free_space = rv.aggregates.aggr_info.size_available.to_i
42
+ raise "Insufficient free space in #{CONTAINING_AGGR}: #{aggr_free_space}" if aggr_free_space < VOL_SIZE_GB * GB
43
+
44
+ #
45
+ # The creation of the volume will result in the creation a qtree entry for its root.
46
+ # If we want to base a VMware datastore on the volume's NFS share, the security style of
47
+ # its corresponding qtree must not be 'ntfs'.
48
+ #
49
+ # Unfortunately, the API doesn't provide a way to specify this value or change it after the fact.
50
+ # The security style is always set to the value of the 'wafl.default_security_style' option.
51
+ # So we must ensure that this value is set to either 'unix' or 'mixed' before the volume is created.
52
+ #
53
+ rv = netapp_client.options_get(:name, 'wafl.default_security_style')
54
+ if rv.value == "ntfs"
55
+ puts "Default security style is ntfs, resetting it to mixed"
56
+ rv = netapp_client.options_set do
57
+ name 'wafl.default_security_style'
58
+ value 'mixed'
59
+ end
60
+ end
61
+
62
+ #
63
+ # Create the volume within the given aggregate.
64
+ #
65
+ rv = netapp_client.volume_create do
66
+ containing_aggr_name CONTAINING_AGGR
67
+ volume NEW_VOLUME
68
+ space_reserve "none"
69
+ size "#{VOL_SIZE_GB}g"
70
+ end
71
+
72
+ #
73
+ # Get the export rules for the new volume's NFS share.
74
+ #
75
+ rv = netapp_client.nfs_exportfs_list_rules(:pathname, NFS_PATH)
76
+
77
+ #
78
+ # Add a list of root access hosts to the rules.
79
+ # These are the ESX hosts that will be able to access the datastore.
80
+ #
81
+ rules = rv.rules
82
+ rules.exports_rule_info.root = NetAppManageability::NAMHash.new do
83
+ exports_hostname_info NetAppManageability::NAMArray.new do
84
+ ROOT_HOSTS.each do |rh|
85
+ push NetAppManageability::NAMHash.new { name rh }
86
+ end
87
+ end
88
+ end
89
+
90
+ #
91
+ # Update the export rules with the root access host list.
92
+ #
93
+ rv = netapp_client.nfs_exportfs_modify_rule do
94
+ persistent true
95
+ rule rules
96
+ end
@@ -0,0 +1,20 @@
1
+ require 'net_app_manageability'
2
+ require 'logger'
3
+
4
+ SERVER = raise "please define server"
5
+ USERNAME = ""
6
+ PASSWORD = ""
7
+
8
+ netapp_client = NetAppManageability::Client.new do
9
+ server SERVER
10
+ auth_style NetAppManageability::Client::NA_STYLE_LOGIN_PASSWORD
11
+ username USERNAME
12
+ password PASSWORD
13
+ end
14
+
15
+ rv = netapp_client.aggr_list_info
16
+
17
+ aia = rv.aggregates.aggr_info.to_ary
18
+ aia.each do |ai|
19
+ puts "Aggregate: #{ai.name}\tavailable space: #{ai.size_available}"
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'net_app_manageability'
2
+ require 'logger'
3
+
4
+ SERVER = raise "please define server"
5
+ USERNAME = ""
6
+ PASSWORD = ""
7
+
8
+ netapp_client = NetAppManageability::Client.new do
9
+ server SERVER
10
+ auth_style NetAppManageability::Client::NA_STYLE_LOGIN_PASSWORD
11
+ username USERNAME
12
+ password PASSWORD
13
+ end
14
+
15
+ rv = netapp_client.volume_list_info
16
+
17
+ aia = rv.volumes.volume_info.to_ary
18
+ aia.each do |ai|
19
+ puts "Volume: #{ai.name}\tavailable space: #{ai.size_available}"
20
+ end
@@ -0,0 +1,29 @@
1
+ require 'net_app_manageability'
2
+ require 'logger'
3
+
4
+ SERVER = raise "please define server"
5
+ USERNAME = ""
6
+ PASSWORD = ""
7
+
8
+ netapp_client = NetAppManageability::Client.new do
9
+ server SERVER
10
+ auth_style NetAppManageability::Client::NA_STYLE_LOGIN_PASSWORD
11
+ username USERNAME
12
+ password PASSWORD
13
+ end
14
+
15
+ rv = netapp_client.lun_list_info
16
+ puts rv.inspect
17
+ puts
18
+
19
+ rv = netapp_client.lun_map_list_info(:path, '/vol/luns/lun1')
20
+ puts rv.inspect
21
+ puts
22
+
23
+ rv = netapp_client.iscsi_adapter_initiators_list_info
24
+ puts rv.inspect
25
+ puts
26
+
27
+ rv = netapp_client.iscsi_connection_list_info
28
+ puts rv.inspect
29
+ puts
@@ -0,0 +1,51 @@
1
+ require 'net_app_manageability'
2
+ require 'logger'
3
+
4
+ SERVER = raise "please define server"
5
+ USERNAME = ""
6
+ PASSWORD = ""
7
+
8
+ netapp_client = NetAppManageability::Client.new do
9
+ server SERVER
10
+ auth_style NetAppManageability::Client::NA_STYLE_LOGIN_PASSWORD
11
+ username USERNAME
12
+ password PASSWORD
13
+ end
14
+
15
+ rv = netapp_client.nfs_exportfs_list_rules(:pathname, "/vol/#{VOLUME_NAME}")
16
+ raise "No export rules found for path /vol/#{VOLUME_NAME}" unless rv.kind_of?(NetAppManageability::NAMHash)
17
+
18
+ rules = rv.rules
19
+ rules.exports_rule_info.root = NetAppManageability::NAMHash.new if rules.exports_rule_info.root.nil?
20
+ if rules.exports_rule_info.root.exports_hostname_info.nil?
21
+ rules.exports_rule_info.root.exports_hostname_info = NetAppManageability::NAMArray.new
22
+ else
23
+ rules.exports_rule_info.root.exports_hostname_info = rules.exports_rule_info.root.exports_hostname_info.to_ary
24
+ end
25
+
26
+ rha = rules.exports_rule_info.root.exports_hostname_info
27
+
28
+ changed = false
29
+ ROOT_HOSTS.each do |nrhn|
30
+ skip = false
31
+ rha.each do |crhh|
32
+ if crhh.name == nrhn
33
+ skip = true
34
+ break
35
+ end
36
+ end
37
+ next if skip
38
+
39
+ rha << NetAppManageability::NAMHash.new { name nrhn }
40
+ changed = true
41
+ end
42
+
43
+ if changed
44
+ puts "Updating rules"
45
+ netapp_client.nfs_exportfs_modify_rule do
46
+ persistent true
47
+ rule rules
48
+ end
49
+ else
50
+ puts "No change to rules, not updating"
51
+ end