Class: Inspec::Resources::AzureVirtualMachineDataDisk

Inherits:
AzureResourceBase show all
Defined in:
lib/resources/azure/azure_virtual_machine_data_disk.rb

Instance Attribute Summary

Attributes inherited from AzureResourceBase

#azure, #client, #opts

Instance Method Summary collapse

Methods inherited from AzureResourceBase

#catch_azure_errors, #create_tag_methods, #failed_resource?, #has_tags?, #resource_group, #resources, #tag_count

Constructor Details

#initialize(opts = {}) ⇒ AzureVirtualMachineDataDisk

Constructor for the resource. This calls the parent constructor to get the generic resource for the specified machine. This will provide static methods that are documented

Author:

  • Russell Seymour



39
40
41
42
43
44
45
46
# File 'lib/resources/azure/azure_virtual_machine_data_disk.rb', line 39

def initialize(opts = {})
  # The generic resource needs to pass back a Microsoft.Compute/virtualMachines object so force it
  opts[:type] = 'Microsoft.Compute/virtualMachines'
  super(opts)

  # Get the data disks
  resources
end

Instance Method Details

#countObject

Return an integer stating how many data disks are attached to the machine



67
68
69
# File 'lib/resources/azure/azure_virtual_machine_data_disk.rb', line 67

def count
  entries.count
end

#datadisk_detailsObject

Return information about the disks and add to the filter table so that assertions can be performed

Author:

  • Russell Seymour



52
53
54
55
56
57
58
59
# File 'lib/resources/azure/azure_virtual_machine_data_disk.rb', line 52

def datadisk_details
  return if failed_resource?
  # Iterate around the data disks on the machine
  properties.storageProfile.dataDisks.each_with_index.map do |datadisk, index|
    # Call function to parse the data disks and return an object based on the parameters
    parse_datadisk(datadisk, index)
  end
end

#has_data_disks?Boolean

Return boolean to denote if the machine has data disks attached or not

Returns:

  • (Boolean)


62
63
64
# File 'lib/resources/azure/azure_virtual_machine_data_disk.rb', line 62

def has_data_disks?
  !entries.empty?
end

#has_managed_disks?Boolean

Return boolean to state if the machine is using managed disks for data disks

Returns:

  • (Boolean)


72
73
74
75
76
# File 'lib/resources/azure/azure_virtual_machine_data_disk.rb', line 72

def has_managed_disks?
  # iterate around the entries
  result = entries.each.select { |e| e[:is_managed_disk?] }
  result.empty? ? false : true
end