Class: OsCtld::Container::Hooks::Base

Inherits:
Hook::Base
  • Object
show all
Defined in:
lib/osctld/container/hooks.rb

Instance Attribute Summary collapse

Attributes inherited from Hook::Base

#event_instance, #opts

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Hook::Base

blocking, blocking?, #blocking?, #exec, #executable, hook, #initialize

Constructor Details

This class inherits a constructor from OsCtld::Hook::Base

Instance Attribute Details

#ctContainer (readonly)

Returns:



13
14
15
# File 'lib/osctld/container/hooks.rb', line 13

def ct
  @ct
end

Class Method Details

.ct_hook(hook_name) ⇒ Object

Register container hook under a name

Parameters:

  • hook_name (Symbol)


8
9
10
# File 'lib/osctld/container/hooks.rb', line 8

def self.ct_hook(hook_name)
  hook(Container, hook_name, self)
end

Instance Method Details

#environmentObject (protected)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/osctld/container/hooks.rb', line 21

def environment
  super.merge({
    'OSCTL_POOL_NAME' => ct.pool.name,
    'OSCTL_CT_ID' => ct.id,
    'OSCTL_CT_USER' => ct.user.name,
    'OSCTL_CT_GROUP' => ct.group.name,
    'OSCTL_CT_DATASET' => ct.get_run_conf.dataset.to_s,
    'OSCTL_CT_ROOTFS' => ct.get_run_conf.rootfs,
    'OSCTL_CT_LXC_PATH' => ct.lxc_home,
    'OSCTL_CT_LXC_DIR' => ct.lxc_dir,
    'OSCTL_CT_CGROUP_PATH' => ct.cgroup_path,
    'OSCTL_CT_DISTRIBUTION' => ct.get_run_conf.distribution,
    'OSCTL_CT_VERSION' => ct.get_run_conf.version,
    'OSCTL_CT_HOSTNAME' => ct.hostname.to_s,
    'OSCTL_CT_LOG_FILE' => ct.log_path
  })
end

#setupObject



15
16
17
# File 'lib/osctld/container/hooks.rb', line 15

def setup
  @ct = event_instance
end