nub 0.0.136 → 0.0.138
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nub/net.rb +9 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89f02089be4f4ce91020479f5812fa4089143e32e73eced4c65ce5f2f1cf0b54
|
4
|
+
data.tar.gz: 245d02777cfe330471fa7b50d801f1c0044ed8a5df9dabf6eb1bdf8db82bde7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e43f5866c1d15d10020403671a88d02ec0d46ba99ff20d91ad1f910e6583bda24304550f6b1b2c5d3157b8fe0fae4df10a4d34a7f3667f0516699edd7a98d4a
|
7
|
+
data.tar.gz: 628b315e03a6a25752903d4638501889f957e14095a69825722cf97b1bfc3b9d233ad67c31d2dcb2e89885efa4d7709f1b580d05bdc99ebd524ced3935deaeb3
|
data/lib/nub/net.rb
CHANGED
@@ -146,7 +146,7 @@ module Net
|
|
146
146
|
# Network object
|
147
147
|
# @param subnet [String] of the network e.g. 192.168.100.0
|
148
148
|
# @param cidr [String] of the network
|
149
|
-
# @param nic [String] to use for NAT
|
149
|
+
# @param nic [String] to use for NAT, true pics primary
|
150
150
|
# @param nameservers [Array[String]] to optionally use for new network else uses hosts
|
151
151
|
Network = Struct.new(:subnet, :cidr, :nic, :nameservers)
|
152
152
|
|
@@ -161,6 +161,7 @@ module Net
|
|
161
161
|
# @returns [Array] of name server ips
|
162
162
|
def nameservers(*args)
|
163
163
|
filename = args.any? ? args.first.to_s : '/etc/resolv.conf'
|
164
|
+
filename = '/etc/resolv.conf' if !File.file?(filename)
|
164
165
|
|
165
166
|
result = []
|
166
167
|
if File.file?(filename)
|
@@ -239,6 +240,7 @@ module Net
|
|
239
240
|
|
240
241
|
# Pull from existing namespace first
|
241
242
|
if self.namespaces.include?(namespace)
|
243
|
+
network.nameservers = self.nameservers("/etc/netns/#{namespace}/resolv.conf")
|
242
244
|
host_veth, guest_veth = self.namespace_veths(namespace)
|
243
245
|
|
244
246
|
# Handle args as either as positional or named
|
@@ -247,7 +249,7 @@ module Net
|
|
247
249
|
network = args.first[:network] if args.first.key?(:network)
|
248
250
|
host_veth = args.first[:host_veth] if args.first.key?(:host_veth)
|
249
251
|
guest_veth = args.first[:guest_veth] if args.first.key?(:guest_veth)
|
250
|
-
elsif args.
|
252
|
+
elsif args.any?
|
251
253
|
host_veth = args.shift
|
252
254
|
guest_veth = args.shift if args.any?
|
253
255
|
network = args.shift if args.any?
|
@@ -257,7 +259,9 @@ module Net
|
|
257
259
|
# Populate missing information
|
258
260
|
host_veth.name = "#{namespace}_host" if !host_veth.name
|
259
261
|
guest_veth.name = "#{namespace}_guest" if !guest_veth.name
|
260
|
-
network.
|
262
|
+
network.subnet = @@namespace_subnet if !network.subnet
|
263
|
+
network.cidr = @@namespace_cidr if !network.cidr
|
264
|
+
network.nic = self.primary_nic if network.nic.nil? || network.nic == true
|
261
265
|
network.nameservers = self.nameservers if !network.nameservers
|
262
266
|
if !host_veth.ip or !guest_veth.ip
|
263
267
|
host_ip, guest_ip = self.namespace_next_veth_ips
|
@@ -278,7 +282,7 @@ module Net
|
|
278
282
|
# If the nic param is nil NAT is not enabled. If nic is true then the primary nic is dynamically
|
279
283
|
# looked up else use user given If nameservers are not given the host nameservers will be used
|
280
284
|
def create_namespace(namespace, *args)
|
281
|
-
host_veth, guest_veth, network = self.namespace_details(namespace, args)
|
285
|
+
host_veth, guest_veth, network = self.namespace_details(namespace, *args)
|
282
286
|
|
283
287
|
# Ensure namespace i.e. /var/run/netns/<namespace> exists
|
284
288
|
if !self.namespaces.include?(namespace)
|
@@ -360,7 +364,7 @@ module Net
|
|
360
364
|
# If the nic param is nil NAT is not enabled. If nic is true then the primary nic is dynamically
|
361
365
|
# looked up else use user given If nameservers are not given the host nameservers will be used
|
362
366
|
def delete_namespace(namespace, *args)
|
363
|
-
host_veth, guest_veth, network = self.namespace_details(namespace, args)
|
367
|
+
host_veth, guest_veth, network = self.namespace_details(namespace, *args)
|
364
368
|
|
365
369
|
# Remove nameserver config for network namespace
|
366
370
|
namespace_conf = File.join("/etc/netns", namespace)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.138
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Crummett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|