Class: OsCtl::ExportFS::Cli::Server
- Defined in:
- lib/osctl/exportfs/cli/server.rb
Constant Summary collapse
- FIELDS =
%i[server state netif address].freeze
Instance Method Summary collapse
- #attach ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #list ⇒ Object
- #parse_nfs_versions(opt) ⇒ Object protected
- #restart ⇒ Object
- #server_options ⇒ Object protected
- #set ⇒ Object
- #spawn ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods inherited from Command
Constructor Details
This class inherits a constructor from OsCtl::ExportFS::Cli::Command
Instance Method Details
#attach ⇒ Object
81 82 83 84 |
# File 'lib/osctl/exportfs/cli/server.rb', line 81 def attach require_args!('name') OsCtl::ExportFS::Operations::Server::Attach.run(args[0]) end |
#create ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/osctl/exportfs/cli/server.rb', line 37 def create require_args!('name') OsCtl::ExportFS::Operations::Server::Create.run( args[0], options: ) end |
#delete ⇒ Object
45 46 47 48 |
# File 'lib/osctl/exportfs/cli/server.rb', line 45 def delete require_args!('name') OsCtl::ExportFS::Operations::Server::Delete.run(args[0]) end |
#list ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/osctl/exportfs/cli/server.rb', line 8 def list if opts[:list] puts FIELDS.join("\n") return end fmt_opts = { layout: :columns, cols: opts[:output] ? opts[:output].split(',').map(&:to_sym) : FIELDS, sort: opts[:sort] && opts[:sort].split(',').map(&:to_sym) } fmt_opts[:header] = false if opts['hide-header'] OsCtl::Lib::Cli::OutputFormatter.print( OsCtl::ExportFS::Operations::Server::List.run.map do |s| cfg = s.open_config { server: s.name, state: s.running? ? 'running' : 'stopped', netif: cfg.netif, address: cfg.address } end, **fmt_opts ) end |
#parse_nfs_versions(opt) ⇒ Object (protected)
106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/osctl/exportfs/cli/server.rb', line 106 def parse_nfs_versions(opt) return if opt.nil? ret = opt.split(',') choices = OsCtl::ExportFS::Config::Nfsd::VERSIONS ret.each do |v| unless choices.include?(v) raise "invalid NFS version '#{v}', possible values are: #{choices.join(', ')}" end end ret end |
#restart ⇒ Object
70 71 72 73 74 |
# File 'lib/osctl/exportfs/cli/server.rb', line 70 def restart require_args!('name') runsv = OsCtl::ExportFS::Operations::Server::Runsv.new(args[0]) runsv.restart end |
#server_options ⇒ Object (protected)
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/osctl/exportfs/cli/server.rb', line 88 def { address: opts['address'], netif: opts['netif'], nfsd: { port: opts['nfsd-port'], nproc: opts['nfsd-nproc'], tcp: opts['nfsd-tcp'], udp: opts['nfsd-udp'], versions: parse_nfs_versions(opts['nfs-versions']), syslog: opts['nfsd-syslog'] }, mountd_port: opts['mountd-port'], lockd_port: opts['lockd-port'], statd_port: opts['statd-port'] } end |
#set ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/osctl/exportfs/cli/server.rb', line 50 def set require_args!('name') OsCtl::ExportFS::Operations::Server::Configure.run( OsCtl::ExportFS::Server.new(args[0]), ) end |
#spawn ⇒ Object
76 77 78 79 |
# File 'lib/osctl/exportfs/cli/server.rb', line 76 def spawn require_args!('name') OsCtl::ExportFS::Operations::Server::Spawn.run(args[0]) end |