├── .fixtures.yml ├── .gitignore ├── .project ├── .travis.yml ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── lib ├── puppet │ ├── provider │ │ ├── transport │ │ │ └── default.rb │ │ ├── vnx_array │ │ │ └── vnx_array.rb │ │ ├── vnx_dns │ │ │ └── vnx_dns.rb │ │ ├── vnx_domain │ │ │ └── vnx_domain.rb │ │ ├── vnx_fastcache │ │ │ └── vnx_fastcache.rb │ │ ├── vnx_initiator │ │ │ └── vnx_initiator.rb │ │ ├── vnx_lun │ │ │ └── vnx_lun.rb │ │ ├── vnx_nqm │ │ │ └── vnx_nqm.rb │ │ ├── vnx_ntp │ │ │ └── vnx_ntp.rb │ │ ├── vnx_sp │ │ │ └── vnx_sp.rb │ │ ├── vnx_storagegroup │ │ │ └── vnx_storagegroup.rb │ │ └── vnx_storagepool │ │ │ └── vnx_storagepool.rb │ └── type │ │ ├── transport.rb │ │ ├── vnx_analyzer.rb │ │ ├── vnx_array.rb │ │ ├── vnx_autotiering.rb │ │ ├── vnx_dns.rb │ │ ├── vnx_domain.rb │ │ ├── vnx_eventmonitor.rb │ │ ├── vnx_eventtemplate.rb │ │ ├── vnx_fastcache.rb │ │ ├── vnx_initiator.rb │ │ ├── vnx_iscsiport.rb │ │ ├── vnx_ldap.rb │ │ ├── vnx_lun.rb │ │ ├── vnx_nqm.rb │ │ ├── vnx_ntp.rb │ │ ├── vnx_sp.rb │ │ ├── vnx_storagegroup.rb │ │ ├── vnx_storagepool.rb │ │ └── vnx_storagesystemcache.rb └── puppet_x │ └── puppetlabs │ └── transport │ └── emc_vnx.rb ├── metadata.json ├── spec └── spec_helper.rb └── tests ├── init.pp ├── initiator.pp ├── lun.pp ├── storage_group.pp └── storage_pool.pp /.fixtures.yml: -------------------------------------------------------------------------------- 1 | fixtures: 2 | symlinks: 3 | vnx: "#{source_dir}" 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | pkg/ 2 | Gemfile.lock 3 | vendor/ 4 | spec/fixtures/ 5 | .vagrant/ 6 | .bundle/ 7 | coverage/ 8 | .*.sw* 9 | .vendor/ 10 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | puppet-vnx 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.xtext.ui.shared.xtextBuilder 10 | 11 | 12 | 13 | 14 | 15 | com.puppetlabs.geppetto.pp.dsl.ui.puppetNature 16 | org.eclipse.xtext.ui.shared.xtextNature 17 | 18 | 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: ruby 3 | bundler_args: --without development 4 | before_install: rm Gemfile.lock || true 5 | sudo: false 6 | rvm: 7 | - 2.3.1 8 | - 2.2.4 9 | - 2.1.9 10 | - 2.0.0 11 | - 1.9.3 12 | script: "bundle exec rake validate" 13 | env: 14 | - PUPPET_GEM_VERSION="~> 3.6.0" 15 | - PUPPET_GEM_VERSION="~> 3.6.0" STRICT_VARIABLES=yes 16 | - PUPPET_GEM_VERSION="~> 3.7.0" 17 | - PUPPET_GEM_VERSION="~> 3.7.0" STRICT_VARIABLES=yes 18 | - PUPPET_GEM_VERSION="~> 3.7.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes 19 | - PUPPET_GEM_VERSION="~> 3.8.0" 20 | - PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes 21 | - PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes 22 | - PUPPET_GEM_VERSION="~> 4.0.0" 23 | - PUPPET_GEM_VERSION="~> 4.1.0" 24 | - PUPPET_GEM_VERSION="~> 4.2.0" 25 | - PUPPET_GEM_VERSION="~> 4.3.0" 26 | - PUPPET_GIT_URL="https://github.com/puppetlabs/puppet.git" 27 | matrix: 28 | fast_finish: true 29 | exclude: 30 | - rvm: 2.3.1 31 | env: PUPPET_GEM_VERSION="~> 3.6.0" 32 | - rvm: 2.3.1 33 | env: PUPPET_GEM_VERSION="~> 3.6.0" STRICT_VARIABLES=yes 34 | - rvm: 2.3.1 35 | env: PUPPET_GEM_VERSION="~> 3.7.0" 36 | - rvm: 2.3.1 37 | env: PUPPET_GEM_VERSION="~> 3.7.0" STRICT_VARIABLES=yes 38 | - rvm: 2.3.1 39 | env: PUPPET_GEM_VERSION="~> 3.7.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes 40 | - rvm: 2.3.1 41 | env: PUPPET_GEM_VERSION="~> 3.8.0" 42 | - rvm: 2.3.1 43 | env: PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes 44 | - rvm: 2.3.1 45 | env: PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes 46 | - rvm: 2.2.4 47 | env: PUPPET_GEM_VERSION="~> 3.6.0" 48 | - rvm: 2.2.4 49 | env: PUPPET_GEM_VERSION="~> 3.6.0" STRICT_VARIABLES=yes 50 | - rvm: 2.2.4 51 | env: PUPPET_GEM_VERSION="~> 3.7.0" 52 | - rvm: 2.2.4 53 | env: PUPPET_GEM_VERSION="~> 3.7.0" STRICT_VARIABLES=yes 54 | - rvm: 2.2.4 55 | env: PUPPET_GEM_VERSION="~> 3.7.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes 56 | - rvm: 2.2.4 57 | env: PUPPET_GEM_VERSION="~> 3.8.0" 58 | - rvm: 2.2.4 59 | env: PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes 60 | - rvm: 2.2.4 61 | env: PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes 62 | - rvm: 1.9.3 63 | env: PUPPET_GEM_VERSION="~> 3.6.0" 64 | - rvm: 1.9.3 65 | env: PUPPET_GEM_VERSION="~> 3.6.0" STRICT_VARIABLES=yes 66 | - rvm: 1.9.3 67 | env: PUPPET_GEM_VERSION="~> 3.7.0" 68 | - rvm: 1.9.3 69 | env: PUPPET_GEM_VERSION="~> 3.7.0" STRICT_VARIABLES=yes 70 | - rvm: 1.9.3 71 | env: PUPPET_GEM_VERSION="~> 3.7.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes 72 | - rvm: 1.9.3 73 | env: PUPPET_GEM_VERSION="~> 3.8.0" 74 | - rvm: 1.9.3 75 | env: PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes 76 | - rvm: 1.9.3 77 | env: PUPPET_GEM_VERSION="~> 3.8.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes 78 | - rvm: 1.9.3 79 | env: PUPPET_GEM_VERSION="~> 4.0.0" 80 | - rvm: 1.9.3 81 | env: PUPPET_GEM_VERSION="~> 4.1.0" 82 | - rvm: 1.9.3 83 | env: PUPPET_GEM_VERSION="~> 4.2.0" 84 | - rvm: 1.9.3 85 | env: PUPPET_GEM_VERSION="~> 4.3.0" 86 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source ENV['GEM_SOURCE'] || "https://rubygems.org" 2 | 3 | group :development, :unit_tests do 4 | gem "rake", "~> 10.0" 5 | gem 'rspec', '~> 2.0', :require => false 6 | gem 'rspec-puppet', '>= 2.1.0', :require => false 7 | gem 'puppetlabs_spec_helper', :require => false 8 | gem 'puppet-lint', '>= 1.1.0', :require => false 9 | gem 'puppet_facts', :require => false 10 | gem 'puppet-lint-unquoted_string-check', :require => false 11 | gem 'puppet-lint-empty_string-check', :require => false 12 | gem 'puppet-lint-leading_zero-check', :require => false 13 | gem 'puppet-lint-variable_contains_upcase', :require => false 14 | end 15 | 16 | if facterversion = ENV['FACTER_GEM_VERSION'] 17 | gem 'facter', facterversion, :require => false 18 | else 19 | gem 'facter', :require => false 20 | end 21 | 22 | if puppetversion = ENV['PUPPET_GEM_VERSION'] 23 | gem 'puppet', puppetversion, :require => false 24 | else 25 | gem 'puppet', :require => false 26 | end 27 | 28 | # vim:ft=ruby 29 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2014, 2015 ClusterHQ 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Puppet VNX Module 2 | Puppet VNX module wraps Naviseccli into Puppet module to simplify the configuration of VNX Initiator, DNS, Storage Pool, Hot Spare, Storage Group, LUN, Fast Cache, NTP, Domain, SP and Array. 3 | 4 | CI Status 5 | --------- 6 | [![Build Status](https://api.travis-ci.org/emccode/puppet-vnx.svg?branch=master)](https://travis-ci.org/emccode/puppet-vnx) 7 | 8 | Prerequisite 9 | ------- 10 | Ruby >= 1.9.3 11 | RubyGem >= 3.6.0 12 | 13 | Prepare 14 | ------- 15 | Download and install Navisphere CLI 16 | 17 | For VNX1 Series: https://support.emc.com/downloads/12781_VNX1-Series 18 | 19 | For VNX2 Series: https://support.emc.com/downloads/36656_VNX2-Series 20 | 21 | Example 22 | ------- 23 | ```puppet 24 | transport {'vnx5400': 25 | username => 'nasadmin', 26 | password => 'nasadmin', 27 | server => '10.10.166.9' 28 | } 29 | 30 | vnx_storagepool {"elc-cloud": 31 | disks => ['0_0_4', '0_0_5', '0_0_6', '0_0_7', '0_0_8'], 32 | raid_type => 'r_5', 33 | transport => Transport['vnx5400'], 34 | ensure => present 35 | } 36 | ``` 37 | Notice: Type parameters refer to Navisphere CLI parameters 38 | 39 | 40 | TO DO 41 | ------- 42 | * Add more configurable resources 43 | 44 | 45 | License 46 | ------- 47 | Licensed under the Apache License, Version 2.0 (the “License”). See LICENSE for details. 48 | 49 | 50 | Contact 51 | ------- 52 | jie.bao@emc.com 53 | layne.peng@emc.com 54 | 55 | 56 | Support 57 | ------- 58 | Please file bugs and issues on the Github issues page for this project. This is to help keep track and document everything related to this repo. For general discussions and further support you can join the [EMC {code} Community slack channel](http://community.emccode.com/). Lastly, for questions asked on [Stackoverflow.com](https://stackoverflow.com) please tag them with **EMC**. The code and documentation are released with no warranties or SLAs and are intended to be supported through a community driven process. 59 | 60 | 61 | Please log tickets and issues at our [Projects site](http://projects.example.com) -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'puppetlabs_spec_helper/rake_tasks' 3 | require 'puppet-lint/tasks/puppet-lint' 4 | PuppetLint.configuration.send('disable_80chars') 5 | PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] 6 | 7 | desc "Validate manifests, templates, and ruby files" 8 | task :validate do 9 | Dir['manifests/**/*.pp'].each do |manifest| 10 | sh "puppet parser validate --noop #{manifest}" 11 | end 12 | Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file| 13 | sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ 14 | end 15 | Dir['templates/**/*.erb'].each do |template| 16 | sh "erb -P -x -T '-' #{template} | ruby -c" 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/puppet/provider/transport/default.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.type(:transport).provide(:default) do 2 | 3 | #defaultfor :default_provider => 'true' 4 | 5 | desc 'Basic provider for transport that just returns the value passed into the resource' 6 | 7 | def name 8 | resource[:name] 9 | end 10 | 11 | def username 12 | resource[:username] 13 | end 14 | 15 | def password 16 | resource[:password] 17 | end 18 | 19 | def server 20 | resource[:server] 21 | end 22 | 23 | def scope 24 | resource[:scope] 25 | end 26 | 27 | def cli_path 28 | resource[:cli_path] 29 | end 30 | 31 | end 32 | -------------------------------------------------------------------------------- /lib/puppet/provider/vnx_array/vnx_array.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.type(:vnx_array).provide(:vnx_array) do 2 | desc "Manage VNX Array name." 3 | 4 | def self.instances 5 | arrayname = run("arrayname").gsub("Array Name:", '').strip 6 | new(:name => arrayname) 7 | end 8 | 9 | def exists 10 | @property_hash[:ensure] == :present 11 | end 12 | 13 | def create 14 | run("arrayname", resource[:name], "-o") 15 | @property_hash[:ensure] = :present 16 | end 17 | 18 | def destroy 19 | # No method to destroy DNS settings so leave action blank 20 | @property_hash[:ensure] = :absent 21 | end 22 | 23 | end 24 | 25 | -------------------------------------------------------------------------------- /lib/puppet/provider/vnx_dns/vnx_dns.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.type(:vnx_dns).provide(:vnx_dns) do 2 | desc "Configure DNS settings for VNX." 3 | 4 | def self.instances 5 | dns_info = run(%w[networkadmin -dns -list]).split("\n") 6 | dns_info.each do |line| 7 | if line.include?("DNS Domain") 8 | domain = line.gsub("DNS Domain:", '').strip 9 | elsif line.include?("DNS Name Servers") 10 | name_servers = line.scan(/\d+\.\d+\.\d+\.\d+/) 11 | elsif line.include?("DNS Search List:") 12 | search_list = line.gsub("DNS Search List:", '').strip.split(' ') 13 | end 14 | end 15 | new dns_settings = { :name => domain, 16 | :ensure => :present, 17 | :name_servers => name_servers, 18 | :search_list => search_list } 19 | dns_instances << new(dns_settings) 20 | end 21 | 22 | def self.prefetch(resources) 23 | dns = instances 24 | resources.keys.each do |name| 25 | if provider = dns.find{ |dnsname| dnsname.name == name } 26 | resources[name].provider = provider 27 | end 28 | end 29 | end 30 | 31 | def exists 32 | @property_hash[:ensure] == :present 33 | end 34 | 35 | def create 36 | set_dns = "-networkadmin", "-dns", "-set", resource[:name] 37 | set_dns << "-nameserver" << resource[:name_servers] if resource[:name_servers] 38 | set_dns << "-searchlist" << resource[:search_list] if resource[:search_list] 39 | set_dns << "-o" 40 | run(set_dns) 41 | @property_hash[:ensure] = :present 42 | end 43 | 44 | def name_servers=(value) 45 | set_ns = "-networkadmin", "-dns", "-set", "-nameserver", value, "-o" 46 | run(set_ns) 47 | end 48 | 49 | def search_list=(value) 50 | set_sl = "-networkadmin", "-dns", "-set", resource[:search_list], "-o" 51 | run(set_sl) 52 | end 53 | 54 | def destroy 55 | # No method to destroy DNS settings so leave action blank 56 | @property_hash[:ensure] = :absent 57 | end 58 | 59 | end 60 | 61 | -------------------------------------------------------------------------------- /lib/puppet/provider/vnx_domain/vnx_domain.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.type(:vnx_domain).provide(:vnx_domain) do 2 | desc "Configure NTP settings for VNX." 3 | 4 | def self.instances 5 | domain_instances = [] 6 | domain_info = run(%w[domain -list]).split("\n") 7 | domain_info.each do |line| 8 | master = false 9 | if line.include?('IP Address:') 10 | ip_address = line.scan(/\d+\.\d+\.\d+\.\d+/) 11 | master = true if line.include?('Master') 12 | end 13 | new vnx_domains = { :name => ip_address, 14 | :ensure => :present, 15 | :master => master, } 16 | 17 | domain_instances << new(vnx_domains) 18 | end 19 | domain_instances 20 | end 21 | 22 | 23 | def self.prefetch(resources) 24 | domain = instances 25 | resources.keys.each do |name| 26 | if provider = domain.find{ |domainname| domainname.name == name } 27 | resources[name].provider = provider 28 | end 29 | end 30 | end 31 | 32 | def exists 33 | @property_hash[:ensure] == :present 34 | end 35 | 36 | def create 37 | create_domain = "domain", "-add", resource[:name] 38 | create_domain << ["-olduser", resource[:old_user], "-oldpassword", resource[:old_password], "-oldscope", resource[:old_scope], "-o"] if resource[:old_user] 39 | run(create_domain) 40 | @property_hash[:ensure] = :present 41 | end 42 | 43 | def destroy 44 | run("domain", "-remove", resource[:name], "-o") 45 | @property_hash[:ensure] = :absent 46 | end 47 | 48 | def unitialize=(value) 49 | run("domain", "-uninitialize", resource[:name], "-o") if unitialize == :true 50 | end 51 | 52 | def master 53 | @property_hash[:master] 54 | end 55 | 56 | def master=(value) 57 | if value == :true and master_defined 58 | raise Puppet::Error, "Master already set in domain" 59 | else 60 | run("domain", "-setmaster", resource[:name], "-o") if value == :true 61 | end 62 | end 63 | 64 | def master_defined 65 | domains = run("domain", "-list", "-all") 66 | domains.include?('Master') ? true : false 67 | end 68 | 69 | end 70 | 71 | -------------------------------------------------------------------------------- /lib/puppet/provider/vnx_fastcache/vnx_fastcache.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require 'puppet_x/puppetlabs/transport/emc_vnx' 3 | rescue LoadError => e 4 | require 'pathname' # WORK_AROUND #14073 and #7788 5 | module_lib = Pathname.new(__FILE__).parent.parent.parent 6 | puts "MODULE LIB IS #{module_lib}" 7 | require File.join module_lib, 'puppet_x/puppetlabs/transport/emc_vnx' 8 | end 9 | 10 | Puppet::Type.type(:vnx_fastcache).provide(:vnx_fastcache) do 11 | include PuppetX::Puppetlabs::Transport::EMCVNX 12 | 13 | desc "Manages VNX FAST Cache settings." 14 | mk_resource_property_methods 15 | 16 | def initialize *args 17 | super 18 | @property_flush = {} 19 | end 20 | 21 | def get_current_properties 22 | fast_info = run(%w[cache -fast -info]) 23 | #fast =~/Mode: N\/A/ ? false : true 24 | self.class.get_fastcache_properties fast_info 25 | end 26 | 27 | def self.get_fastcache_properties fast_info 28 | fast = {} 29 | fast_info.split("\n").each do |line| 30 | if (pattern == "Mode:") && line.start_with?(pattern) 31 | fast[:Mode] = line.sub(pattern, "").strip 32 | #puts "wzz Debug: fastMode is #{fast[:Mode]}" 33 | end 34 | end 35 | fast[:ensure] = fast[:Mode]=~/N\/A/ ? :absent : :present 36 | fast 37 | end 38 | 39 | # assume exists should be first called 40 | def exists? 41 | #puts "#{current_properties[:ensure]}" 42 | current_properties[:ensure] == :present 43 | end 44 | 45 | 46 | # def exists? 47 | # fast = run(%w[cache -fast -info]) 48 | # fast =~/Mode: N\/A/ ? false : true 49 | # end 50 | 51 | 52 | def create 53 | args = ['cache', '-fast', '-create','-disks',*resource[:disks],'-mode',resource[:cache_mode],'-rtype', resource[:raid_type], '-o'] 54 | run(args) 55 | #run('cache', '-fast', '-create', '-disks', resource[:disks], '-mode', resource[:cache_mode], '-rtype', resource[:raid_type], '-o') 56 | #run(%w[cache -fast -create -disks *resource[:disks] -mode ,resource[:cache_mode] -rtype resource[:raid_type] -o]) 57 | @property_hash[:ensure] = :present 58 | end 59 | 60 | 61 | def destroy 62 | result = run(%w[cache -fast -destroy -o]) 63 | #@property_hash[:ensure] = :absent 64 | end 65 | 66 | def flush 67 | if exists? 68 | if @property_flush[:ensure] == :absent 69 | destroy 70 | return 71 | end 72 | else 73 | create 74 | end 75 | end 76 | 77 | end 78 | -------------------------------------------------------------------------------- /lib/puppet/provider/vnx_initiator/vnx_initiator.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require 'puppet_x/puppetlabs/transport/emc_vnx' 3 | rescue LoadError => e 4 | require 'pathname' # WORK_AROUND #14073 and #7788 5 | module_lib = Pathname.new(__FILE__).parent.parent.parent 6 | puts "MODULE LIB IS #{module_lib}" 7 | require File.join module_lib, 'puppet_x/puppetlabs/transport/emc_vnx' 8 | end 9 | 10 | Puppet::Type.type(:vnx_initiator).provide(:vnx_initiator) do 11 | include PuppetX::Puppetlabs::Transport::EMCVNX 12 | 13 | desc "Manage Hosts/Initiators for VNX." 14 | 15 | mk_resource_methods 16 | 17 | def initialize(value={}) 18 | super(value) 19 | @property_flush = {} 20 | end 21 | 22 | def get_instances 23 | initiators = [] 24 | initiator_lines = run(%w[port -list -hba]).split("Information about each HBA:\n\n") 25 | initiator_lines.each do |line_info| 26 | next if line_info =~ /\A\s+\z/ #skip blank line 27 | initiator_info = {} 28 | hba_info, hba_ports = line_info.split "Information about each port of this HBA:\n\n" 29 | hba_info.split("\n").each do |line| 30 | pattern = 'HBA UID:' 31 | if line.start_with?(pattern) 32 | initiator_info[:hba_uid] = line.sub(pattern, '').strip 33 | next 34 | end 35 | pattern = 'Server Name:' 36 | if line.start_with?(pattern) 37 | initiator_info[:hostname] = line.sub(pattern, '').strip 38 | next 39 | end 40 | pattern = 'Server IP Address:' 41 | if line.start_with?(pattern) 42 | initiator_info[:ip_address] = line.sub(pattern, '').strip 43 | initiator_info[:ip_address] = nil if initiator_info[:ip_address] == "UNKNOWN" 44 | next 45 | end 46 | end 47 | 48 | ports = [] 49 | hba_ports.split("\n\n").each do |port_info| 50 | port = {} 51 | port_info.split("\n").each do |line| 52 | line.strip! 53 | pattern = 'SP Name:' 54 | if line.start_with?(pattern) 55 | port[:sp] = (line.sub(pattern, '').strip == "SP A" ? :a : :b) 56 | next 57 | end 58 | pattern = 'SP Port ID:' 59 | if line.start_with?(pattern) 60 | port[:sp_port] = line.sub(pattern, '').strip.to_i 61 | next 62 | end 63 | pattern = 'StorageGroup Name:' 64 | if line.start_with?(pattern) 65 | port[:storage_group_name] = line.sub(pattern, '').strip 66 | next 67 | end 68 | 69 | end 70 | ports << port unless port.empty? 71 | end 72 | initiator_info[:ensure] = :present 73 | initiator_info[:ports] = ports 74 | initiators << initiator_info 75 | end 76 | initiators 77 | end 78 | 79 | def exists? 80 | get_instances.find{|initiator| initiator[:hba_uid] == resource[:hba_uid]} 81 | end 82 | 83 | def set_initiator 84 | resource[:ports].each do |port| 85 | if port["storage_group"] 86 | gname = port["storage_group"] 87 | #else 88 | # gname = create_temp_storage_group 89 | end 90 | 91 | begin 92 | #debug "Try to create #{resource[:name]} #{resource[:ip_address]}, #{resource[:hostname]} on #{port[:storagegroup]} #{port[:so]} #{port[:sp_port]}" 93 | command = ["storagegroup", "-setpath", "-hbauid", resource[:hba_uid], "-sp", port["sp"], "-spport", port["sp_port"].to_s, "-o"] 94 | if resource[:ip_address] != nil 95 | command += ["-ip",resource[:ip_address]] 96 | end 97 | 98 | if resource[:hostname] != nil 99 | command +=["-host",resource[:hostname]] 100 | end 101 | 102 | if resource[:failovermode] != nil 103 | command +=["-failovermode", resource[:failovermode]] 104 | end 105 | 106 | if resource[:arraycommpath] != nil 107 | command +=["-arraycommpath", resource[:arraycommpath]] 108 | end 109 | 110 | if gname != nil 111 | command += ["-gname", gname] 112 | end 113 | run(command) 114 | ensure 115 | #destroy_temp_storage_group(resource[:hostname], gname) unless port["storage_group"] 116 | end 117 | end 118 | @property_hash[:ensure] = :present 119 | end 120 | 121 | # def create_temp_storage_group 122 | #create a temporary storage group for registering a new initiator 123 | # gname = "TmpSG" + Time.now.to_i.to_s 124 | # pre_command = ["storagegroup", "-create", "-gname", gname] 125 | # run(pre_command) 126 | # gname 127 | # end 128 | 129 | # def destroy_temp_storage_group(hostname, gname) 130 | # #destroy temporary storage group 131 | # begin 132 | # post_command = ["storagegroup", "-disconnecthost", "-host", hostname, "-gname", gname, "-o"] 133 | # run(post_command) 134 | # ensure 135 | # post_command = ["storagegroup", "-destroy", "-gname", gname, "-o"] 136 | # run(post_command) 137 | # end 138 | # end 139 | 140 | def create 141 | @property_flush[:ensure] = :present 142 | end 143 | 144 | def destroy 145 | @property_flush[:ensure] = :absent 146 | end 147 | 148 | def flush 149 | if @property_flush[:ensure] == :absent 150 | run(["port", "-removeHBA", "-o", "-hbauid", resource[:hba_uid]]) 151 | else 152 | set_initiator 153 | end 154 | end 155 | 156 | end 157 | -------------------------------------------------------------------------------- /lib/puppet/provider/vnx_lun/vnx_lun.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require 'puppet_x/puppetlabs/transport/emc_vnx' 3 | rescue LoadError => e 4 | require 'pathname' # WORK_AROUND #14073 and #7788 5 | module_lib = Pathname.new(__FILE__).parent.parent.parent 6 | puts "MODULE LIB IS #{module_lib}" 7 | require File.join module_lib, 'puppet_x/puppetlabs/transport/emc_vnx' 8 | end 9 | 10 | Puppet::Type.type(:vnx_lun).provide(:vnx_lun) do 11 | include PuppetX::Puppetlabs::Transport::EMCVNX 12 | 13 | desc "Manage LUNs for VNX." 14 | 15 | mk_resource_property_methods 16 | 17 | def initialize *args 18 | super 19 | @property_flush = {} 20 | end 21 | 22 | def get_current_properties 23 | lun_info = run(["lun", "-list", "-name", resource[:lun_name]]) 24 | self.class.get_lun_properties lun_info 25 | end 26 | 27 | def self.get_lun_properties lun_info 28 | lun = {} 29 | lun_info.split("\n").each do |line| 30 | pattern = "LOGICAL UNIT NUMBER" 31 | if line.start_with?(pattern) 32 | lun[:lun_number] = line.sub(pattern, "").strip.to_i 33 | next 34 | end 35 | 36 | pattern = "Name:" 37 | if line.start_with?(pattern) 38 | lun[:name] = line.sub(pattern, "").strip 39 | next 40 | end 41 | 42 | pattern = "UID:" 43 | if line.start_with?(pattern) 44 | lun[:uid] = line.sub(pattern, "").strip 45 | next 46 | end 47 | 48 | pattern = "Current Owner:" 49 | if line.start_with?(pattern) 50 | owner = line.sub(pattern, "").strip 51 | owner = if owner == "SP A" 52 | :a 53 | elsif owner == "SP B" 54 | :b 55 | else 56 | raise "parse error, at: #{pattern}" 57 | end 58 | lun[:current_owner] = owner 59 | next 60 | end 61 | 62 | pattern = "Default Owner:" 63 | if line.start_with?(pattern) 64 | owner = line.sub(pattern, "").strip 65 | owner = if owner == "SP A" 66 | :a 67 | elsif owner == "SP B" 68 | :b 69 | else 70 | raise "parse error, at: #{pattern}" 71 | end 72 | lun[:default_owner] = owner 73 | next 74 | end 75 | 76 | pattern = "Allocation Owner:" 77 | if line.start_with?(pattern) 78 | owner = line.sub(pattern, "").strip 79 | owner = if owner == "SP A" 80 | :a 81 | elsif owner == "SP B" 82 | :b 83 | else 84 | raise "parse error, at: #{pattern}" 85 | end 86 | lun[:allocation_owner] = owner 87 | next 88 | end 89 | 90 | pattern = "User Capacity (Blocks):" 91 | if line.start_with?(pattern) 92 | lun[:user_capacity_blocks] = line.sub(pattern, "").strip.to_i 93 | next 94 | end 95 | 96 | pattern = /\AUser Capacity \((\w+)\):(.+)/ 97 | if line =~ pattern 98 | lun[:capacity] = $2.strip.to_i 99 | sq = $1.downcase 100 | lun[:size_qual] = [:gb, :tb, :mb, :bc].find{|v| sq.include? v.to_s} 101 | next 102 | end 103 | 104 | pattern = "Consumed Capacity (Blocks):" 105 | if line.start_with?(pattern) 106 | lun[:consumed_capacity_blocks] = line.sub(pattern, "").strip.to_i 107 | next 108 | end 109 | 110 | pattern = /\AConsumed Capacity \((\w+)\):(.+)/ 111 | if line =~ pattern 112 | lun[:consumed_capacity] = $2.strip.to_f 113 | next 114 | end 115 | 116 | pattern = "Pool Name:" 117 | if line.start_with?(pattern) 118 | lun[:pool_name] = line.sub(pattern, "").strip 119 | next 120 | end 121 | 122 | pattern = "Offset:" 123 | if line.start_with?(pattern) 124 | lun[:offset] = line.sub(pattern, "").strip.to_i 125 | next 126 | end 127 | 128 | pattern = "Auto-Assign Enabled:" 129 | if line.start_with?(pattern) 130 | lun[:auto_assign] = (line.sub(pattern, "").strip == "DISABLED" ? :false : :true) 131 | next 132 | end 133 | 134 | pattern = "Raid Type:" 135 | if line.start_with?(pattern) 136 | lun[:raid_type] = line.sub(pattern, "").strip 137 | next 138 | end 139 | 140 | pattern = "Is Pool LUN:" 141 | if line.start_with?(pattern) 142 | lun[:is_pool_lun] = (line.sub(pattern, "").strip == "Yes" ? :true : :false) 143 | next 144 | end 145 | 146 | pattern = "Is Thin LUN:" 147 | if line.start_with?(pattern) 148 | lun[:is_thin_lun] = (line.sub(pattern, "").strip == "Yes" ? :true : :false) 149 | lun[:type] = (lun[:is_thin_lun] == :true ? :thin : :nonthin) 150 | next 151 | end 152 | 153 | pattern = "Tiering Policy:" 154 | if line.start_with?(pattern) 155 | result = line.sub(pattern, "").strip.downcase 156 | result = if result.include? "auto" 157 | :auto_tier 158 | elsif result.include? "highest" 159 | :highest_available 160 | elsif result.include? "lowest" 161 | :lowest_available 162 | else 163 | :no_movement 164 | end 165 | lun[:tiering_policy] = result 166 | next 167 | end 168 | 169 | pattern = "Initial Tier:" 170 | if line.start_with?(pattern) 171 | result = line.sub(pattern, "").strip.downcase 172 | result = if result.include? "highest" 173 | :highest_available 174 | elsif result.include? "lowest" 175 | :lowest_available 176 | else 177 | :optimize_pool 178 | end 179 | lun[:initial_tier] = result 180 | next 181 | end 182 | end 183 | lun[:ensure] = :present 184 | lun 185 | end 186 | 187 | # def self.instances 188 | # lun_instances = [] 189 | # luns_info = run ["lun", "-list"] 190 | # luns_info.split("\n\n").each do |lun_info| 191 | # lun = get_lun_properties lun_info 192 | # lun_instances << new(lun) 193 | # end 194 | # lun_instances 195 | # end 196 | 197 | # def self.prefetch(resources) 198 | # instances.each do |prov| 199 | # if resource = resources[prov.name] 200 | # resource.provider = prov 201 | # end 202 | # end 203 | # end 204 | 205 | # assume exists should be first called 206 | def exists? 207 | current_properties[:ensure] == :present 208 | end 209 | 210 | def set_lun 211 | # expand 212 | args = ["lun", "-expand", "-name", resource[:lun_name]] 213 | origin_length = args.length 214 | args << "-capacity" << resource[:capacity] if @property_flush[:capacity] 215 | args << "-sq" << resource[:size_qual] if @property_flush[:size_qual] 216 | args << "-ignoreThresholds" if (resource[:ignore_thresholds] == :true) 217 | args << "-o" 218 | run(args) if args.length > origin_length + 1 219 | 220 | # modify 221 | args = ["lun", "-modify", "-name", resource[:lun_name]] 222 | origin_length = args.length 223 | args << "-aa" << (resource[:auto_assign] == :true ? 1 : 0) if @property_flush[:auto_assign] 224 | args << "-newName" << resource[:new_name] if @property_flush[:new_name] && (@property_flush[:new_name] != resource[:lun_name]) 225 | args << "-sp" << resource[:default_owner].to_s.upcase if @property_flush[:default_owner] 226 | args << "-tieringPolicy" << (case resource[:tiering_policy] 227 | when :no_movement then "noMovement" 228 | when :auto_tier then "autoTier" 229 | when :highest_available then "highestAvailable" 230 | when :highest_available then "lowestAvailable" 231 | end) if @property_flush[:tiering_policy] 232 | 233 | args << "-initialTier" << (case resource[:initial_tier] 234 | when :optimize_pool then "optimizePool" 235 | when :highest_available then "highestAvailable" 236 | when :lowest_available then "lowestAvailable" 237 | end) if @property_flush[:initial_tier] 238 | 239 | args << "-allowSnapAutoDelete" << (resource[:allow_snap_auto_delete] == :true ? "yes" : "no") if @property_flush[:allow_snap_auto_delete] 240 | args << "-allowInbandSnapAttach" << (resource[:allow_inband_snap_attach] == :true ? "yes" : "no") if @property_flush[:allow_inband_snap_attach] 241 | if @property_flush[:allocation_policy] 242 | raise ArgumentError, "allocation_policy must be automatic" if resource[:allocation_policy] != :automatic 243 | args << "-allocationPolicy" << "automatic" 244 | end 245 | 246 | args << "-o" 247 | run(args) if args.length > origin_length + 1 248 | end 249 | 250 | def create_lun 251 | args = ['lun', '-create'] 252 | if resource[:type] == :snap 253 | args << "-type" << "Snap" 254 | args << "-primaryLun" << resource[:primary_lun_number] if resource[:primary_lun_number] 255 | args << "-primaryLunName" << resource[:primary_lun_name] if resource[:primary_lun_name] 256 | args << "-sp" << resource[:default_owner].to_s.upcase if resource[:default_owner] 257 | args << "-l" << resource[:lun_number] if resource[:lun_number] 258 | args << "-name" << resource[:lun_name] if resource[:lun_name] 259 | args << "-allowSnapAutoDelete" << (resource[:allow_snap_auto_delete] == :true ? "yes" : "no") if resource[:allow_snap_auto_delete] 260 | args << "-allowInbandSnapAttach" << (resource[:allow_inband_snap_attach] == :true ? "yes" : "no") if resource[:allow_inband_snap_attach] 261 | else 262 | args << "-type" << (resource[:type] == :thin ? 'Thin' : 'NonThin') if resource[:type] 263 | args << "-capacity" << resource[:capacity] if resource[:capacity] 264 | args << "-sq" << resource[:size_qual] if resource[:size_qual] 265 | args << "-poolId" << resource[:pool_id] if resource[:pool_id] 266 | args << "-poolName" << resource[:pool_name] if resource[:pool_name] 267 | args << "-sp" << resource[:default_owner].to_s.upcase if resource[:default_owner] 268 | args << "-aa" << (resource[:auto_assign] == :true ? 1 : 0) if resource[:auto_assign] 269 | args << "-l" << resource[:lun_number] if resource[:lun_number] 270 | args << "-name" << resource[:lun_name] 271 | args << "-offset" << resource[:offset] if resource[:offset] 272 | args << "-tieringPolicy" << (case resource[:tiering_policy] 273 | when :no_movement then "noMovement" 274 | when :auto_tier then "autoTier" 275 | when :highest_available then "highestAvailable" 276 | when :lowest_available then "lowestAvailable" 277 | end) if resource[:tiering_policy] 278 | 279 | args << "-initialTier" << (case resource[:initial_tier] 280 | when :optimize_pool then "optimizePool" 281 | when :highest_available then "highestAvailable" 282 | when :lowest_available then "lowestAvailable" 283 | end) if resource[:initial_tier] 284 | 285 | args << "-allowSnapAutoDelete" << (resource[:allow_snap_auto_delete] == :true ? "yes" : "no") if resource[:allow_snap_auto_delete] 286 | args << "-ignoreThresholds" if (resource[:ignore_thresholds] == :true) 287 | args << "-allocationPolicy" << (resource[:allocation_policy] == :on_demand ? "onDemand" : "automatic") if resource[:allocation_policy] 288 | end 289 | 290 | run(args) 291 | @property_hash[:ensure] = :present 292 | end 293 | 294 | def create 295 | @property_flush[:ensure] = :present 296 | end 297 | 298 | def destroy 299 | @property_flush[:ensure] = :absent 300 | end 301 | 302 | def flush 303 | # destroy 304 | if @property_flush[:ensure] == :absent 305 | args = ["lun", "-destroy"] 306 | args << "-name" << resource[:lun_name] 307 | args << "-o" 308 | run args 309 | @property_hash[:ensure] = :absent 310 | return 311 | end 312 | 313 | if exists? 314 | set_lun 315 | else 316 | create_lun 317 | end 318 | end 319 | end 320 | -------------------------------------------------------------------------------- /lib/puppet/provider/vnx_nqm/vnx_nqm.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require 'puppet_x/puppetlabs/transport/emc_vnx' 3 | rescue LoadError => e 4 | require 'pathname' # WORK_AROUND #14073 and #7788 5 | module_lib = Pathname.new(__FILE__).parent.parent.parent 6 | puts "MODULE LIB IS #{module_lib}" 7 | require File.join module_lib, 'puppet_x/puppetlabs/transport/emc_vnx' 8 | end 9 | 10 | Puppet::Type.type(:vnx_nqm).provide(:vnx_nqm) do 11 | include PuppetX::Puppetlabs::Transport::EMCVNX 12 | 13 | desc "Set QoS for LUNs for VNX." 14 | 15 | $ioClass = [] 16 | $iNumIOClass = 0 17 | 18 | mk_resource_property_methods 19 | 20 | def initialize *args 21 | super 22 | @property_flush = {} 23 | end 24 | 25 | def get_current_properties 26 | nqm_info = run(["nqm", "-ioclass", "-list", "-name", resource[:ioclass]]) 27 | self.class.get_nqm_properties nqm_info 28 | end 29 | 30 | def self.get_nqm_properties nqm_info 31 | nqm = {} 32 | nqm_info.split("\n").each do |line| 33 | 34 | if (pattern == "Name:") && line.start_with?(pattern) 35 | nqm[:ioclass] = line.sub(pattern, "").strip 36 | next 37 | end 38 | 39 | if (pattern == "Current State:") && line.start_with?(pattern) 40 | nqm[:current_state] = line.sub(pattern, "").strip 41 | next 42 | end 43 | 44 | if (pattern == "Status:") && line.start_with?(pattern) 45 | nqm[:status] = line.sub(pattern, "").strip 46 | next 47 | end 48 | 49 | if (pattern == "Number of LUN(s):") && line.start_with?(pattern) 50 | nqm[:number_of_luns] = line.sub(pattern, "").strip.to_i 51 | next 52 | end 53 | 54 | if (pattern == "LUN Number:") && line.start_with?(pattern) 55 | nqm[:lun_number] = line.sub(pattern, "").strip.to_i 56 | next 57 | end 58 | 59 | if (pattern == "LUN Name:") && line.start_with?(pattern) 60 | nqm[:lun_name] = line.sub(pattern, "").strip.to_i 61 | next 62 | end 63 | 64 | if (pattern == "LUN WWN:") && line.start_with?(pattern) 65 | nqm[:lun_wwn] = line.sub(pattern, "").strip 66 | next 67 | end 68 | 69 | if (pattern == "RAID Type:") && line.start_with?(pattern) 70 | nqm[:raid_type] = line.sub(pattern, "").strip 71 | next 72 | end 73 | 74 | if (pattern == "IO Type:") && line.start_with?(pattern) 75 | nqm[:io_type] = line.sub(pattern, "").strip 76 | next 77 | end 78 | 79 | if (pattern == "IO Size Range:") && line.start_with?(pattern) 80 | nqm[:io_size_range] = line.sub(pattern, "").strip 81 | next 82 | end 83 | 84 | if (pattern == "Control Method:") && line.start_with?(pattern) 85 | nqm[:control_method] = line.sub(pattern, "").strip 86 | next 87 | end 88 | 89 | if (pattern == "Metric Type:") && line.start_with?(pattern) 90 | nqm[:metric_type] = line.sub(pattern, "").strip 91 | next 92 | end 93 | 94 | if (pattern == "Goal Value:") && line.start_with?(pattern) 95 | nqm[:goal_value] = line.sub(pattern, "").strip 96 | next 97 | end 98 | 99 | end 100 | nqm[:ensure] = :present 101 | nqm 102 | end 103 | 104 | # assume exists should be first called 105 | def exists? 106 | current_properties[:ensure] == :present 107 | end 108 | 109 | def create_ioclass 110 | args = ['nqm', '-ioclass', '-create', '-name', resource[:ioclass]] 111 | args << "-iotype" << resource[:io_type] 112 | args << "-anyio" if resource[:anyio] 113 | args << "-luns" << resource[:lun_number] 114 | args << "-ctrlmethod" << resource[:control_method] 115 | args << "-gmetric" << resource[:metric_type] 116 | args << "-gval" << resource[:goal_value] 117 | run(args) 118 | $ioClass[$iNumIOClass]="#{resource[:ioclass]}" 119 | $iNumIOClass=$iNumIOClass+1 120 | 121 | # out_ioclasses = `echo #{resource[:ioclass]} >> /tmp/#{resource[:policy_name]}.txt` 122 | # out_ioclasses 123 | @property_hash[:ensure] = :present 124 | end 125 | 126 | def modify_ioclass 127 | args = ['nqm', '-ioclass', '-modify', '-name', resource[:ioclass]] 128 | origin_length = args.length 129 | args << "-iotype" << resource[:io_type] 130 | args << "-anyio" if resource[:anyio] 131 | args << "-luns" << resource[:lun_number] 132 | args << "-ctrlmethod" << resource[:control_method] 133 | args << "-gmetric" << resource[:metric_type] 134 | args << "-gval" << resource[:goal_value] 135 | run(args) 136 | $ioClass[$iNumIOClass]="#{resource[:ioclass]}" 137 | $iNumIOClass=$iNumIOClass+1 138 | @property_hash[:ensure] = :present 139 | end 140 | 141 | # def get_file_as_string(filename) 142 | # data = '' 143 | # f = File.open(filename, "r") 144 | # f.each_line do |line| 145 | # data += line 146 | # end 147 | # return data 148 | # end 149 | 150 | def create_policy 151 | # f_name = "/tmp/" + resource[:policy_name] + ".txt" 152 | # ioclass_list = get_file_as_string(f_name) 153 | # ioclass_list = ioclass_list.gsub("\n", ' ') 154 | args = ['nqm', '-policy', '-create', '-name', resource[:policy_name], '-ioclasses', *$ioClass] 155 | args << "-failaction" << resource[:fail_action] 156 | run(args) 157 | @property_hash[:ensure] = :present 158 | end 159 | 160 | def modify_policy 161 | args = ['nqm', '-policy', '-modify', '-name', resource[:policy_name]] 162 | args << "-ioclasses" << resource[:ioclass] 163 | args << "-failaction" << resource[:fail_action] 164 | run(args) 165 | @property_hash[:ensure] = :present 166 | end 167 | 168 | def run_policy 169 | args = ['nqm', '-run', resource[:policy_name]] 170 | run(args) 171 | @property_hash[:ensure] = :present 172 | end 173 | 174 | def create 175 | @property_flush[:ensure] = :present 176 | end 177 | 178 | def destroy 179 | @property_flush[:ensure] = :absent 180 | end 181 | 182 | def flush 183 | # destroy 184 | if @property_flush[:ensure] == :absent 185 | args = ["nqm", "-ioclass", "-destroy"] 186 | args << "-name" << resource[:ioclass] 187 | args << "-o" 188 | run args 189 | @property_hash[:ensure] = :absent 190 | return 191 | end 192 | 193 | if exists? 194 | modify_ioclass 195 | else 196 | if resource[:ioclass] 197 | create_ioclass 198 | else 199 | create_policy 200 | run_policy 201 | end 202 | end 203 | end 204 | end 205 | -------------------------------------------------------------------------------- /lib/puppet/provider/vnx_ntp/vnx_ntp.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.type(:vnx_ntp).provide(:vnx_ntp) do 2 | desc "Configure NTP settings for VNX." 3 | 4 | def self.instances 5 | ntp_info = run(%w[ntp -list -all]).split("\n") 6 | ntp_info.each do |line| 7 | if line.include?('start') 8 | running = line.gsub("start:", '').strip 9 | elsif line.include?('interval') 10 | interval = line.gsub("interval:", '').strip 11 | elsif line.include?('address') 12 | address = line.scan(/\d+\.\d+\.\d+\.\d+/).sort 13 | elsif line.include?('serverkey') 14 | server_keys = line.gsub("serverkey:", " ").split(" ") 15 | elsif line.include?('keyvalue') 16 | keyvalues = line.gsub("keyvalue:", " ").split(" ") 17 | end 18 | end 19 | new ntp_settings = { :ntp_servers => address, 20 | :ensure => :present, 21 | :interval => interval, 22 | :ensure_running => running, 23 | :server_key => server_keys, 24 | :keyvalue => keyvalues } 25 | ntp_instances << new(ntp_settings) 26 | end 27 | 28 | def self.prefetch(resources) 29 | ntp = instances 30 | resources.keys.each do |name| 31 | if provider = ntp.find{ |ntpname| ntpname.name == name } 32 | resources[name].provider = provider 33 | end 34 | end 35 | end 36 | 37 | def exists 38 | @property_hash[:ensure] == :present 39 | end 40 | 41 | def create 42 | set_ntp = "-set", "-start", resource[:ensure_running], "-servers", resource[:ntp_servers] 43 | set_ntp << ["-serverkey", resource[:server_key], "-keyvalue", resource[:keyvalue]] if resource[:server_key] 44 | run(set_ntp) 45 | @property_hash[:ensure] = :present 46 | end 47 | 48 | def destroy 49 | run("ntp", "-set", "-start", "no") 50 | @property_hash[:ensure] = :absent 51 | end 52 | 53 | end 54 | 55 | -------------------------------------------------------------------------------- /lib/puppet/provider/vnx_sp/vnx_sp.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.type(:vnx_sp).provide(:vnx_sp) do 2 | desc "Manage VNX Service Processor settings." 3 | 4 | mk_resource_methods 5 | 6 | def self.instances 7 | sps_instances =[] 8 | sps = ['a', 'b'] 9 | sps.each do |sp | 10 | sps_info = run("networkadmin", "-get", "-sp", sp).split("\n") 11 | sps_info.each do |line| 12 | if line.include?("Network Name") 13 | name = line.gsub("Storage Processor Network Name:", '').strip 14 | elsif line =~/^Port ID/ 15 | port_id = line.gsub("Port ID:", '').strip 16 | elsif line.include?("Subnet Mask") 17 | subnet_mask = line.scan(/\d+\.\d+\.\d+\.\d+/) 18 | elsif line.include?("IP Address") 19 | ip_address = line.scan(/\d+\.\d+\.\d+\.\d+/) 20 | elsif line.include?("Gateway Address") 21 | gateway = line.scan(/\d+\.\d+\.\d+\.\d+/) 22 | elsif line.include?("Virtual Port ID") 23 | vport = line.gsub("Virtual Port ID:", '').strip 24 | elsif line.include?("VLAN ID") 25 | vlan = line.gsub("VLAN ID:", '').strip 26 | end 27 | new sp_settings = { :service_processor => sp, 28 | :sp_name => sps, 29 | :port_id => port_id, 30 | :subnet_mask => subnet_mask, 31 | :ip_address => ip_address, 32 | :gateway => gateway, 33 | :vport => vport, 34 | :vlan => vlan } 35 | sps_instances << new(sp_settings) 36 | end 37 | end 38 | sps_instances 39 | end 40 | 41 | def self.prefetch(resources) 42 | sps = instances 43 | resources.keys.each do |name| 44 | if provider = sps.find{ |spname| spname.name == name } 45 | resources[name].provider = provider 46 | end 47 | end 48 | end 49 | 50 | def exists 51 | @property_hash[:ensure] == :present 52 | end 53 | 54 | def create 55 | # SP's are always present and we are only modifying SP paramaters 56 | # so create will not change anything 57 | @property_hash[:ensure] = :present 58 | end 59 | 60 | def flush 61 | @options = ["networkadmin", "-set", "-o", "-sp", resource[:service_processor]] 62 | if @property_hash[:ensure] == :present 63 | # If both name and IP addressing need to be changed, the network settings 64 | # will be changed first, followed by the SP network name 65 | if resource[:sp_name] 66 | if resource[:subnetmask] or resource[:gateway] or resource[:ip_address] 67 | @options << "-ipv4" << resource[:ip_address] if resource[:ip_address] 68 | @options << "-subnetmask" << resource[:subnetmask] if resource[:subnetmask] 69 | @options << "-gateway" << resource[:gateway] if resource[:gateway] 70 | run(@options) 71 | end 72 | @options << "-name" << resource[:sp_name] 73 | run(@options) 74 | end 75 | end 76 | end 77 | 78 | def destroy 79 | # No method to destroy VNX name or IP settings in VNX so destroy does nothing 80 | @property_hash[:ensure] = :absent 81 | end 82 | 83 | end 84 | 85 | -------------------------------------------------------------------------------- /lib/puppet/provider/vnx_storagegroup/vnx_storagegroup.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require 'puppet_x/puppetlabs/transport/emc_vnx' 3 | rescue LoadError => e 4 | require 'pathname' # WORK_AROUND #14073 and #7788 5 | module_lib = Pathname.new(__FILE__).parent.parent.parent 6 | puts "MODULE LIB IS #{module_lib}" 7 | require File.join module_lib, 'puppet_x/puppetlabs/transport/emc_vnx' 8 | end 9 | 10 | Puppet::Type.type(:vnx_storagegroup).provide(:vnx_storagegroup) do 11 | include PuppetX::Puppetlabs::Transport::EMCVNX 12 | 13 | desc "Manages VNX Storage Groups." 14 | 15 | mk_resource_property_methods 16 | 17 | def initialize *args 18 | super 19 | @property_flush = {} 20 | end 21 | 22 | def addhlu hlu, alu 23 | # begin 24 | # # check alu presences 25 | # run(["lun", "-list", "-l", alu]) 26 | # rescue 27 | # run ["lun", "-create", "-l", alu] 28 | # end 29 | args = ["storagegroup", "-addhlu", "-gname", resource[:sg_name], "-hlu", hlu, "-alu", alu] 30 | # puts "#{args}" 31 | run args 32 | end 33 | 34 | def removehlu hlu 35 | args = ["storagegroup", "-removehlu", "-gname", resource[:sg_name], "-hlu", hlu, "-o"] 36 | run args 37 | end 38 | 39 | def setpath 40 | args = ["storagegroup", "-setpath", "-o"] 41 | args << "-gname" << resource[:sg_name] if resource[:sg_name] 42 | args << "-hbauid" << resource[:hbauid] 43 | args << "-sp" << resource[:sp] 44 | args << "-spport" << resource[:sp_port] 45 | args << "-spvport" << resource[:sp_vport] if resource[:sp_vport] 46 | args << "-type" << resource[:initiator_type] if resource[:initiator_type] 47 | args << "-ip" << resource[:ip_address] if resource[:ip_address] 48 | args << "-host" << resource[:hostname] if resource[:hostname] 49 | args << "-failovermode" << resource[:failover_mode] if resource[:failover_mode] 50 | args << "-arraycommpath" << resource[:array_commpath] if resource[:array_commpath] 51 | args << "-unitserialnumber" << resource[:unit_serialnumber] if resource[:unit_serialnumber] 52 | run args 53 | # @property_hash[:ensure] = :present 54 | end 55 | 56 | def addhost 57 | args = ["storagegroup", "-connecthost", "-host", resource[:host_name], "-gname", resource[:sg_name], "-o"] 58 | run args 59 | end 60 | 61 | def get_current_properties 62 | sg = run(["storagegroup", "-list", "-gname", resource[:sg_name]]) 63 | self.class.get_storagegroup_properties sg 64 | end 65 | 66 | def self.get_storagegroup_properties sg 67 | line_values = sg.split /\n+/ 68 | line_values.shift while line_values.first.empty? 69 | storage_group = {} 70 | while line_value = line_values.shift 71 | if line_value.start_with?('Storage Group Name:') 72 | storage_group[:sg_name] = line_value[(line_value.index(":") + 1)..-1].strip 73 | next 74 | end 75 | 76 | if line_value.start_with?('Storage Group UID:') 77 | storage_group[:uid] = line_value[(line_value.index(":") + 1)..-1].strip 78 | next 79 | end 80 | 81 | if line_value.start_with?('Shareable:') 82 | shareable = line_value[(line_value.index(":") + 1)..-1].strip 83 | storage_group[:shareable] = (shareable == "YES" ? :true : :false) 84 | next 85 | end 86 | 87 | if line_value.start_with?('HBA/SP Pairs:') 88 | if line_values.first.start_with? " HBA UID" 89 | line_values.shift 90 | if line_values.first.start_with? " -----" 91 | line_values.shift 92 | pairs = [] 93 | while line_values.first.start_with? " " 94 | hba_uid, sp_name, sp_port = line_values.first.strip.split(/\s{2,}/) 95 | pairs << ({:hba_uid => hba_uid, :sp_name => (sp_name == "SP A" ? :a : :b), :sp_port => sp_port.to_i}) 96 | line_values.shift 97 | end 98 | storage_group[:HBAs] = pairs 99 | end 100 | end 101 | end 102 | 103 | if line_value.start_with?('HLU/ALU Pairs:') 104 | if line_values.first.start_with? " HLU Number" 105 | line_values.shift 106 | if line_values.first.start_with? " -----" 107 | line_values.shift 108 | pairs = [] 109 | while line_values.first.start_with? " " 110 | hlu, alu = line_values.first.strip.split.map{|v| v.to_i} 111 | pairs << ({'hlu' => hlu, 'alu' => alu}) 112 | line_values.shift 113 | end 114 | storage_group[:luns] = pairs 115 | end 116 | end 117 | end 118 | 119 | end 120 | storage_group[:ensure] = :present 121 | storage_group 122 | end 123 | 124 | # def self.instances 125 | # storage_groups=[] 126 | # storage_group_info = run ["storagegroup", "-list"] 127 | # storage_group_info.split("Storage Group Name:").each do |sg| 128 | # line_values = sg.split /\n+/ 129 | # next if line_values.empty? #skip blank line 130 | # line_values.shift while line_values.first.empty? 131 | # storage_group = {:name => line_values.shift.strip} 132 | # while line_value = line_values.shift 133 | # if line_value.start_with?('Storage Group UID:') 134 | # storage_group[:uid] = line_value[(line_value.index(":") + 1)..-1].strip 135 | # next 136 | # end 137 | # 138 | # if line_value.start_with?('Shareable:') 139 | # shareable = line_value[(line_value.index(":") + 1)..-1].strip 140 | # storage_group[:shareable] = (shareable == "YES" ? :true : :false) 141 | # next 142 | # end 143 | # 144 | # if line_value.start_with?('HBA/SP Pairs:') 145 | # if line_values.first.start_with? " HBA UID" 146 | # line_values.shift 147 | # if line_values.first.start_with? " -----" 148 | # line_values.shift 149 | # pairs = [] 150 | # while line_values.first.start_with? " " 151 | # hba_uid, sp_name, sp_port = line_values.first.strip.split(/\s{2,}/) 152 | # pairs << ({:hba_uid => hba_uid, :sp_name => (sp_name == "SP A" ? :a : :b), :sp_port => sp_port.to_i}) 153 | # line_values.shift 154 | # end 155 | # storage_group[:HBAs] = pairs 156 | # end 157 | # end 158 | # end 159 | # 160 | # if line_value.start_with?('HLU/ALU Pairs:') 161 | # if line_values.first.start_with? " HLU Number" 162 | # line_values.shift 163 | # if line_values.first.start_with? " -----" 164 | # line_values.shift 165 | # pairs = [] 166 | # while line_values.first.start_with? " " 167 | # hlu, alu = line_values.first.strip.split.map{|v| v.to_i} 168 | # pairs << ({'hlu' => hlu, 'alu' => alu}) 169 | # line_values.shift 170 | # end 171 | # storage_group[:luns] = pairs 172 | # end 173 | # end 174 | # end 175 | # 176 | # end 177 | # storage_group[:ensure] = :present 178 | # storage_groups << new(storage_group) 179 | # end 180 | # storage_groups 181 | # end 182 | # 183 | # def self.prefetch(resources) 184 | # vnx_storagegroup = instances 185 | # resources.keys.each do |name| 186 | # if provider = vnx_storagegroup.find{ |storagegroup| storagegroup.name == name } 187 | # resources[name].provider = provider 188 | # end 189 | # end 190 | # end 191 | 192 | def create_storagegroup 193 | run(["storagegroup", "-create", "-gname", resource[:sg_name]]) 194 | set_storagegroup 195 | @property_hash[:ensure] = :present 196 | end 197 | 198 | def create 199 | @property_flush[:ensure] = :present 200 | end 201 | 202 | def set_storagegroup 203 | if @property_flush[:luns] 204 | pairs = resource[:luns] 205 | should_pairs = if pairs.nil? || pairs == :absent 206 | [] 207 | else 208 | pairs.map{|pair| pair.values_at('hlu', 'alu').map &:to_s}.sort 209 | end 210 | current_properties = get_current_properties 211 | current_pairs = current_properties[:luns] 212 | is_pairs = if current_pairs.nil? || current_pairs == :absent 213 | [] 214 | else 215 | current_pairs.map{|pair| pair.values_at('hlu', 'alu').map &:to_s}.sort 216 | end 217 | # remove_pairs = is_pairs - should_pairs 218 | # remove_pairs.each{|hlu, alu| removehlu hlu} 219 | add_pairs = should_pairs - is_pairs 220 | add_pairs.each{|hlu, alu| addhlu hlu, alu} 221 | end 222 | 223 | #set the initiator path 224 | if @property_flush[:hbauid] 225 | #hostname = resource[:hbauid] 226 | # puts "tohdat debug: property_flush #{@property_flush[:hbauid]}" 227 | # puts "tohdat debug: #{@property_flush[:addonly]}" 228 | if @property_flush[:setpathonly] == :true 229 | args = ["storagegroup", "-setpath", "-o"] 230 | args << "-gname" << resource[:sg_name] if resource[:sg_name] 231 | args << "-hbauid" << resource[:hbauid] 232 | args << "-sp" << resource[:sp] 233 | args << "-spport" << resource[:sp_port] 234 | args << "-spvport" << resource[:sp_vport] if resource[:sp_vport] 235 | args << "-type" << resource[:initiator_type] if resource[:initiator_type] 236 | args << "-ip" << resource[:ip_address] if resource[:ip_address] 237 | args << "-host" << resource[:hostname] if resource[:hostname] 238 | args << "-failovermode" << resource[:failover_mode] if resource[:failover_mode] 239 | args << "-arraycommpath" << resource[:array_commpath] if resource[:array_commpath] 240 | args << "-unitserialnumber" << resource[:unit_serialnumber] if resource[:unit_serialnumber] 241 | # puts "tohdat debug: running args...#{args}" 242 | run args 243 | end 244 | end 245 | 246 | #change the hosts 247 | if @property_flush[:host_name] 248 | #hostname = resource[:host_name] 249 | if @property_flush[:addonly] == :true 250 | args = ["storagegroup", "-connecthost", "-host", resource[:host_name], "-gname", resource[:sg_name], "-o"] 251 | run args 252 | end 253 | end 254 | 255 | 256 | 257 | #change the storage group name 258 | if @property_flush[:new_name] && (@property_flush[:new_name] != resource[:sg_name]) 259 | args = ["storagegroup", "-chgname", "-gname", resource[:sg_name], "-newgname", @property_flush[:new_name], "-o"] 260 | run args 261 | resource[:sg_name] = @property_flush[:new_name] 262 | end 263 | end 264 | 265 | def flush 266 | # destroy 267 | if @property_flush[:ensure] == :absent 268 | run(["storagegroup", "-destroy", "-gname", resource[:sg_name], "-o"]) 269 | @property_hash[:ensure] = :absent 270 | return 271 | end 272 | 273 | if exists? 274 | set_storagegroup 275 | else 276 | create_storagegroup 277 | end 278 | end 279 | 280 | def destroy 281 | @property_flush[:ensure] = :absent 282 | end 283 | 284 | def exists? 285 | current_properties[:ensure] == :present 286 | end 287 | end 288 | -------------------------------------------------------------------------------- /lib/puppet/provider/vnx_storagepool/vnx_storagepool.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require 'puppet_x/puppetlabs/transport/emc_vnx' 3 | rescue LoadError => e 4 | require 'pathname' # WORK_AROUND #14073 and #7788 5 | module_lib = Pathname.new(__FILE__).parent.parent.parent 6 | puts "MODULE LIB IS #{module_lib}" 7 | require File.join module_lib, 'puppet_x/puppetlabs/transport/emc_vnx' 8 | end 9 | 10 | Puppet::Type.type(:vnx_storagepool).provide(:vnx_storagepool) do 11 | include PuppetX::Puppetlabs::Transport::EMCVNX 12 | 13 | desc "Manages VNX Storage Pools." 14 | 15 | mk_resource_property_methods 16 | 17 | def initialize *args 18 | super 19 | @property_flush = {} 20 | end 21 | 22 | def get_current_properties 23 | storagepool = run(["storagepool", "-list", "-name", resource[:name]]) 24 | self.class.get_storagepool_properties(storagepool) 25 | end 26 | 27 | def self.get_storagepool_properties storagepool 28 | sp_info = { :ensure => :present } 29 | sp_lines = storagepool.split("\n") 30 | while line = sp_lines.shift 31 | if line.start_with?('Pool Name:') 32 | sp_name = line.gsub("Pool Name:", '').strip 33 | sp_info[:name] = sp_name 34 | end 35 | 36 | if line.start_with?('Pool ID:') 37 | value = line.gsub("Pool ID:", '').strip 38 | sp_info[:pool_id] = value 39 | end 40 | 41 | if line.start_with?('Raid Type:') 42 | value = line.gsub("Raid Type:", '').strip 43 | sp_info[:raid_type] = value 44 | end 45 | 46 | if line.start_with?('Percent Full Threshold:') 47 | value = line.gsub("Percent Full Threshold:", '').strip 48 | sp_info[:percent_full_threshold] = value 49 | end 50 | 51 | if line.start_with?('Description:') 52 | value = line.gsub("Description:", '').strip 53 | sp_info[:description] = value 54 | end 55 | 56 | if line.start_with?('Disk Type:') 57 | value = line.gsub("Disk Type:", '').strip 58 | sp_info[:disk_type] = value 59 | end 60 | 61 | if line.start_with?('State:') 62 | value = line.gsub("State:", '').strip 63 | sp_info[:state] = value.downcase.to_sym 64 | end 65 | 66 | if line.start_with?('Status:') 67 | value = line.gsub("Status:", '').strip 68 | sp_info[:status] = value 69 | end 70 | 71 | if line.start_with?('Current Operation:') 72 | value = line.gsub("Current Operation:", '').strip 73 | sp_info[:current_operation] = value 74 | end 75 | 76 | if line.start_with?('Current Operation State:') 77 | value = line.gsub("Current Operation State:", '').strip 78 | sp_info[:current_operation_state] = value 79 | end 80 | 81 | if line.start_with?('Current Operation Status:') 82 | value = line.gsub("Current Operation Status:", '').strip 83 | sp_info[:current_operation_status] = value 84 | end 85 | 86 | if line.start_with?('Current Operation Percent Completed:') 87 | value = line.gsub("Current Operation Percent Completed:", '').strip 88 | sp_info[:current_operation_percent_completed] = value 89 | end 90 | 91 | pattern = 'Raw Capacity (Blocks):' 92 | if line.start_with?(pattern) 93 | value = line.gsub(pattern, '').strip 94 | sp_info[:raw_capacity_blocks] = value 95 | next 96 | end 97 | 98 | pattern = 'Raw Capacity (GBs):' 99 | if line.start_with?(pattern) 100 | value = line.gsub(pattern, '').strip 101 | sp_info[:raw_capacity_gbs] = value 102 | next 103 | end 104 | 105 | pattern = 'User Capacity (Blocks):' 106 | if line.start_with?(pattern) 107 | value = line.gsub(pattern, '').strip 108 | sp_info[:user_capacity_blocks] = value 109 | next 110 | end 111 | 112 | pattern = 'User Capacity (GBs):' 113 | if line.start_with?(pattern) 114 | value = line.gsub(pattern, '').strip 115 | sp_info[:user_capacity_gbs] = value 116 | next 117 | end 118 | 119 | pattern = 'Consumed Capacity (Blocks):' 120 | if line.start_with?(pattern) 121 | value = line.gsub(pattern, '').strip 122 | sp_info[:consumed_capacity_blocks] = value 123 | next 124 | end 125 | 126 | pattern = 'Consumed Capacity (GBs):' 127 | if line.start_with?(pattern) 128 | value = line.gsub(pattern, '').strip 129 | sp_info[:consumed_capacity_gbs] = value 130 | next 131 | end 132 | 133 | pattern = 'Available Capacity (Blocks):' 134 | if line.start_with?(pattern) 135 | value = line.gsub(pattern, '').strip 136 | sp_info[:available_capacity_blocks] = value 137 | next 138 | end 139 | 140 | pattern = 'Available Capacity (GBs):' 141 | if line.start_with?(pattern) 142 | value = line.gsub(pattern, '').strip 143 | sp_info[:available_capacity_gbs] = value 144 | next 145 | end 146 | 147 | pattern = 'Percent Full:' 148 | if line.start_with?(pattern) 149 | value = line.gsub(pattern, '').strip 150 | sp_info[:percent_full] = value 151 | next 152 | end 153 | 154 | pattern = 'Total Subscribed Capacity (Blocks):' 155 | if line.start_with?(pattern) 156 | value = line.gsub(pattern, '').strip 157 | sp_info[:total_subscribed_capacity_blocks] = value 158 | next 159 | end 160 | 161 | pattern = 'Total Subscribed Capacity (GBs):' 162 | if line.start_with?(pattern) 163 | value = line.gsub(pattern, '').strip 164 | sp_info[:total_subscribed_capacity_gbs] = value 165 | next 166 | end 167 | 168 | pattern = 'Percent Subscribed:' 169 | if line.start_with?(pattern) 170 | value = line.gsub(pattern, '').strip 171 | sp_info[:percent_subscribed] = value 172 | next 173 | end 174 | 175 | pattern = 'Oversubscribed by (Blocks):' 176 | if line.start_with?(pattern) 177 | value = line.gsub(pattern, '').strip 178 | sp_info[:oversubscribed_by_blocks] = value 179 | next 180 | end 181 | 182 | pattern = 'Oversubscribed by (GBs):' 183 | if line.start_with?(pattern) 184 | value = line.gsub(pattern, '').strip 185 | sp_info[:oversubscribed_by_gbs] = value 186 | next 187 | end 188 | 189 | pattern = 'Disks:' 190 | if line.start_with?(pattern) 191 | disks = [] 192 | while /Bus (\d+) Enclosure (\d+) Disk (\d+)/ =~ sp_lines.first 193 | sp_lines.shift 194 | disks << "#{$1}_#{$2}_#{$3}" 195 | end 196 | sp_info[:disks] = disks 197 | next 198 | end 199 | 200 | pattern = 'LUNs:' 201 | if line.start_with?(pattern) 202 | value = line.gsub(pattern, '').strip 203 | sp_info[:luns] = value.split(",").map{|v| v.strip.to_i} 204 | next 205 | end 206 | end 207 | sp_info 208 | end 209 | 210 | # def self.instances 211 | # storage_pools=[] 212 | # output_lines = run(["storagepool", "-list"]).split("\n\n") 213 | # output_lines.each do |line_info| 214 | # storage_pools << new(get_storagepool_properties line_info) 215 | # end 216 | # storage_pools 217 | # end 218 | # 219 | # def self.prefetch(resources) 220 | # vnx_storagepool = instances 221 | # resources.keys.each do |name| 222 | # if provider = vnx_storagepool.find{ |storagepool| storagepool.name == name } 223 | # resources[name].provider = provider 224 | # end 225 | # end 226 | # end 227 | 228 | def set_storagepool 229 | run ["storagepool", "-cancelExpand", "-name", resource[:name]] if resource[:cancel_expand] == :true 230 | # raise error if resource disks less than current 231 | raise ArgumentError, "can't remove storagepool disks\ncurrent disks:#{current_properties[:disks]}\nchange to:#{resource[:disks]}" if resource[:disks] && !(current_properties[:disks] - resource[:disks]).empty? 232 | 233 | # run expand 234 | args = ["storagepool", "-expand", "-name", resource[:name]] 235 | origin_length = args.length + 1 236 | if @property_flush[:raid_type] 237 | args << "-rtype" << resource[:raid_type] 238 | if resource[:rdrive_count] 239 | args << "-rdrivecount" << resource[:rdrive_count] 240 | end 241 | end 242 | if @property_flush[:disks] && ((resource[:disks] || []).sort != (@property_hash[:disks] || []).sort) 243 | args << "-disks" 244 | args += (resource[:disks] - @property_hash[:disks]) 245 | end 246 | args << "-initialverify" if resource[:initialverify] == :true 247 | args << "-skipRules" if resource[:skip_rules] == :true 248 | args << "-o" 249 | run(args) if args.length > origin_length 250 | 251 | # run modify 252 | args = ["storagepool", "-modify", "-name", resource[:name]] 253 | origin_length = args.length + 1 254 | args << "-newName" << resource[:new_name] if resource[:new_name] && (resource[:new_name] != resource[:name]) 255 | args << "-description" << resource[:description] if @property_flush[:description] 256 | args << "-prcntFullThreshold" << resource[:percent_full_threshold] if @property_flush[:percent_full_threshold] 257 | args << "-autoTiering" << resource[:auto_tiering] if @property_flush[:auto_tiering] 258 | args << "-fastcache" << (resource[:ensure_fastcache] == :true ? "on" : "off") if @property_flush[:ensure_fastcache] 259 | args << "-snapPoolFullThresholdEnabled" << (resource[:snappool_fullthreshold] == :enabled ? "on" : "off") if @property_flush[:snappool_fullthreshold] 260 | args << "-snapPoolFullHWM" << resource[:snappool_hwm] if @property_flush[:snappool_hwm] 261 | args << "-snapPoolFullLWM" << resource[:snappool_lwm] if @property_flush[:snappool_lwm] 262 | args << "-snapSpaceUsedThresholdEnabled" << (resource[:snapspace_threshold] == :enabled ? "on" : "off") if @property_flush[:snapspace_threshold] 263 | args << "-snapSpaceUsedHWM" << resource[:snapspace_hwm] if @property_flush[:snapspace_hwm] 264 | args << "-snapSpaceUsedLWM" << resource[:snapspace_lwm] if @property_flush[:snapspace_lwm] 265 | 266 | args << "-o" 267 | if args.length > origin_length 268 | run(args) 269 | resource[:name] = resource[:new_name] if resource[:new_name] 270 | end 271 | end 272 | 273 | def create_storagepool 274 | create_pool = ["storagepool", "-create", "-name", resource[:name], "-disks", *resource[:disks]] 275 | create_pool << "-rtype" << resource[:raid_type] if resource[:raid_type] 276 | create_pool << "-rdrivecount" << resource[:rdrive_count] if resource[:rdrive_count] 277 | create_pool << "-description" << resource[:description] if resource[:description] 278 | create_pool << "-prcntFullThreshold" << resource[:percent_full_threshold] if resource[:percent_full_threshold] 279 | create_pool << "-skipRules" if resource[:skip_rules] == :true 280 | create_pool << "-autoTiering" << resource[:auto_tiering] if resource[:auto_tiering] 281 | create_pool << "-fastcache" << "on" if resource[:ensure_fastcache] == :true 282 | create_pool << "-fastcache" << "off" if resource[:ensure_fastcache] == :false 283 | create_pool << "--snapPoolFullThresholdEnabled" << "on" if resource[:snappool_fullthreshold] == :enabled 284 | create_pool << "--snapPoolFullThresholdEnabled" << "off" if resource[:snappool_fullthreshold] == :disabled 285 | create_pool << "-snapPoolFullHWM" << resource[:snappool_hwm] if resource[:snappool_hwm] 286 | create_pool << "-snapPoolFullLWM" << resource[:snappool_lwm] if resource[:snappool_lwm] 287 | create_pool << "-snapSpaceUsedThresholdEnabled" << "on" if resource[:snapspace_threshold] == :enabled 288 | create_pool << "-snapSpaceUsedThresholdEnabled" << "off" if resource[:snapspace_threshold] == :disabled 289 | create_pool << "-snapSpaceUsedHWM" << resource[:snapspace_hwm] if resource[:snapspace_hwm] 290 | create_pool << "-snapSpaceUsedLWM" << resource[:snapspace_lwm] if resource[:snapspace_lwm] 291 | create_pool << "-initialverify" << "yes" if resource[:initialverify] == :true 292 | create_pool << "-initialverify" << "no" if resource[:initialverify] == :false 293 | 294 | run(create_pool) 295 | @property_hash[:ensure] = :present 296 | end 297 | 298 | def create 299 | @property_flush[:ensure] = :present 300 | end 301 | 302 | def flush 303 | # destroy 304 | if @property_flush[:ensure] == :absent 305 | # destroy lun first 306 | @property_hash[:luns].each do |lun| 307 | args = ["lun", "-destroy", "-l", lun, "-o"] 308 | run args 309 | end 310 | run(["storagepool", "-destroy", "-name", resource[:name], "-o"]) 311 | @property_hash[:ensure] = :absent 312 | return 313 | end 314 | 315 | if exists? 316 | set_storagepool 317 | else 318 | create_storagepool 319 | end 320 | end 321 | 322 | def destroy 323 | @property_flush[:ensure] = :absent 324 | end 325 | 326 | def exists? 327 | current_properties[:ensure] == :present 328 | end 329 | end 330 | -------------------------------------------------------------------------------- /lib/puppet/type/transport.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:transport) do 2 | @doc = "Manage transport connectivity info such as username, password, server, scope." 3 | 4 | newparam(:name, :namevar => true) do 5 | desc "The name of the network transport." 6 | end 7 | 8 | newparam(:username) do 9 | end 10 | 11 | newparam(:password) do 12 | end 13 | 14 | newparam(:server) do 15 | end 16 | 17 | newparam(:scope) do 18 | defaultto 0 19 | newvalues(0,1,2) 20 | end 21 | 22 | newparam(:cli_path) do 23 | defaultto "/opt/Navisphere/bin/naviseccli" 24 | end 25 | end 26 | 27 | unless Puppet::Type.metaparams.include? :transport 28 | Puppet::Type.newmetaparam(:transport) do 29 | desc "Provide a new metaparameter for all resources called transport." 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_analyzer.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_analyzer) do 2 | @doc = "Manage VNX Analyzer settings." 3 | 4 | newparam(:name, :namevar => true) do 5 | desc "VNX Analyzer name, defaults to analyzer" 6 | defaultto :analyzer 7 | end 8 | 9 | newparam(:ensure_started) do 10 | desc "Controls starting and stopping the analyzer" 11 | defaultto :true 12 | newvalues(:true, :false) 13 | end 14 | 15 | newparam(:nar_interval) do 16 | desc "Polling interval for performance logging" 17 | validate do |value| 18 | fail("nar_interval must be an integer") unless value.is_a? Integer 19 | fail("Invalid value for nar_interval") unless value >= 60 and value <= 3600 20 | end 21 | end 22 | 23 | newparam(:rt_interval) do 24 | desc "Polling interval for real-time chart windows" 25 | validate do |value| 26 | fail("rt_interval must be an integer") unless value.is_a? Integer 27 | fail("Invalid value for rt_interval") unless value >= 60 and value <= 3600 28 | end 29 | end 30 | 31 | newparam(:non_stop) do 32 | desc "Sets performance logging to non_stop" 33 | defaultto :false 34 | newvalues(:true, :false) 35 | end 36 | 37 | newparam(:log_period) do 38 | desc "Sets performance logging to run for 1-7 days" 39 | validate do |value| 40 | fail("Log period must be an integer") unless value.is_a? Integer 41 | fail("Invalid log_period value") unless value >=1 and value <= 7 42 | end 43 | end 44 | 45 | newparam(:periodic_logging) do 46 | desc "Creates archive files at periods of 156 samples" 47 | defaultto :false 48 | newvalues(:true, :false) 49 | end 50 | 51 | newparam(:default_logging) do 52 | desc "Sets logging to defaults" 53 | defaultto :false 54 | newvalues(:true, :false) 55 | end 56 | 57 | validate do 58 | fail("Non_stop and log_period cannot be specified together") if self[:log_period] and self[:non_stop] 59 | end 60 | 61 | 62 | end 63 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_array.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_array) do 2 | @doc = "Manage EMC VNX Array name." 3 | 4 | ensurable 5 | 6 | newparam(:name, :namevar => true) do 7 | desc "The name for the VNX Array" 8 | validate do |value| 9 | fail("Length of name cannot exceed 64 characters") if value.length >64 10 | end 11 | end 12 | 13 | 14 | end 15 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_autotiering.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_autotiering) do 2 | @doc = "Manage EMC autotiering and autotiering schedule." 3 | 4 | newparam(:schedule, :namevar => true, :array_matching => :all) do 5 | desc "The days of the week for the scheduled VNX autotiering." 6 | validate do |value| 7 | validdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] 8 | fail("Invalid day for autotiering schedule") unless validdays.include?(value) 9 | end 10 | end 11 | 12 | newparam(:ensure_enabled) do 13 | desc "Controls the enabling and disabling of autotiering" 14 | defaultto :false 15 | newvalues(:false, :true) 16 | end 17 | 18 | newparam(:time) do 19 | desc "The time of day for VNX autotiering. 20 | Valid values are colon separated digits representing hour and time 21 | in the formate hh:mm or h:mm." 22 | validate do |value| 23 | fail("Invalid Time specificiation") unless value =~/^([01]?[0-9]|2[0-3]):[0-5][0-9]/ 24 | end 25 | end 26 | 27 | newparam(:duration) do 28 | desc "The duration for a manual relocation." 29 | validate do |value| 30 | fail("Invalid duration") unless value =~/^([01]?[0-9]|2[0-3]):[0-5][0-9]/ 31 | end 32 | end 33 | 34 | newparam(:relocation_rate) do 35 | desc "The rate for manual relocation; high, medium or low." 36 | defaultto :medium 37 | newvalues(:medium, :high, :low) 38 | end 39 | 40 | newparam(:poolname) do 41 | desc "The pool name for relocation. Specify pool name or 'all' to 42 | apply to all pools" 43 | end 44 | 45 | validate do 46 | if self[:ensure_enabled] == :true 47 | fail("Must specify schedule for autotiering") unless self[:time] or self[:days] or self[:duration] 48 | end 49 | end 50 | 51 | end 52 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_dns.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_dns) do 2 | @doc = "Manage EMC VNX DNS settings." 3 | 4 | ensurable 5 | 6 | newparam(:domain, :namevar => true) do 7 | desc "The DNS Domain name" 8 | end 9 | 10 | newproperty(:name_servers, :array_matching => all) do 11 | desc "The DNS name server IPv4 addresses." 12 | validate do |value| 13 | fail("Invalid IP address specified for nameserver") unless IPAddr.new(value).ipv4? 14 | end 15 | end 16 | 17 | newproperty(:search_list, :array_matching => all) do 18 | desc "The DNS search list." 19 | end 20 | 21 | end 22 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_domain.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_domain) do 2 | @doc = "Manage EMC VNX Domain settings." 3 | 4 | ensurable 5 | 6 | newparam(:domain, :namevar => true) do 7 | desc "The VNX Domain name" 8 | end 9 | 10 | newproperty(:ensure_member) do 11 | desc "Ensure a system is part of a VNX domain." 12 | newvalues(:true, :false) 13 | end 14 | 15 | newparam(:ensure_master) do 16 | desc "Sets the specified system as the domain master" 17 | newvalues(:true) 18 | end 19 | 20 | newparam(:domain_member) do 21 | desc "The IP address of the system to add to the VNX domain" 22 | validate do |value| 23 | fail("Invalid IP address specified for Domain member") unless IPAddr.new(value).ipv4? 24 | end 25 | end 26 | 27 | newparam(:old_user) do 28 | desc "Specify user to add system" 29 | end 30 | 31 | newparam(:old_password) do 32 | desc "Password for user" 33 | end 34 | 35 | newparam(:old_scope) do 36 | desc "The user scope, global, local, or LDAP" 37 | newvalues(:global, :local, :LDAP) 38 | end 39 | 40 | validate do 41 | if self[:old_scope] or self[:old_password] or self[:old_user] 42 | fail("Must specify user, password and scope together") unless self[:old_scope] and self[:old_password] and self[:old_user] 43 | end 44 | end 45 | 46 | end 47 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_eventmonitor.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_eventmonitor) do 2 | @doc = "Manage VNX systems to monitor." 3 | 4 | newparam(:system, :namevar => true) do 5 | desc "The VNX system" 6 | end 7 | 8 | newparam(:server) do 9 | desc "The host agent where the system is added" 10 | end 11 | 12 | newparam(:ensure_monitored) do 13 | desc "Manages adding and removing systems to monitor" 14 | defaultto :true 15 | newvalues(:true, :false) 16 | end 17 | 18 | newparam(:template_name) do 19 | desc "The Template filename to be imported to the template database" 20 | validate do |value| 21 | fail("Template filename is not a valid file path") unless File.file?(value) 22 | end 23 | end 24 | 25 | newparam(:file_path) do 26 | desc "The File path for exported templates" 27 | validate do |value| 28 | fail("Invalid file path specifed for export") unless File.directory?(value) 29 | end 30 | end 31 | 32 | newparam(:ensure_imported) do 33 | desc "Imports the template file" 34 | defaultto :true 35 | end 36 | 37 | newparam(:ensure_exported) do 38 | desc "Exports the template file" 39 | defaultto :true 40 | end 41 | 42 | newparam(:resolve_conflict) do 43 | desc "Resolves Template conflicts" 44 | defaultto :true 45 | end 46 | 47 | newparam(:ensure_swapped) do 48 | desc "Swaps the specified template with the current template name" 49 | validate do |value| 50 | fail("Invalid template name format") unless value =~/^\w+$/ 51 | end 52 | end 53 | 54 | 55 | end 56 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_eventtemplate.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_eventtemplate) do 2 | @doc = "Manage VNX Event Monitor Templates." 3 | 4 | newparam(:template_name, :namevar => true) do 5 | desc "The Template Name" 6 | validate do |value| 7 | fail("Invalid template name format") unless value =~/^\w+$/ 8 | end 9 | end 10 | 11 | newparam(:template_filename) do 12 | desc "The Template filename to be imported to the template database" 13 | validate do |value| 14 | fail("Template filename is not a valid file path") unless File.file?(value) 15 | end 16 | end 17 | 18 | newparam(:file_path) do 19 | desc "The File path for exported templates" 20 | validate do |value| 21 | fail("Invalid file path specifed for export") unless File.directory?(value) 22 | end 23 | end 24 | 25 | newparam(:ensure_imported) do 26 | desc "Imports the template file" 27 | defaultto :true 28 | end 29 | 30 | newparam(:ensure_exported) do 31 | desc "Exports the template file" 32 | defaultto :true 33 | end 34 | 35 | newparam(:resolve_conflict) do 36 | desc "Resolves Template conflicts" 37 | defaultto :true 38 | end 39 | 40 | newparam(:ensure_swapped) do 41 | desc "Swaps the specified template with the current template name" 42 | validate do |value| 43 | fail("Invalid template name format") unless value =~/^\w+$/ 44 | end 45 | end 46 | 47 | end 48 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_fastcache.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_fastcache) do 2 | @doc = "Manage EMC VNX FAST cache settings." 3 | 4 | ensurable 5 | 6 | newparam(:name, :namevar => true) do 7 | desc "Fast Cache Name" 8 | end 9 | 10 | newparam(:cache_mode) do 11 | desc "Cache mode, can be rw or ro" 12 | newvalues(:ro, :rw) 13 | end 14 | 15 | newparam(:raid_type) do 16 | desc "The FAST Cache raid type" 17 | defaultto :r_1 18 | newvalues(:r_1) 19 | end 20 | 21 | 22 | newproperty(:disks, :array_matching => :all) do 23 | desc "The VNX disks to be used for FAST Cache. 24 | Disks must be specified in an array." 25 | # Build up list of disks available for FAST Cache 26 | validate do |value| 27 | fail ("Invalid format for disks") unless value =~/(^\d{1})[_](\d{1})[_](\d{1})$/ 28 | end 29 | end 30 | 31 | validate do 32 | if self[:disks] or self[:raid_type] or self[:cache_mode] 33 | unless self[:disks] and self[:raid_type] and self[:cache_mode] 34 | fail("Disks, RAID Type, and Cache Mode are required to enable FAST Cache") 35 | end 36 | end 37 | end 38 | 39 | end 40 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_initiator.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_initiator) do 2 | @doc = "VNX Initiator/Hosts." 3 | 4 | ensurable 5 | 6 | newparam(:hbauid, :namevar => true) do 7 | desc "The HBA UID for an Initiator" 8 | end 9 | 10 | newparam(:hba_uid) do 11 | desc "The HBA UID for an Initiator not name" 12 | end 13 | 14 | newproperty(:failovermode) do 15 | desc "failover mode" 16 | end 17 | 18 | newproperty(:arraycommpath) do 19 | desc "Array Comm Path" 20 | end 21 | 22 | 23 | newproperty(:hostname) do 24 | desc "The host name of virtual machine" 25 | end 26 | 27 | newproperty(:ip_address) do 28 | desc "The IP address of virtual machine" 29 | validate do |value| 30 | fail("#{value} is not a valid IPv4 address") unless value.nil? || IPAddr.new(value).ipv4? 31 | end 32 | end 33 | 34 | newproperty(:ports, :array_matching => :all) do 35 | desc "Information about each port of this HBA" 36 | end 37 | 38 | # newparam(:sp) do 39 | # desc "The sevice port to register" 40 | # newvalues(:a, :b) 41 | # end 42 | 43 | # newparam(:sp_port) do 44 | # desc "SP port" 45 | # newvalues(0, 1) 46 | # end 47 | 48 | # newproperty(:storage_group_name) do 49 | # desc "Storage Group name." 50 | # end 51 | 52 | # newproperty(:storage_group_uid) do 53 | # desc "Storage Group uid." 54 | # validate do |value| 55 | # fail("#{value} is not a Integer") unless value.is_a? Integer 56 | # end 57 | # end 58 | end 59 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_iscsiport.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_iscsiport) do 2 | @doc = "Manage EMC VNX ISCSI Port settings." 3 | 4 | ensurable 5 | 6 | newparam(:name, :namevar => true) do 7 | desc "The VNX SP Port to configure" 8 | newvalues(:spa_0, :spa_1, :spb_0, :spb_1) 9 | end 10 | 11 | newparam(:vportid) do 12 | desc "The virtual Port ID." 13 | munge do |value| 14 | value = '0' unless self[:vportid] 15 | end 16 | validate do |value| 17 | fail("Vportid must be an integer") unless value.is_a? Integer 18 | end 19 | end 20 | 21 | newparam(:vlanid) do 22 | desc "The Port VLAN ID" 23 | validate do |value| 24 | fail ("#{value} is not a valid VLAN VALUE") unless value >= 0 and value <= 4095 25 | end 26 | end 27 | 28 | newparam(:enable_vlantag) do 29 | desc "Allows enabling or disabling of VLAN tagging" 30 | defaultto :false 31 | newvalues(:true, :false) 32 | end 33 | 34 | newparam(:address) do 35 | desc "THe IP Address of the SP Port" 36 | validate do |value| 37 | fail("#{value} is not a valid IPv4 address") unless IPAddr.new(value).ipv4? 38 | end 39 | end 40 | 41 | newparam(:subnetmask) do 42 | desc "The Subnet Mask for the SP Port" 43 | validate do |value| 44 | fail("#{value} is not a valid Subnet") unless IPAddr.new(value).ipv4? 45 | end 46 | end 47 | 48 | newparam(:gateway) do 49 | desc "The gateway address for the SP Port" 50 | validate do |value| 51 | fail("#{value} is not a valid Gateway address") unless IPAddr.new(value).ipv4? 52 | end 53 | end 54 | 55 | newparam(:initiator_authenticate) do 56 | desc "True sets this value to 0 or not required, False sets to 1 and required" 57 | defaultto :false 58 | newvalues(:true, :false) 59 | end 60 | 61 | newparam(:alias) do 62 | desc "The iSCSI port Alias" 63 | end 64 | 65 | newparam(:port_speeed) do 66 | desc "The Port speed" 67 | end 68 | 69 | newparam(:mtu) do 70 | desc "The MTU for the port" 71 | validate do |value| 72 | fail("Invalid MTU size") unless value < 9000 73 | end 74 | end 75 | 76 | end 77 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_ldap.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_ldap) do 2 | @doc = "Manage EMC VNX LDAP settings." 3 | 4 | ensurable 5 | 6 | newparam(:server, :namevar => true) do 7 | desc "The VNX LD Server IP Address" 8 | validate do |value| 9 | fail("#{value} is not a valid IP for LDAP") unless IPAddr.new(value).ipv4? 10 | end 11 | end 12 | 13 | newparam(:portnumber) do 14 | desc "The LDAP Port number, 389 for LDAN, 636 for LDAPS" 15 | validate do |value| 16 | fail("Invalid port number for LDAP") unless value==636 or value==389 17 | end 18 | end 19 | 20 | 21 | newparam(:servertype) do 22 | desc "The LDAP Server type" 23 | defaultto :ldap 24 | newvalues(:ldap, :ad) 25 | end 26 | 27 | newparam(:protocol) do 28 | desc "The LDAP Protocol" 29 | defaultto :ldap 30 | newvalues(:ldap, :ldaps) 31 | end 32 | 33 | newparam(:binddn) do 34 | desc "The login for LDAP/AD" 35 | validate do |value| 36 | fail("Login cannot exceed 512 characters") if value.length > 512 37 | fail("Invalid format for LDAP Login") unless value =~/^cn=\w+,ou=\w+,dc=\w+,dc=\w+$/ 38 | end 39 | end 40 | 41 | newparam(:bind_password) do 42 | desc "The LDAP password" 43 | validate do |value| 44 | fail("Password cannot exceed 512 characters") if value.length > 512 45 | end 46 | end 47 | 48 | newparam(:user_search_path) do 49 | desc "The LDAP user search path" 50 | validate do |value| 51 | fail("Invalid LDAP user search path") unless value =~/^ou=\w+,dc=\w+,dc=\w+$/ 52 | end 53 | end 54 | 55 | newparam(:group_search_path) do 56 | desc "The LDAP group search path" 57 | validate do |value| 58 | fail("Invalid LDAP group search path") unless value =~/^ou=\w+,dc=\w+,dc=\w+$/ 59 | end 60 | end 61 | 62 | newparam(:user_id_attribute) do 63 | desc "The attribute to which the user ID will be appended in the LDAP/AD servers" 64 | validate do |value| 65 | fail("Invalid user_id_attribute") if value.length > 128 66 | end 67 | end 68 | 69 | newparam(:user_name_attribute) do 70 | desc "The attribute to which the user's common name (cn) will be appended in the servers" 71 | validate do |value| 72 | fail("Invalid user_name_attribute") if value.length > 128 73 | end 74 | end 75 | 76 | newparam(:group_name_attribute) do 77 | desc "The attribute to which the user group's common name will be appended in the servers" 78 | validate do |value| 79 | fail("Invalid group_name_attribute") if value.length > 128 80 | end 81 | end 82 | 83 | newparam(:group_member_attribute) do 84 | desc "A search filter for the different attribute types to identify the different groups of members" 85 | validate do |value| 86 | fail("Invalid group_member_attribute") if value.length > 128 87 | end 88 | end 89 | 90 | newparam(:user_object_class) do 91 | desc "A search filter in a situation where a user has multiple entries in a server" 92 | validate do |value| 93 | fail("Invalid user_object_class") if value.length > 128 94 | end 95 | end 96 | 97 | newparam(:group_object_class) do 98 | desc "A search filter in a situation where a group has multiple entries in a server" 99 | validate do |value| 100 | fail("Invalid group_object_class") if value.length > 128 101 | end 102 | end 103 | 104 | newparam(:cert) do 105 | desc "The pathname of the trusted cert file to be uplodaded to the cert store" 106 | validate do |value| 107 | fail("Invalid cert path") unless File.file?(value) 108 | end 109 | end 110 | 111 | 112 | end 113 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_lun.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_lun) do 2 | @doc = "Manage EMC VNX LUNs." 3 | 4 | ensurable 5 | 6 | newproperty(:lun_number) do 7 | desc "The LUN Id." 8 | end 9 | 10 | newparam(:name, :namevar => true) do 11 | desc "The LUN name" 12 | validate do |value| 13 | fail("LUN name cannot exceed 64 characters") unless value.length <= 64 14 | end 15 | end 16 | 17 | newparam(:lun_name) do 18 | desc "The LUN name" 19 | validate do |value| 20 | fail("LUN name cannot exceed 64 characters") unless value.length <= 64 21 | end 22 | end 23 | 24 | newparam(:primary_lun_number) do 25 | desc "The primary LUN number" 26 | end 27 | 28 | newparam(:primary_lun_name) do 29 | desc "The primary LUN number" 30 | end 31 | 32 | newproperty(:new_name) do 33 | desc "The LUN new name" 34 | 35 | validate do |value| 36 | fail("LUN name cannot exceed 64 characters") unless value.length <= 64 37 | end 38 | end 39 | 40 | newparam(:type) do 41 | desc "LUN type, THIN or Thick. Unchangeable once created." 42 | newvalues(:thin, :nonthin, :snap) 43 | end 44 | 45 | newproperty(:capacity) do 46 | desc "The LUN capacity" 47 | munge do |value| 48 | value.to_i 49 | end 50 | end 51 | 52 | newproperty(:size_qual) do 53 | desc "Size qualifier for the LUN capacity" 54 | newvalues(:gb, :tb, :mb, :bc) 55 | end 56 | 57 | newproperty(:pool_name) do 58 | desc "Storage pool the LUN will belong to. Unchangeable once created." 59 | end 60 | 61 | newproperty(:pool_id) do 62 | desc "Storage pool the LUN will belong to. Unchangeable once created." 63 | end 64 | 65 | newproperty(:auto_assign) do 66 | desc "Specifies whether to use auto assign for the LUN. Unchangeable once created." 67 | newvalues(:true, :false) 68 | end 69 | 70 | newproperty(:offset) do 71 | desc "The LUN offset. Unchangeable once created." 72 | 73 | munge do |value| 74 | value.to_i 75 | end 76 | end 77 | 78 | newproperty(:tiering_policy) do 79 | desc "The LUN auto-tiering policy" 80 | newvalues(:no_movement, :auto_tier, :highest_available, :lowest_available) 81 | end 82 | 83 | newproperty(:initial_tier) do 84 | desc "The initial tier preference" 85 | newvalues(:optimize_pool, :lowest_available, :highest_available) 86 | end 87 | 88 | newproperty(:allow_snap_auto_delete) do 89 | desc "Allow deleting snap automatically when lun is deleted" 90 | newvalues(:true, :false) 91 | end 92 | 93 | newproperty(:allow_inband_snap_attach) do 94 | desc "Allow Inband Snap Attach" 95 | end 96 | 97 | newproperty(:ignore_thresholds) do 98 | desc "Forces the non-snap LUN to be created, ignoring possible threshold related error" 99 | newvalues(:true, :false) 100 | end 101 | 102 | newproperty(:allocation_policy) do 103 | desc "The allocation policy on the pool LUN." 104 | newvalues(:on_demand, :automatic) 105 | end 106 | 107 | newproperty(:default_owner) do 108 | desc "Default Service Port the LUN belong to" 109 | 110 | newvalues(:a, :b) 111 | end 112 | 113 | #============Read Only Properties=============# 114 | newproperty(:uid) do 115 | desc "UID" 116 | 117 | validate do 118 | fail "uid is read-only" 119 | end 120 | end 121 | 122 | newproperty(:current_owner) do 123 | desc "Current Service Port the LUN belong to" 124 | 125 | validate do 126 | fail "current_owner is read-only" 127 | end 128 | end 129 | 130 | newproperty(:allocation_owner) do 131 | desc "Allocation Service Port the LUN belong to" 132 | 133 | validate do 134 | fail "allocation_owner is read-only" 135 | end 136 | end 137 | 138 | newproperty(:user_capacity_blocks) do 139 | desc "User Capacity (Blocks)" 140 | 141 | validate do 142 | fail "user_capacity_blocks is read-only" 143 | end 144 | end 145 | 146 | newproperty(:consumed_capacity_blocks) do 147 | desc "Consumed Capacity (Blocks)" 148 | 149 | validate do 150 | fail "consumed_capacity_blocks is read-only" 151 | end 152 | end 153 | 154 | newproperty(:consumed_capacity) do 155 | desc "Consumed Capacity" 156 | 157 | validate do 158 | fail "consumed_capacity is read-only" 159 | end 160 | end 161 | 162 | newproperty(:raid_type) do 163 | desc "Raid Type of the LUN" 164 | 165 | validate do 166 | fail "Raid type is read-only" 167 | end 168 | end 169 | 170 | newproperty(:is_pool_lun) do 171 | newvalues(:true, :false) 172 | 173 | validate do 174 | fail "is_pool_lun is read-only" 175 | end 176 | end 177 | 178 | newproperty(:is_thin_lun) do 179 | newvalues(:true, :false) 180 | 181 | validate do 182 | fail "is_thin_lun is read-only" 183 | end 184 | end 185 | end 186 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_nqm.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_nqm) do 2 | @doc = "Manage EMC VNX Qos Settings." 3 | 4 | ensurable 5 | 6 | newparam(:name, :namevar => true) do 7 | desc "The IOclass name" 8 | validate do |value| 9 | fail("IOclass name cannot exceed 64 characters") unless value.length <= 64 10 | end 11 | end 12 | 13 | newproperty(:ioclass) do 14 | desc "The IOclass." 15 | end 16 | 17 | newproperty(:current_state) do 18 | desc "The current_state." 19 | end 20 | 21 | newproperty(:status) do 22 | desc "The status." 23 | end 24 | 25 | newproperty(:number_of_luns) do 26 | desc "The number_of_luns." 27 | end 28 | 29 | newproperty(:lun_number) do 30 | desc "The LUN Id." 31 | end 32 | 33 | newparam(:lun_name) do 34 | desc "The LUN name" 35 | validate do |value| 36 | fail("LUN name cannot exceed 64 characters") unless value.length <= 64 37 | end 38 | end 39 | 40 | newproperty(:lun_wwn) do 41 | desc "The LUN WWN." 42 | end 43 | 44 | newproperty(:raid_type) do 45 | desc "The raid_type." 46 | end 47 | 48 | newproperty(:io_type) do 49 | desc "The io_type." 50 | end 51 | 52 | newproperty(:io_size_range) do 53 | desc "The io_size_range." 54 | end 55 | 56 | newproperty(:control_method) do 57 | desc "The control_method." 58 | end 59 | 60 | newproperty(:metric_type) do 61 | desc "The metric_type." 62 | end 63 | 64 | newproperty(:goal_value) do 65 | desc "The goal_value." 66 | end 67 | 68 | newproperty(:anyio) do 69 | desc "The anyio." 70 | end 71 | 72 | newproperty(:policy_name) do 73 | desc "The policy name." 74 | end 75 | 76 | newproperty(:fail_action) do 77 | desc "The fail_action." 78 | end 79 | 80 | 81 | #============Read Only Properties=============# 82 | end 83 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_ntp.rb: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2014 EMC, Inc. 2 | Puppet::Type.newtype(:vnx_ntp) do 3 | @doc = "Manage EMC VNX NTP settings." 4 | 5 | ensurable 6 | 7 | newproperty(:ensure_running) do 8 | desc "Control whether NTP is started or not" 9 | defaultto :no 10 | newvalues(:yes, :no) 11 | end 12 | 13 | newproperty(:interval) do 14 | desc "The synchronization interval in minutes from 30 to 43200." 15 | validate do |value| 16 | fail("Invalid range for NTP") unless value.is_a? Integer and value >= 30 and value <= 43200 17 | end 18 | end 19 | 20 | newparam(:ntp_servers, :namevar => true, :array_matching => all) do 21 | desc "The NTP server address." 22 | validate do |value| 23 | fail("#{value} is not a valid value IPV4 address") unless IPAddr.new(value).ipv4? 24 | end 25 | end 26 | 27 | newparam(:server_key, :array_matching => :all) do 28 | desc "The NTP server key value." 29 | validate do |value| 30 | fail("Server_key values must be integer values") unless value.is_a? Integer 31 | fail("Server_key out of accepted range") unless value >= 0 and value <= 65534 32 | end 33 | end 34 | 35 | 36 | newparam(:keyvalue, :array_matching => :all) do 37 | desc "The NTP keyvalue for authentication." 38 | validate do |value| 39 | fail ("#{value} is not a valid keyvalue for NTP") unless value.length <= 16 and keyval =~ /^[ -~]+$/ and !(keyval =~ /#/) 40 | end 41 | end 42 | 43 | validate do 44 | fail("Cannot specify server_key without keyvalue") if self[:server_key] and self[:keyvalue].nil? 45 | fail("Cannot specify keyvalue without server_key") if self[:keyvalue] and self[:server_key].nil? 46 | fail("Invalid number of serverkey/keyvalue pairs") if self[:server_key].length != self[:keyvalue].length 47 | if :ensure_running == :yes 48 | fail("Must specify servers and interval") unless self[:servers] and self[:interval] 49 | end 50 | end 51 | 52 | 53 | end 54 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_sp.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_sp) do 2 | @doc = "Manage EMC VNX SP name and IP settings." 3 | 4 | ensurable 5 | 6 | newparam(:service_processor, :namevar => true) do 7 | desc "The Service Processor" 8 | newvalues(:a, :b) 9 | end 10 | 11 | newproperty(:sp_name) do 12 | desc "The Service Processor network name" 13 | validate do |value| 14 | fail("Length of name cannot exceed 64 characters") if value.length >64 15 | end 16 | end 17 | 18 | newparam(:ipaddress) do 19 | desc "The IPv4 address for the VNX SP" 20 | validate do |value| 21 | fail("Invalid IP address specified") unless IPAddr.new(value).ipv4? 22 | end 23 | end 24 | 25 | newparam(:subnetmask) do 26 | desc "The IP Subnet mask" 27 | validate do |value| 28 | fail("Invalid IP address for subnet mask") unless IPAddr.new(value).ipv4? 29 | end 30 | end 31 | 32 | newparam(:gateway) do 33 | desc "The IP gateway address" 34 | validate do |value| 35 | fail("Invalid IP address for gateway") unless IPAddr.new(value).ipv4? 36 | end 37 | end 38 | 39 | 40 | end 41 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_storagegroup.rb: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2014 EMC, Inc. 2 | Puppet::Type.newtype(:vnx_storagegroup) do 3 | @doc = "Manage EMC VNX storage groups." 4 | 5 | ensurable 6 | 7 | newparam(:name, :namevar => true) do 8 | desc "Storage group name." 9 | 10 | # validate do |value| 11 | # fail("Invalid Storage group name length") unless value.length <= 128 and value.length > 0 12 | # end 13 | end 14 | 15 | newparam(:sg_name) do 16 | desc "Storage group name." 17 | 18 | validate do |value| 19 | fail("Invalid Storage group name length") unless value.length <= 64 and value.length > 0 20 | end 21 | end 22 | 23 | newproperty(:hbauid) do 24 | desc "The HBA UID for an Initiator" 25 | 26 | validate do |value| 27 | fail("Invalid Storage group name length") unless value.length <= 64 and value.length > 0 28 | end 29 | end 30 | 31 | newproperty(:sp) do 32 | desc "Owner SP." 33 | 34 | validate do |value| 35 | fail("Invalid Storage group name length") unless value.length <= 64 and value.length > 0 36 | end 37 | end 38 | 39 | newproperty(:sp_port) do 40 | desc "Owner SP." 41 | 42 | validate do |value| 43 | fail("Invalid Storage group name length") unless value.length <= 64 and value.length > 0 44 | end 45 | end 46 | 47 | newproperty(:initiator_type) do 48 | desc "Owner SP." 49 | 50 | validate do |value| 51 | fail("Invalid Storage group name length") unless value.length <= 64 and value.length > 0 52 | end 53 | end 54 | 55 | newproperty(:ip_address) do 56 | desc "The IP address of virtual machine" 57 | validate do |value| 58 | fail("#{value} is not a valid IPv4 address") unless value.nil? || IPAddr.new(value).ipv4? 59 | end 60 | end 61 | 62 | newproperty(:hostname) do 63 | desc "Owner SP." 64 | 65 | validate do |value| 66 | fail("Invalid Storage group name length") unless value.length <= 64 and value.length > 0 67 | end 68 | end 69 | 70 | newproperty(:failover_mode) do 71 | desc "Owner SP." 72 | 73 | validate do |value| 74 | fail("Invalid Storage group name length") unless value.length <= 64 and value.length > 0 75 | end 76 | end 77 | 78 | newproperty(:array_commpath) do 79 | desc "Owner SP." 80 | 81 | validate do |value| 82 | fail("Invalid Storage group name length") unless value.length <= 64 and value.length > 0 83 | end 84 | end 85 | 86 | newproperty(:unit_serialnumber) do 87 | desc "Owner SP." 88 | 89 | validate do |value| 90 | fail("Invalid Storage group name length") unless value.length <= 64 and value.length > 0 91 | end 92 | end 93 | 94 | newproperty(:setpathonly) do 95 | desc "addonly only used when you don't want to move anything from storagegroup" 96 | newvalues(:true, :false) 97 | end 98 | 99 | 100 | newproperty(:addonly) do 101 | desc "addonly only used when you don't want to move anything from storagegroup" 102 | newvalues(:true, :false) 103 | end 104 | 105 | newproperty(:host_name) do 106 | desc "Host name." 107 | 108 | validate do |value| 109 | fail("Invalid Host name length") unless value.length <= 64 and value.length > 0 110 | end 111 | end 112 | 113 | newproperty(:uid) do 114 | desc "Storage group uid." 115 | 116 | validate do 117 | fail "uid is read-only" 118 | end 119 | end 120 | 121 | newproperty(:shareable) do 122 | desc "The storage group shareable property." 123 | newvalues(:true, :false) 124 | validate do 125 | fail "shareable is read-only" 126 | end 127 | end 128 | 129 | newproperty(:new_name) do 130 | desc "The storage group new name." 131 | end 132 | 133 | newproperty(:HBAs, :array_matching => :all) do 134 | desc "HBA/SP Pairs" 135 | validate do 136 | fail "hba_sp_pairs is read-only" 137 | end 138 | end 139 | 140 | newproperty(:luns, :array_matching => :all) do 141 | desc "HLU/ALU Pairs" 142 | 143 | def insync? is 144 | if [is, should].all?{|v| v.respond_to?(:map)} 145 | is.map{|pair| pair.values_at('hlu', 'alu').map &:to_s}.sort == should.map{|pair| pair.values_at('hlu', 'alu').map &:to_s}.sort 146 | else 147 | (is || :absent) == (should || :absent) 148 | end 149 | end 150 | end 151 | end 152 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_storagepool.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_storagepool) do 2 | @doc = "Manage EMC VNX storage pools." 3 | 4 | ensurable 5 | 6 | newparam(:name, :namevar => true) do 7 | desc "The storage pool name." 8 | isnamevar 9 | validate do |value| 10 | fail("Storage group name cannot exceed 64 characters") unless value.length <= 64 11 | end 12 | end 13 | 14 | newproperty(:disks, :array_matching => :all) do 15 | desc "The disks to add to the storage pool." 16 | 17 | validate do |*value| 18 | fail ("Invalid format for disks") unless value.all?{|v| v =~ /\A\d+\_\d+\_\d+\z/} 19 | end 20 | 21 | def insync? is 22 | is.sort == should.sort 23 | end 24 | 25 | end 26 | 27 | 28 | newproperty(:raid_type) do 29 | desc "The RAID type for the pool." 30 | munge do |value| 31 | if %w[r_5 r_6 R_10].include? value 32 | value.to_sym 33 | else 34 | value 35 | end 36 | end 37 | newvalues(:r_5, :r_6, :r_10) 38 | end 39 | 40 | newparam(:rdrive_count) do 41 | desc "The RAID drive count used to create internal RAID groups" 42 | end 43 | 44 | newproperty(:description) do 45 | desc "The storage pool description" 46 | validate do |value| 47 | fail("Description must be between 0 and 255 characters") unless value.length > 0 and value.length <=255 48 | end 49 | end 50 | 51 | newproperty(:percent_full_threshold) do 52 | desc "The percent full before alerts are generated" 53 | validate do |value| 54 | fail("Non-integer value specified") unless value.is_a? Integer 55 | fail("Invalid percent value") unless value >=1 and value <=84 56 | end 57 | end 58 | 59 | newparam(:skip_rules) do 60 | desc "Allows skipping rule checking when creating pools" 61 | newvalues(:true, :false) 62 | end 63 | 64 | newparam(:auto_tiering) do 65 | desc "Sets the auto tiering schedule" 66 | newvalues(:manual, :scheduled) 67 | end 68 | 69 | newparam(:ensure_fastcache) do 70 | desc "Enables or disables FAST Cache for the pool" 71 | newvalues(:true, :false) 72 | end 73 | 74 | newparam(:snappool_fullthreshold) do 75 | desc "Enables or disables checking HWM for auto delete" 76 | munge do |value| 77 | if %w[enabled disabled].include? value.downcase 78 | values.downcase.to_sym 79 | else 80 | value 81 | end 82 | end 83 | newvalues(:enabled, :disabled) 84 | end 85 | 86 | newparam(:snappool_hwm) do 87 | desc "The pool full HWM that triggers auto delete" 88 | validate do |value| 89 | fail("Invalid value for Snap Pool Full HWM") unless value.is_a? Integer and value > 0 and value < 100 90 | end 91 | end 92 | 93 | newparam(:snappool_lwm) do 94 | desc "The pool full LWM that stops auto delete" 95 | validate do |value| 96 | fail("Invalid value for Snap Pool Full LWM") unless value.is_a? Integer and value > 0 and value < 100 97 | end 98 | end 99 | 100 | newparam(:snapspace_threshold) do 101 | desc "Check snapshot space for HWM for auto delete" 102 | newvalues(:enabled, :disabled) 103 | end 104 | 105 | newparam(:snapspace_hwm) do 106 | desc "Snapshot space used HWM that triggers auto delete" 107 | validate do |value| 108 | fail("Invalid value for Snap Space Used HWM") unless value.is_a? Integer and value > 0 and value < 100 109 | end 110 | end 111 | 112 | newparam(:snapspace_lwm) do 113 | desc "Snapshot space LWM which stops auto delete" 114 | validate do |value| 115 | fail("Invalid value for Snap Space Used LWM") unless value.is_a? Integer and value > 0 and value < 100 116 | end 117 | end 118 | 119 | newparam(:initialverify) do 120 | desc "Specify whether initial verify is run on pool creation or expansion" 121 | newvalues(:true, :false) 122 | end 123 | 124 | newproperty(:cancel_expand) do 125 | desc "cancel expand" 126 | 127 | defaultto :false 128 | newvalues(:true, :false) 129 | end 130 | 131 | newproperty(:new_name) do 132 | desc "The new storage pool name." 133 | 134 | validate do |value| 135 | fail("Storage group name cannot exceed 64 characters") unless value.length <= 64 136 | end 137 | end 138 | 139 | #=================================read-only values===================== 140 | 141 | newproperty(:pool_id) do 142 | validate do 143 | fail "pool_id is read-only" 144 | end 145 | end 146 | 147 | newproperty(:disk_type) do 148 | desc "Disk Type" 149 | 150 | validate do 151 | fail "disk_type is read-only" 152 | end 153 | end 154 | 155 | newproperty(:state) do 156 | desc "State" 157 | 158 | validate do 159 | fail "state is read-only" 160 | end 161 | end 162 | 163 | newproperty(:status) do 164 | desc "Status" 165 | 166 | validate do 167 | fail "status is read-only" 168 | end 169 | end 170 | 171 | newproperty(:current_operation) do 172 | desc "Current Operation" 173 | 174 | validate do 175 | fail "current_operation is read-only" 176 | end 177 | end 178 | 179 | newproperty(:current_operation_state) do 180 | desc "Current Operation State" 181 | 182 | validate do 183 | fail "current_operation_state is read-only" 184 | end 185 | end 186 | 187 | newproperty(:current_operation_status) do 188 | desc "Current Operation Status" 189 | 190 | validate do 191 | fail "current_operation_status is read-only" 192 | end 193 | end 194 | 195 | newproperty(:current_operation_percent_completed) do 196 | desc "Current Operation Status Completed" 197 | 198 | validate do 199 | fail "current_operation_percent_completed is read-only" 200 | end 201 | end 202 | 203 | newproperty(:raw_capacity_blocks) do 204 | desc "Raw Capacity (Blocks)" 205 | 206 | validate do 207 | fail "raw_capacity_blocks is read-only" 208 | end 209 | end 210 | 211 | newproperty(:raw_capacity_gbs) do 212 | desc "Raw Capacity (GBs)" 213 | 214 | validate do 215 | fail "raw_capacity_gbs is read-only" 216 | end 217 | end 218 | 219 | newproperty(:user_capacity_blocks) do 220 | desc "User Capacity (Blocks)" 221 | validate do 222 | fail "user_capacity_blocks is read-only" 223 | end 224 | end 225 | 226 | newproperty(:user_capacity_gbs) do 227 | desc "User Capacity (GBs)" 228 | validate do 229 | fail "user_capacity_gbs is read-only" 230 | end 231 | end 232 | 233 | newproperty(:consumed_capacity_blocks) do 234 | desc "Consumed Capacity (Blocks)" 235 | validate do 236 | fail "consumed_capacity_blocks is read-only" 237 | end 238 | end 239 | 240 | newproperty(:consumed_capacity_gbs) do 241 | desc "Consumed Capacity (GBs)" 242 | validate do 243 | fail "consumed_capacity_gbs is read-only" 244 | end 245 | end 246 | 247 | newproperty(:available_capacity_blocks) do 248 | desc "Available Capacity (Blocks)" 249 | validate do 250 | fail "available_capacity_blocks is read-only" 251 | end 252 | end 253 | 254 | newproperty(:available_capacity_gbs) do 255 | desc "Available Capacity (GBs)" 256 | validate do 257 | fail "available_capacity_gbs is read-only" 258 | end 259 | end 260 | 261 | newproperty(:percent_full) do 262 | desc "Percent Full" 263 | validate do 264 | fail "percent_full is read-only" 265 | end 266 | end 267 | 268 | newproperty(:total_subscribed_capacity_blocks) do 269 | desc "Total Subscribed Capacity (Blocks)" 270 | validate do 271 | fail "total_subscribed_capacity_blocks is read-only" 272 | end 273 | end 274 | 275 | newproperty(:total_subscribed_capacity_gbs) do 276 | desc "Total Subscribed Capacity (GBs)" 277 | validate do 278 | fail "total_subscribed_capacity_gbs is read-only" 279 | end 280 | end 281 | 282 | newproperty(:percent_subscribed) do 283 | desc "Percent Subscribed" 284 | validate do 285 | fail "percent_subscribed is read-only" 286 | end 287 | end 288 | 289 | newproperty(:oversubscribed_by_blocks) do 290 | desc "Oversubscribed by (Blocks)" 291 | validate do 292 | fail "oversubscribed_by_blocks is read-only" 293 | end 294 | end 295 | 296 | newproperty(:oversubscribed_by_gbs) do 297 | desc "Oversubscribed by (GBs)" 298 | validate do 299 | fail "oversubscribed_by_gbs is read-only" 300 | end 301 | end 302 | 303 | newproperty(:luns, :array_matching => :all) do 304 | desc "LUNs" 305 | 306 | validate do 307 | fail "luns is read-only" 308 | end 309 | end 310 | 311 | end 312 | -------------------------------------------------------------------------------- /lib/puppet/type/vnx_storagesystemcache.rb: -------------------------------------------------------------------------------- 1 | Puppet::Type.newtype(:vnx_fastcache) do 2 | @doc = "Manage EMC VNX FAST cache settings." 3 | 4 | ensurable 5 | 6 | newparam(:disks) do 7 | desc "The VNX disks to be used for FAST Cache. 8 | Disks must be specified in a comma separated list." 9 | isnamevar 10 | validate do |value| 11 | value.gsub!(/\s+/, "") 12 | value.split(",") 13 | value.each do |val| 14 | unless vnxdiskslist.include?(val) 15 | raise ArgumentError, "Storage group names cannot exceed 64 characters." % value 16 | end 17 | end 18 | end 19 | end 20 | 21 | 22 | 23 | newparam(:mode) do 24 | desc "The VNX FAST Cache mode, can only be ro or rw." 25 | validate do |value| 26 | validmodes = ['ro', 'rw'] 27 | unless validmodes.include?(value) 28 | raise ArgumentError, "%s mode is not a valid FAST cache mode." % value 29 | end 30 | end 31 | end 32 | 33 | newparam(:rtype) do 34 | desc "The VNX FAST Cache raid type, can only be disk or r_1." 35 | validate do |value| 36 | validraid = ['disk', 'r_1'] 37 | unless validraid.include?(value) 38 | raise ArgumentError, "%s is not a valid RAID type for FAST cache." % value 39 | end 40 | end 41 | end 42 | 43 | end 44 | -------------------------------------------------------------------------------- /lib/puppet_x/puppetlabs/transport/emc_vnx.rb: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2014, EMC, Inc. 2 | 3 | require 'fileutils' 4 | require 'tmpdir' 5 | 6 | #if IO.respond_to?(:popen4) 7 | # def open4(*args) 8 | # op4 = IO.popen4(*args) 9 | # return op4 unless block_given? 10 | # yield op4 11 | # end 12 | #else 13 | # require 'open4' 14 | #end 15 | #require 'open3' 16 | require 'shellwords' 17 | 18 | module PuppetX 19 | module Puppetlabs 20 | module Transport 21 | module EMCVNX 22 | 23 | class Vnx 24 | 25 | #DEFAULT_ADMIN_SCOPE = 0 26 | #DEFAULT_CLI_PATH = '/opt/Navisphere/bin/naviseccli' 27 | 28 | attr_accessor :navicli 29 | attr_reader :array, :username, :password, :scope, :cli_path 30 | 31 | def initialize(option) 32 | @array = option[:array] 33 | @username = option[:username] 34 | @password = option[:password] 35 | @host_addr = option[:host_addr] 36 | @scope = option[:scope] #|| DEFAULT_ADMIN_SCOPE 37 | @cli_path = option[:cli_path] #|| DEFAULT_CLI_PATH 38 | Puppet.debug("#{self.class} initializing connection to: #{@array}") 39 | end 40 | 41 | def connect 42 | @navicli = setup_auth_file 43 | return 44 | end 45 | 46 | def secure_dir 47 | @secure_dir ||= Dir.mktmpdir("navicli-sec-", "/var/tmp") 48 | end 49 | 50 | def close 51 | FileUtils.remove_entry secure_dir 52 | end 53 | 54 | def setup_auth_file 55 | args = %W[-AddUserSecurity -password #{@password} -scope #{@scope} -user #{@username}] 56 | begin 57 | run(args, raise_on_failure=false) 58 | rescue 59 | # if this command fails, cleanup 60 | close 61 | raise 62 | end 63 | end 64 | 65 | def run(args, raise_on_failure=true) 66 | args = [ '-secfilepath', secure_dir, '-address', @host_addr] + args 67 | # err = out = nil 68 | #pid, stdin, stdout, stderr = open4(@cli_path, *args) 69 | # Open3.popen3(@cli_path, *args) do |stdin, stdout, stderr, t| 70 | # out = stdout.read 71 | # err = stderr.read 72 | # end 73 | output = `#{@cli_path} #{Shellwords.join args}` 74 | raise "Command error, output:\n#{output}" if raise_on_failure && !$?.success? 75 | output 76 | end 77 | 78 | end 79 | 80 | @vnxcli = nil 81 | 82 | def initial_cli() 83 | #Define VNX Login Info 84 | res = resource.catalog.resource(resource[:transport].to_s) 85 | if !res 86 | raise "Can't find transport" 87 | end 88 | option = {} 89 | option[:username] = res.provider.send(:username) 90 | option[:password] = res.provider.send(:password) 91 | option[:host_addr] = res.provider.send(:server) 92 | option[:array] = res.provider.send(:name) 93 | option[:scope] = res.provider.send(:scope) 94 | option[:cli_path] = res.provider.send(:cli_path) 95 | 96 | @vnxcli = Vnx.new(option) 97 | @vnxcli.connect 98 | end 99 | 100 | def run(args) 101 | if args.any? &:nil? 102 | raise ArgumentError, "Some arguments missing!. Arguments: #{args.inspect}." 103 | end 104 | 105 | args = args.map &:to_s #convert symbol, numbers to string 106 | 107 | if !@vnxcli 108 | initial_cli 109 | end 110 | debug "Run command: #{Shellwords.join args}" 111 | out = @vnxcli.run(args) 112 | debug out 113 | out 114 | end 115 | 116 | def self.included base 117 | base.send :extend, ClassMethods 118 | end 119 | 120 | 121 | def current_properties 122 | if @property_hash.empty? 123 | begin 124 | @property_hash = get_current_properties 125 | rescue 126 | @property_hash = {:ensure => :absent} 127 | end 128 | end 129 | @property_hash 130 | end 131 | 132 | module ClassMethods 133 | def mk_resource_property_methods 134 | [resource_type.validproperties, resource_type.parameters].flatten.each do |attr| 135 | attr = attr.intern 136 | next if attr == :name 137 | define_method(attr) do 138 | if current_properties[attr].nil? 139 | :absent 140 | else 141 | current_properties[attr] 142 | end 143 | end 144 | 145 | define_method(attr.to_s + "=") do |val| 146 | @property_flush[attr] = val 147 | end 148 | end 149 | end 150 | end 151 | end 152 | end 153 | end 154 | end -------------------------------------------------------------------------------- /metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swindlife-emc_vnx", 3 | "version": "0.1.5", 4 | "author": "swindlife", 5 | "summary": "Setup and configure EMC VNX resources", 6 | "license": "Apache License, Version 2.0", 7 | "source": "https://github.com/codedellemc/puppet-vnx.git", 8 | "project_page": "https://github.com/codedellemc/puppet-vnx", 9 | "issues_url": "https://github.com/emccode/puppet-vnx/issues", 10 | "dependencies": [] 11 | } 12 | 13 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | dir = File.expand_path(File.dirname(__FILE__)) 2 | $LOAD_PATH.unshift File.join(dir, 'lib') 3 | 4 | require 'mocha' 5 | require 'puppet' 6 | require 'rspec' 7 | require 'spec/autorun' 8 | 9 | Spec::Runner.configure do |config| 10 | config.mock_with :mocha 11 | end 12 | 13 | # We need this because the RAL uses 'should' as a method. This 14 | # allows us the same behaviour but with a different method name. 15 | class Object 16 | alias :must :should 17 | end 18 | -------------------------------------------------------------------------------- /tests/init.pp: -------------------------------------------------------------------------------- 1 | # The baseline for module testing used by Puppet Labs is that each manifest 2 | # should have a corresponding test manifest that declares that class or defined 3 | # type. 4 | # 5 | # Tests are then run by using puppet apply --noop (to check for compilation errors 6 | # and view a log of events) or by fully applying the test in a virtual environment 7 | # (to compare the resulting system state to the desired state). 8 | # 9 | # Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html 10 | # 11 | class vnx ( 12 | ){ 13 | } -------------------------------------------------------------------------------- /tests/initiator.pp: -------------------------------------------------------------------------------- 1 | transport { 'VNX': 2 | server => '10.13.180.6', 3 | username => 'nasadmin', 4 | password => 'nasadmin', 5 | } 6 | 7 | vnx_initiator { 'iqn_test': 8 | ensure => present, 9 | hostname => 'test_host', 10 | ip_address => '10.32.105.149', 11 | ports => [ {'sp' => a, 'sp_port' => 1} ], 12 | transport => Transport['VNX'], 13 | } -------------------------------------------------------------------------------- /tests/lun.pp: -------------------------------------------------------------------------------- 1 | transport { 'VNX': 2 | server => '10.13.180.6', 3 | username => 'nasadmin', 4 | password => 'nasadmin', 5 | } 6 | 7 | vnx_lun { 'test_lun': 8 | ensure => present, 9 | capacity => 10, 10 | pool_name => 'just_test', 11 | transport => Transport['VNX'], 12 | } -------------------------------------------------------------------------------- /tests/storage_group.pp: -------------------------------------------------------------------------------- 1 | transport { 'VNX': 2 | server => '10.13.180.6', 3 | username => 'nasadmin', 4 | password => 'nasadmin', 5 | } 6 | 7 | vnx_storagegroup { 'test_group': 8 | ensure => present, 9 | hlu_alu_pairs => [ {'hlu_number' => 0, 'alu_number' => 11} ], 10 | } -------------------------------------------------------------------------------- /tests/storage_pool.pp: -------------------------------------------------------------------------------- 1 | transport { 'VNX': 2 | server => '10.13.180.6', 3 | username => 'nasadmin', 4 | password => 'nasadmin', 5 | } 6 | 7 | vnx_storagepool { 'test_pool': 8 | ensure => present, 9 | raid_type => r_5, 10 | disks => ['0_1_0', '0_1_1', '0_1_2', '0_1_3', '0_1_4'], 11 | transport => Transport['VNX'], 12 | } --------------------------------------------------------------------------------