Class: SmartMachine::Machines::Network

Inherits:
Base
  • Object
show all
Defined in:
lib/smart_machine/machines/network.rb

Instance Method Summary collapse

Methods inherited from Base

#machine_has_engine_installed?, #platform_on_machine?, #user_bash

Methods included from Logger

configure_logger_for, included, #logger, logger_for

Constructor Details

#initialize(name:) ⇒ Network

Returns a new instance of Network.



4
5
6
7
8
9
10
11
12
# File 'lib/smart_machine/machines/network.rb', line 4

def initialize(name:)
  config = SmartMachine.config.network.dig(name.to_sym)
  raise "network config for #{name} not found." unless config

  @driver = config.dig(:driver)

  @name = name.to_s
  @home_dir = File.expand_path('~')
end

Instance Method Details

#downerObject



20
21
22
23
24
# File 'lib/smart_machine/machines/network.rb', line 20

def downer
  raise "Error: Could not remove network: #{@name}" unless system("docker network rm '#{@name}'", out: File::NULL)

  puts "Removed network: #{@name}"
end

#uperObject



14
15
16
17
18
# File 'lib/smart_machine/machines/network.rb', line 14

def uper
  raise "Error: Could not create network: #{@name}" unless system(command.compact.join(' '), out: File::NULL)

  puts "Created network: #{@name}"
end