Class: Porkadot::Cmd::Etcd::Cli

Inherits:
SubCommandBase show all
Includes:
Utils
Defined in:
lib/porkadot/cmd/etcd.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#config, #logger

Methods inherited from SubCommandBase

banner

Class Method Details

.subcommand_prefixObject



63
64
65
# File 'lib/porkadot/cmd/etcd.rb', line 63

def self.subcommand_prefix
  'etcd'
end

Instance Method Details

#allObject



8
9
10
# File 'lib/porkadot/cmd/etcd.rb', line 8

def all
  "Use restore or backup sub commands."
end

#backupObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/porkadot/cmd/etcd.rb', line 15

def backup
  require 'date'

  filename = "etcd-#{DateTime.now.to_s}.db"
  path = File.join(options[:path], filename)

  logger.info "Backing up etcd data to #{path}"
  kubelets = Porkadot::Install::KubeletList.new(self.config)
  kubelets.backup_etcd host: options[:node], path: path
  ""
end

#restoreObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/porkadot/cmd/etcd.rb', line 47

def restore
  invoke :stop, [], options

  path = Dir.glob(File.join(options[:path], "etcd-*.db")).sort.reverse[0]
  unless path
    return "No backup data found...: #{options[:path]}"
  end

  logger.info "Restore etcd from #{path}"
  kubelets = Porkadot::Install::KubeletList.new(self.config)
  kubelets.restore_etcd path: path

  invoke :start, [], options
  ""
end

#startObject



29
30
31
32
33
34
# File 'lib/porkadot/cmd/etcd.rb', line 29

def start
  logger.info "Start etcd"
  kubelets = Porkadot::Install::KubeletList.new(self.config)
  kubelets.start_etcd hosts: options[:node]
  ""
end

#stopObject



38
39
40
41
42
43
# File 'lib/porkadot/cmd/etcd.rb', line 38

def stop
  logger.info "Start etcd"
  kubelets = Porkadot::Install::KubeletList.new(self.config)
  kubelets.stop_etcd hosts: options[:node]
  ""
end