34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/bolt/transport/lxd/connection.rb', line 34
def connect
out, err, status = execute_local_command(%W[list #{container_id} --format json])
unless status.exitstatus.zero?
raise "Error listing available containers: #{err}"
end
containers = JSON.parse(out)
if containers.empty?
raise "Could not find a container with name or ID matching '#{container_id}'"
end
@logger.trace("Opened session")
true
rescue StandardError => e
raise Bolt::Node::ConnectError.new(
"Failed to connect to #{container_id}: #{e.message}",
'CONNECT_ERROR'
)
end
|