Skip to content

Commit

Permalink
Add vfiler support
Browse files Browse the repository at this point in the history
NetApp allows multiple virtual filer to run on one physical filer. Every
API command runs under a specific vfiler context.

Managing a vfiler while connecting to the actual physical filer has the
benefit that you do not have to have network access to your vfiler
(e.g. you can place a vfiler in a DMZ network while your physical filer
is only accessable through your internal network).

The NetApp Server class already implements a method `set_vfiler` that
changes the context for all following api calls.

Allow passing a vfiler via the connection url. So instead of using

    [filer.example.com]
      type netapp
      url https://user:[email protected]

we accept the connection url `https://user:[email protected]/[virtalfiler]`
  • Loading branch information
stschulte authored and fatmcgav committed Jul 22, 2013
1 parent 419aa97 commit eadb815
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
9 changes: 9 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ Example configuration `/etc/puppet/device/pfiler01.example.com.conf`:
type netapp
url https://root:[email protected]

You can also specify a virtual filer you want to operate on: Simply
provide the connection information for your physical filer and specify
an optional path that represents the name of your virtual filer. Example
configuration `/etc/puppet/device/vfiler01.example.com.conf`:

[vfiler01.example.com]
type netapp
url https://root:[email protected]/vfiler01

### NetApp operations
As part of this module, there is a defined type called 'netapp::vqe', which can be used to create a volume, add a qtree and create an NFS export.
An example of this is:
Expand Down
5 changes: 5 additions & 0 deletions lib/puppet/util/network_device/netapp/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def initialize(url)
@transport.set_admin_user(@url.user, @url.password)
@transport.set_transport_type(@url.scheme.upcase)
@transport.set_port(@url.port)
if match = %r{/([^/]+)}.match(@url.path)
@vfiler = match.captures[0]
@transport.set_vfiler(@vfiler)
Puppet.debug("Puppet::Device::Netapp: vfiler context has been set to #{@vfiler}")
end

result = @transport.invoke("system-get-version")
if(result.results_errno != 0)
Expand Down
25 changes: 15 additions & 10 deletions spec/unit/puppet/util/network_device/netapp/device_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@
YAML.load_file(my_fixture('system-get-version.yml'))
end

let :mock_device do
mock 'server object',
:set_admin_user => nil,
:set_transport_type => nil,
:set_port =>nil,
:invoke => version
end



describe "when connecting to a new device" do
it "should reject a single hostname" do
expect { described_class.new('pfiler.example.com') }.to raise_error ArgumentError, /Invalid scheme/
Expand Down Expand Up @@ -49,5 +39,20 @@

described_class.new('https://root:[email protected]')
end

it "should support vfiler" do
transport = mock 'netapp server'
NaServer.expects(:new).with('pfiler.example.com', 1, 13).returns transport
Puppet.expects(:debug).with regexp_matches %r{connecting to Netapp device https://root:\*\*\*\*@pfiler\.example\.com}
Puppet.expects(:debug).with regexp_matches /^Puppet::Device::Netapp: Version = /
Puppet.expects(:debug).with 'Puppet::Device::Netapp: vfiler context has been set to VFILER01'
transport.expects(:set_admin_user).with('root', 'secret')
transport.expects(:set_transport_type).with('HTTPS')
transport.expects(:set_port).with(443)
transport.expects(:set_vfiler).with('VFILER01')
transport.expects(:invoke).with('system-get-version').returns version

described_class.new('https://root:[email protected]/VFILER01/reserved_for_later_usage')
end
end
end

0 comments on commit eadb815

Please sign in to comment.