Class: OsCtl::ExportFS::Cli::Export

Inherits:
Command
  • Object
show all
Defined in:
lib/osctl/exportfs/cli/export.rb

Instance Attribute Summary

Attributes inherited from Command

#args, #gopts, #opts

Instance Method Summary collapse

Methods inherited from Command

#initialize, #require_args!, run

Constructor Details

This class inherits a constructor from OsCtl::ExportFS::Cli::Command

Instance Method Details

#addObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/osctl/exportfs/cli/export.rb', line 19

def add
  require_args!('server')

  ex = OsCtl::ExportFS::Export.new(
    dir: opts[:directory],
    as: opts[:as],
    host: opts[:host],
    options: opts[:options],
  )

  OsCtl::ExportFS::Operations::Export::Add.run(
    OsCtl::ExportFS::Server.new(args[0]),
    ex
  )
end

#listObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/osctl/exportfs/cli/export.rb', line 5

def list
  servers.each do |s|
    cfg = s.open_config
    cfg.exports.each do |ex|
      puts "server  = #{s.name}"
      puts "dir     = #{ex.dir}"
      puts "as      = #{ex.as}"
      puts "host    = #{ex.host}"
      puts "options = #{ex.options}"
      puts
    end
  end
end

#removeObject



35
36
37
38
39
40
41
42
43
# File 'lib/osctl/exportfs/cli/export.rb', line 35

def remove
  require_args!('server')

  OsCtl::ExportFS::Operations::Export::Remove.run(
    OsCtl::ExportFS::Server.new(args[0]),
    opts[:as],
    opts[:host],
  )
end

#serversObject (protected)



46
47
48
49
50
51
52
# File 'lib/osctl/exportfs/cli/export.rb', line 46

def servers
  if args[0]
    [OsCtl::ExportFS::Server.new(args[0])]
  else
    OsCtl::ExportFS::Operations::Server::List.run
  end
end