Class: OsCtl::ExportFS::Operations::Server::Create
- Includes:
- Lib::Utils::Log, Lib::Utils::System
- Defined in:
- lib/osctl/exportfs/operations/server/create.rb
Overview
Create the server configuration
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
protected
Returns the value of attribute opts.
-
#server ⇒ Object
readonly
protected
Returns the value of attribute server.
-
#sys ⇒ Object
readonly
protected
Returns the value of attribute sys.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(name, opts = {}) ⇒ Create
constructor
A new instance of Create.
-
#symlink!(src, dst) ⇒ Object
protected
Forcefully create a symlink be removing existing ‘dst`.
Methods inherited from Base
Constructor Details
Instance Attribute Details
#opts ⇒ Object (readonly, protected)
Returns the value of attribute opts.
48 49 50 |
# File 'lib/osctl/exportfs/operations/server/create.rb', line 48 def opts @opts end |
#server ⇒ Object (readonly, protected)
Returns the value of attribute server.
48 49 50 |
# File 'lib/osctl/exportfs/operations/server/create.rb', line 48 def server @server end |
#sys ⇒ Object (readonly, protected)
Returns the value of attribute sys.
48 49 50 |
# File 'lib/osctl/exportfs/operations/server/create.rb', line 48 def sys @sys end |
Instance Method Details
#execute ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/osctl/exportfs/operations/server/create.rb', line 21 def execute if Dir.exist?(server.dir) raise 'server already exists' end FileUtils.mkdir_p(server.dir) server.synchronize do FileUtils.mkdir_p(server.nfs_state) # Remount the shared dir with --make-shared unless Dir.exist?(server.shared_dir) FileUtils.mkdir_p(server.shared_dir) sys.bind_mount(server.shared_dir, server.shared_dir) sys.make_shared(server.shared_dir) end # Initialize the config file Operations::Server::Configure.run(server, opts[:options]) # Create an empty exports file File.new(server.exports_file, 'w').close end end |
#symlink!(src, dst) ⇒ Object (protected)
Forcefully create a symlink be removing existing ‘dst`
51 52 53 54 |
# File 'lib/osctl/exportfs/operations/server/create.rb', line 51 def symlink!(src, dst) FileUtils.rm_f(dst) File.symlink(src, dst) end |