Class: PuppetX::Sqlserver::Features
- Inherits:
-
Object
- Object
- PuppetX::Sqlserver::Features
- Defined in:
- lib/puppet_x/sqlserver/features.rb
Overview
msdn.microsoft.com/en-us/library/ms143786.aspx basic feature docs
Class Method Summary collapse
-
.get_features ⇒ Object
return a hash of version => shared features array.
-
.get_instance_info(version, instance_name) ⇒ Object
returns a hash containing instance details.
-
.get_instances ⇒ Object
return a hash of version => instance info.
Class Method Details
.get_features ⇒ Object
return a hash of version => shared features array
{ “SQL_2012” => [“Conn”, “SDK”, “MDS”, “BC”, “SSMS”, “ADV_SSMS”, “IS”], “SQL_2014” => [] }
247 248 249 250 251 |
# File 'lib/puppet_x/sqlserver/features.rb', line 247 def self.get_features features = {} ALL_SQL_VERSIONS.each { |version| features[version] = get_shared_features(version) } features end |
.get_instance_info(version, instance_name) ⇒ Object
returns a hash containing instance details
{ “name” => “MSSQLSERVER2”, “version_friendly” => “SQL_2014”, “version” => “12.0.2000.8”, “reg_root” => “SoftwareMicrosoftMicrosoft SQL ServerMSSQL12.MSSQLSERVER2”, “features” =>[ “Replication”, “SQLEngine”, “FullText”, “DQ”, “AS”, “RS” ] }
269 270 271 272 273 274 275 276 277 278 |
# File 'lib/puppet_x/sqlserver/features.rb', line 269 def self.get_instance_info(version, instance_name) return nil if version.nil? sql_instance = get_wmi_instance_info(version, instance_name) # Instance names are unique on a single host, but not for a particular SQL Server version therefore # it's possible to request information for a valid instance_name but not for version. In this case # we just return nil. return nil if sql_instance['reg_root'].nil? feats = get_instance_features(sql_instance['reg_root'], sql_instance['name']) sql_instance.merge({'features' => feats}) end |
.get_instances ⇒ Object
return a hash of version => instance info
{ “SQL_2012” => {}, “SQL_2014” => { “MSSQLSERVER” => { “name” => “MSSQLSERVER”, “version_friendly” => “SQL_2014”, “version” => “12.0.2000.8”, “reg_root” => “SoftwareMicrosoftMicrosoft SQL ServerMSSQL12.MSSQLSERVER”, “features” => [ “Replication”, “SQLEngine”, “FullText”, “DQ”, “AS”, “RS” ] } } }
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/puppet_x/sqlserver/features.rb', line 213 def self.get_instances version_instance_map = ALL_SQL_VERSIONS .map do |version| major_version = SQL_CONFIGURATION[version][:major_version] instances = get_instance_names_by_ver(version) .map { |name| [ name, get_instance_info(version, name) ] } # Instance names are unique on a single host, but not for a particular SQL Server version therefore # it's possible to request information for a valid instance_name but not for version. In this case # we just reject any instances that have no information instances.reject! { |value| value[1].nil? } # Unfortunately later SQL versions can return previous version SQL instances. We can weed these out # by inspecting the major version of the instance_version instances.reject! do |value| return true if value[1]['version'].nil? ver = Gem::Version.new(value[1]['version']) # Segment 0 is the major version number of the SQL Instance ver.segments[0] != major_version end [ version, Hash[instances] ] end Hash[version_instance_map] end |