Class: OsCtld::Container::Hooks::PreMount

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

Instance Attribute Summary

Attributes inherited from Base

#ct

Attributes inherited from Hook::Base

#event_instance, #opts

Instance Method Summary collapse

Methods inherited from Base

ct_hook, #setup

Methods inherited from Hook::Base

blocking, blocking?, #blocking?, #exec, hook, #initialize, #setup

Constructor Details

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

Instance Method Details

#environment ⇒ Object (protected)



67
68
69
70
71
72
# File 'lib/osctld/container/hooks.rb', line 67

def environment
  super.merge({
    'OSCTL_CT_ROOTFS_MOUNT' => opts[:rootfs_mount],
    'OSCTL_CT_NS_PID' => opts[:ns_pid].to_s
  })
end

#executable(hook_path) ⇒ Object (protected)



74
75
76
77
78
79
80
# File 'lib/osctld/container/hooks.rb', line 74

def executable(hook_path)
  if opts[:mnt_ns]
    ['nsenter', "--mount=/proc/self/fd/#{opts[:mnt_ns].fileno}", hook_path]
  else
    ['nsenter', '--target', opts.fetch(:ns_pid).to_s, '--mount', hook_path]
  end
end

#inherited_files ⇒ Object (protected)



82
83
84
# File 'lib/osctld/container/hooks.rb', line 82

def inherited_files
  [opts[:mnt_ns]].compact
end