Class: OsCtl::ExportFS::Operations::Export::Remove
- Includes:
- Lib::Utils::File, Lib::Utils::Log, Lib::Utils::System
- Defined in:
- lib/osctl/exportfs/operations/export/remove.rb
Overview
Remove export from a NFS server
Instance Attribute Summary collapse
-
#cfg ⇒ Object
readonly
protected
Returns the value of attribute cfg.
-
#export ⇒ Object
readonly
protected
Returns the value of attribute export.
-
#server ⇒ Object
readonly
protected
Returns the value of attribute server.
-
#sys ⇒ Object
readonly
protected
Returns the value of attribute sys.
Instance Method Summary collapse
-
#disable_share(unmount: true) ⇒ Object
protected
Unexport and unmount the directory from the server namespace.
- #execute ⇒ Object
-
#initialize(server, as, host) ⇒ Remove
constructor
A new instance of Remove.
-
#remove_from_exports ⇒ Object
protected
Remove the export from the database.
Methods inherited from Base
Constructor Details
#initialize(server, as, host) ⇒ Remove
Returns a new instance of Remove.
15 16 17 18 19 20 21 |
# File 'lib/osctl/exportfs/operations/export/remove.rb', line 15 def initialize(server, as, host) super() @server = server @cfg = server.open_config @export = cfg.exports.lookup(as, host) @sys = OsCtl::Lib::Sys.new end |
Instance Attribute Details
#cfg ⇒ Object (readonly, protected)
Returns the value of attribute cfg.
35 36 37 |
# File 'lib/osctl/exportfs/operations/export/remove.rb', line 35 def cfg @cfg end |
#export ⇒ Object (readonly, protected)
Returns the value of attribute export.
35 36 37 |
# File 'lib/osctl/exportfs/operations/export/remove.rb', line 35 def export @export end |
#server ⇒ Object (readonly, protected)
Returns the value of attribute server.
35 36 37 |
# File 'lib/osctl/exportfs/operations/export/remove.rb', line 35 def server @server end |
#sys ⇒ Object (readonly, protected)
Returns the value of attribute sys.
35 36 37 |
# File 'lib/osctl/exportfs/operations/export/remove.rb', line 35 def sys @sys end |
Instance Method Details
#disable_share(unmount: true) ⇒ Object (protected)
Unexport and unmount the directory from the server namespace
44 45 46 47 48 49 50 51 |
# File 'lib/osctl/exportfs/operations/export/remove.rb', line 44 def disable_share(unmount: true) Operations::Server::Exec.run(server) do server.enter_ns Operations::Exportfs::Generate.run(server) syscmd("exportfs -u \"#{export.host}:#{export.as}\"") sys.unmount(export.as) if unmount end end |
#execute ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/osctl/exportfs/operations/export/remove.rb', line 23 def execute return if export.nil? remove_from_exports return unless server.running? disable_share(unmount: cfg.exports.find_by_as(export.as).nil?) end |
#remove_from_exports ⇒ Object (protected)
Remove the export from the database
38 39 40 41 |
# File 'lib/osctl/exportfs/operations/export/remove.rb', line 38 def remove_from_exports cfg.exports.remove(export) cfg.save end |