Module: OsCtld::Migration

Defined in:
lib/osctld/migration.rb

Defined Under Namespace

Modules: Commands Classes: Command, KeyChain, Log, Server

Constant Summary collapse

USER =
'migration'
UID =
Etc.getpwnam(USER).uid
SOCKET =
File.join(RunState::MIGRATION_DIR, 'control.sock')
AUTHORIZED_KEYS =
File.join(RunState::MIGRATION_DIR, 'authorized_keys')
HOOK =
File.join(RunState::MIGRATION_DIR, 'run')

Class Method Summary collapse

Class Method Details

.assets(add) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/osctld/migration.rb', line 37

def self.assets(add)
  add.symlink(
    HOOK,
    desc: 'Command run by remote node'
  )
  add.file(
    AUTHORIZED_KEYS,
    desc: 'Keys that are authorized to migrate to this node',
    user: UID,
    group: 0,
    mode: 0400
  )

  Server.assets(add)
end

.deployObject



27
28
29
30
# File 'lib/osctld/migration.rb', line 27

def self.deploy
  reset
  DB::Pools.get.each { |pool| pool.migration_key_chain.deploy }
end

.resetObject



32
33
34
35
# File 'lib/osctld/migration.rb', line 32

def self.reset
  File.open(AUTHORIZED_KEYS, 'w', 0400).close
  File.chown(UID, 0, AUTHORIZED_KEYS)
end

.setupObject



14
15
16
17
18
19
20
21
# File 'lib/osctld/migration.rb', line 14

def self.setup
  Server.start
  reset

  unless File.symlink?(HOOK)
    File.symlink(OsCtld::hook_src('migration'), HOOK)
  end
end

.stopObject



23
24
25
# File 'lib/osctld/migration.rb', line 23

def self.stop
  Server.stop
end