Module: PuppetX::EnterpriseModules::Oracle::AuditProperty

Defined in:
lib/puppet_x/enterprisemodules/oracle/audit_property.rb

Overview

Docs

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(parent) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/puppet_x/enterprisemodules/oracle/audit_property.rb', line 11

def self.included(parent)
  parent.extend(ClassMethods)
  if Puppet.const_defined?(:ResourceApi)
    parent.data_type("Optional[Enum['absent','none','by_access','by_session']]")
  else
    parent.newvalues(:absent, :none, :by_access, :by_session)
  end
end

Instance Method Details

#on_applyObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/puppet_x/enterprisemodules/oracle/audit_property.rb', line 20

def on_apply
  clause = case name.to_s
           when /.*_failure/
             'not successful'
           when /.*_success/
             'successful'
           else
             fail "#{name} is invalid here"
           end

  audit_type = name.to_s.split('_').first

  if value.to_s == 'none'
    sql("noaudit #{audit_type} on #{resource.owner}.#{resource.object_name} whenever #{clause}", :sid => resource.sid)
  else
    sql("audit #{audit_type} on #{resource.owner}.#{resource.object_name} #{value.to_s.tr('_', ' ')} whenever #{clause}", :sid => resource.sid)
  end
end