This repository has been archived by the owner on Jan 19, 2019. It is now read-only.
forked from MsysTechnologiesllc/netapp
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Cesar Felce
committed
Jul 3, 2017
1 parent
b2c09c1
commit 4e7055f
Showing
9 changed files
with
198 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Cookbook Name:: netapp | ||
# Provider:: igroup | ||
# | ||
|
||
include NetApp::Api | ||
|
||
use_inline_resources | ||
|
||
action :create do | ||
|
||
# Create API Request. | ||
netapp_igroup_api = netapp_hash | ||
|
||
netapp_igroup_api[:api_name] = "igroup-create" | ||
netapp_igroup_api[:resource] = "igroup" | ||
netapp_igroup_api[:action] = "create" | ||
netapp_igroup_api[:svm] = new_resource.svm | ||
netapp_igroup_api[:api_attribute]["initiator-group-name"] = new_resource.name | ||
netapp_igroup_api[:api_attribute]["initiator-group-type"] = new_resource.igroup_type | ||
netapp_igroup_api[:api_attribute]["os-type"] = new_resource.ostype | ||
|
||
# Invoke NetApp API. | ||
resource_update = invoke(netapp_igroup_api) | ||
new_resource.updated_by_last_action(true) if resource_update | ||
|
||
end | ||
|
||
action :add_rule do | ||
|
||
# Create API Request. | ||
netapp_igroup_add_api = netapp_hash | ||
|
||
netapp_igroup_add_api[:api_name] = "igroup-add" | ||
netapp_igroup_add_api[:resource] = "igroup" | ||
netapp_igroup_add_api[:action] = "add_rule" | ||
netapp_igroup_add_api[:svm] = new_resource.svm | ||
netapp_igroup_add_api[:api_attribute]["initiator-group-name"] = new_resource.name | ||
netapp_igroup_add_api[:api_attribute]["initiator"] = new_resource.initiator | ||
|
||
# Invoke NetApp API. | ||
resource_update = invoke(netapp_igroup_add_api) | ||
new_resource.updated_by_last_action(true) if resource_update | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Cookbook Name:: netapp | ||
# Provider:: lun | ||
# | ||
# Copyright:: 2014, Chef Software, Inc <[email protected]> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
include NetApp::Api | ||
|
||
use_inline_resources | ||
|
||
action :create do | ||
|
||
# Create API Request. | ||
netapp_lun_create_api = netapp_hash | ||
|
||
netapp_lun_create_api[:api_name] = "lun-create-by-size" | ||
netapp_lun_create_api[:resource] = "lun" | ||
netapp_lun_create_api[:action] = "create" | ||
netapp_lun_create_api[:svm] = new_resource.svm | ||
netapp_lun_create_api[:api_attribute]["ostype"] = new_resource.ostype | ||
netapp_lun_create_api[:api_attribute]["size"] = new_resource.size | ||
netapp_lun_create_api[:api_attribute]["prefix-size"] = new_resource.psize | ||
netapp_lun_create_api[:api_attribute]["path"] = new_resource.path | ||
netapp_lun_create_api[:api_attribute]["comment"] = new_resource.comment | ||
netapp_lun_create_api[:api_attribute]["space-allocation-enabled"] = new_resource.allocation | ||
netapp_lun_create_api[:api_attribute]["space-reservation-enabled"] = new_resource.reservation | ||
|
||
# Invoke NetApp API. | ||
resource_update = invoke(netapp_lun_create_api) | ||
new_resource.updated_by_last_action(true) if resource_update | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#Igroup create | ||
netapp_igroup node['igroup']['name'] do | ||
svm node['netapp']['vserver'] | ||
igroup_type node['igroup']['igroup_type'] | ||
ostype node['igroup']['ostype'] | ||
action :create | ||
end | ||
|
||
#Igroup add initiator | ||
netapp_igroup node['igroup']['name'] do | ||
svm node['netapp']['vserver'] | ||
initiator node['igroup']['initiator'] | ||
action :add_rule | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Cookbook Name:: netapp | ||
# Recipe:: lun | ||
|
||
|
||
#EXAMPLE CREATING ISCSI LUN VOL SHOULD EXISTS | ||
lpath = "/vol/demo_vol/demo_lun" | ||
netapp_lun lun do | ||
svm node['netapp']['vserver'] | ||
path lpath | ||
size ((50*1024**3).to_i).to_s | ||
ostype "linux" | ||
action :create | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# Author:: Cesar Felce (<[email protected]>) | ||
# Cookbook Name:: netapp | ||
# Resource:: igroup | ||
# | ||
|
||
actions :create, :add_rule | ||
default_action :create | ||
|
||
attribute :name, :kind_of => String, :required => true, :name_attribute => true | ||
attribute :svm, :kind_of => String | ||
|
||
attribute :ostype, :kind_of => String, :required => true, :equal_to => ["aix", "linux", "vmware", "windows"] | ||
attribute :igroup_type, :kind_of => String, :required => true | ||
|
||
attribute :initiator, :kind_of => String, :required => true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# Author:: Cesar Felce (<[email protected]>) | ||
# Cookbook Name:: netapp | ||
# Resource:: lun | ||
# | ||
# Copyright:: 2014, Chef Software, Inc <[email protected]> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
actions :create | ||
default_action :create | ||
|
||
attribute :name, :kind_of => String, :required => true, :name_attribute => true | ||
attribute :svm, :kind_of => String | ||
|
||
attribute :ostype, :kind_of => String, :required => true, :equal_to => ["aix", "linux", "vmware", "windows_2008"] | ||
attribute :size, :kind_of => String, :required => true | ||
attribute :psize, :kind_of => Fixnum, :required => false, :default => 512 | ||
attribute :path, :kind_of => String, :required => true | ||
attribute :comment, :kind_of => String, :required => false, :default => "chef" | ||
attribute :allocation, :kind_of => String, :required => false, :default => "true" | ||
attribute :reservation, :kind_of => String, :required => false, :default => "false" | ||
|
||
attribute :igroup, :kind_of => String, :required => true | ||
attribute :id, :kind_of => String, :required => true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require_relative '../spec_helper' | ||
require_relative '../helpers/matchers' | ||
|
||
describe 'netapp::lun' do | ||
context 'without :step_into' do | ||
let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe)} | ||
|
||
it 'creates a new lun' do | ||
expect(chef_run).to create_netapp_lun('demo_lun').with( | ||
svm: "cluster2", | ||
aggregate: "aggr1", | ||
size: "50", #GB | ||
ostype: "linux" | ||
) | ||
end | ||
|
||
end | ||
end |