Class: Serverspec::Type::RabbitmqVhostPolicy

Inherits:
RabbitmqBase show all
Defined in:
lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb

Instance Method Summary collapse

Methods inherited from RabbitmqBase

#length

Methods inherited from ApiBase

#[]

Constructor Details

#initialize(name = nil, vhost = nil, options = {}) ⇒ RabbitmqVhostPolicy

Returns a new instance of RabbitmqVhostPolicy.



7
8
9
10
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 7

def initialize(name = nil, vhost = nil, options = {})
  super(name, options)
  @vhost = vhost
end

Instance Method Details

#apply_to?(arg) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 64

def apply_to?(arg)
  inspection['apply-to'] == arg
end

#exist?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 24

def exist?
  !inspection.nil?
end

#ha_modeObject



32
33
34
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 32

def ha_mode
  inspection['definition']['ha-mode']
end

#ha_nodesObject



48
49
50
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 48

def ha_nodes
  inspection['definition']['ha-params']
end

#ha_sync_modeObject



40
41
42
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 40

def ha_sync_mode
  inspection['definition']['ha-sync-mode']
end

#has_ha_mode?(mode) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 28

def has_ha_mode?(mode)
  inspection['definition']['ha-mode'] == mode
end

#has_ha_nodes?(count) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 44

def has_ha_nodes?(count)
  inspection['definition']['ha-params'].to_i == count.to_i
end

#has_ha_sync_mode?(mode) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 36

def has_ha_sync_mode?(mode)
  inspection['definition']['ha-sync-mode'] == mode
end

#inspectionObject



12
13
14
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 12

def inspection
  @inspection ||= ::MultiJson.load(get_inspection.stdout).find { |itm| itm['name'] == @name }
end

#mirror_all?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 52

def mirror_all?
  apply_to?('all')
end

#mirror_exchanges?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 60

def mirror_exchanges?
  apply_to?('exchanges')
end

#mirror_queues?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 56

def mirror_queues?
  apply_to?('queues')
end

#to_sObject



16
17
18
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 16

def to_s
  "RabbitMQ policy '#{@name}' on vhost '#{@vhost}'"
end

#urlObject



20
21
22
# File 'lib/serverspec_extra_types/types/rabbitmq_vhost_policy.rb', line 20

def url
  "#{@url_base}/api/policies/#{@vhost}"
end