vagrant-zones 0.1.99 → 0.1.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2597df7f5e76aadf6d3415e4dafe33af5029f0e2c8975e23dbe599d64d0c0755
4
- data.tar.gz: 362b02ad488fb43f98d0ca954a3d934fbb247ba684d49ab8aec23f97b09eb60f
3
+ metadata.gz: b58a4f65279cdf4fd1ef75666dfad9977f8003c77d6b228672a126d4a436f76a
4
+ data.tar.gz: b48932d77bd5cbe24e35678f5ed4a13a0be2ac04cfd0fba11f4a6d72048584c8
5
5
  SHA512:
6
- metadata.gz: 1c570fc6fc3aa56962c3b6da0ce3d4a95dd78cb5d41dbf27af426a331842e4d6084da3a7dc62a7b897911050fc2a88d4fcbfa6ea0305df408669b1f531b86117
7
- data.tar.gz: 0a5f59044ce1e5524fe044858de4757932a05f84341dca3c8eaafcff4e9ab12ce1187c871639d6eba79bfa68577f86ef362affe1c72c138eae42d55926534d68
6
+ metadata.gz: acaa60b70fc4dd5a51c7adafb54995629ded5e95884c86ce8cd2b43d1a0745756e7044a59496f5603b203e24bc9a2894b40fdfece7227cd0001deb167579d199
7
+ data.tar.gz: 60e9a8a9ca5b93603740742c56e5250f62b9e848515ef10e8889e17c39d0d46c4ba57ea032eb2d4284ede6c51b49814f00c7ed4c5859398f041e3b66604926c8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.101](https://github.com/STARTcloud/vagrant-zones/compare/v0.1.100...v0.1.101) (2025-05-09)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * windows zoneniczloginsetup ([c0eef21](https://github.com/STARTcloud/vagrant-zones/commit/c0eef2157555d668d0a55dddfcbdb2ea419a623d))
9
+ * windows zoneniczloginsetup ([68581e3](https://github.com/STARTcloud/vagrant-zones/commit/68581e37c4c9dd7353ccdfabdc7a5937f5c6a555))
10
+
11
+ ## [0.1.100](https://github.com/STARTcloud/vagrant-zones/compare/v0.1.99...v0.1.100) (2025-05-09)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * adding ansi-strings to fix issue with windows output ([bc67454](https://github.com/STARTcloud/vagrant-zones/commit/bc674546d79419496bb781c7aabf2004126c29a5))
17
+ * linting file ([0455ae0](https://github.com/STARTcloud/vagrant-zones/commit/0455ae0677dc593dea0b43f66ac64ba1930b274f))
18
+ * linting file ([9996594](https://github.com/STARTcloud/vagrant-zones/commit/999659499ca65153527ac9222a500b0fefaf0014))
19
+ * linting file ([0e6c345](https://github.com/STARTcloud/vagrant-zones/commit/0e6c34515147617d6f0d233d7400d65515eea2cd))
20
+
3
21
  ## [0.1.99](https://github.com/STARTcloud/vagrant-zones/compare/v0.1.98...v0.1.99) (2025-05-04)
4
22
 
5
23
 
data/Gemfile CHANGED
@@ -22,4 +22,5 @@ group :plugins do
22
22
  gem 'rubocop-rake', '~> 0.6', '>= 0.6.0'
23
23
  gem 'rubocop-rspec', '~> 2.4', '>= 2.4.0'
24
24
  gem 'ruby-progressbar', '~> 1.11', '>= 1.11.0'
25
+ gem 'strings-ansi', '~> 0.2.0'
25
26
  end
@@ -15,6 +15,7 @@ require 'resolv'
15
15
  require 'vagrant-zones/util/timer'
16
16
  require 'vagrant-zones/util/subprocess'
17
17
  require 'vagrant/util/retryable'
18
+ require 'strings/ansi'
18
19
 
19
20
  module VagrantPlugins
20
21
  module ProviderZone
@@ -1344,20 +1345,74 @@ module VagrantPlugins
1344
1345
  uii.info(I18n.t('vagrant_zones.configure_win_interface_using_vnic'))
1345
1346
  sleep(60)
1346
1347
 
1347
- ## Insert code to get the list of interfaces by mac address in order
1348
- ## to set the proper VNIC name if using multiple adapters
1349
- rename_adapter = %(netsh interface set interface name = "Ethernet" newname = "#{vnic_name}")
1350
- cmd = %(netsh interface ipv4 set address name="#{vnic_name}" static #{ip} #{opts[:netmask]} #{defrouter})
1351
- uii.info(I18n.t('vagrant_zones.win_applied_rename_adapter')) if zlogin(uii, rename_adapter)
1352
- uii.info(I18n.t('vagrant_zones.win_applied_static')) if zlogin(uii, cmd)
1353
- return unless opts[:dns].nil?
1354
-
1355
- ip_addresses = dnsservers(uii, opts).map { |hash| hash['nameserver'] }
1356
- dns1 = %(netsh int ipv4 set dns name="#{vnic_name}" static #{ip_addresses[0]} primary validate=no)
1357
- uii.info(I18n.t('vagrant_zones.win_applied_dns1')) if zlogin(uii, dns1)
1358
- ip_addresses[1..].each_with_index do |dns, index|
1359
- additional_nameservers = %(netsh int ipv4 add dns name="#{vnic_name}" #{dns} index="#{index + 2}" validate=no)
1360
- uii.info(I18n.t('vagrant_zones.win_applied_dns2')) if zlogin(uii, additional_nameservers)
1348
+ # Get the MAC address for this VNIC (if set to auto)
1349
+ mac = macaddress(uii, opts)
1350
+ if mac == 'auto'
1351
+ mac = ''
1352
+ cmd = "#{@pfexec} dladm show-vnic #{vnic_name} | tail -n +2 | awk '{ print $4 }'"
1353
+ vnicmac = execute(false, cmd.to_s)
1354
+ vnicmac.split(':').each { |x| mac += "#{format('%02x', x.to_i(16))}:" }
1355
+ mac = mac[0..-2]
1356
+ end
1357
+
1358
+ # Normalize the MAC address to uppercase with hyphens (Windows format)
1359
+ normalized_mac = mac.split(':').map { |segment| segment.rjust(2, '0') }.join('-').upcase
1360
+
1361
+ # rubocop:disable Style/RedundantStringEscape
1362
+ getmac_cmd = %(bash -c "getmac /v /FO csv /NH | grep \\\"#{normalized_mac}\\\" | awk -F, '{print $1}' | sed 's/\\\"/VZWI/g'")
1363
+ # rubocop:enable Style/RedundantStringEscape
1364
+ raw_output = zlogin(uii, getmac_cmd)
1365
+ adapter_name = nil
1366
+
1367
+ # First sanitize the raw output to remove all ANSI escape sequences
1368
+ raw_output_str = raw_output.is_a?(Array) ? raw_output.join : raw_output.to_s
1369
+ sanitized_output = Strings::ANSI.sanitize(raw_output_str)
1370
+
1371
+ # Find VZWI markers in the sanitized output
1372
+ sanitized_output.split(/[\r\n]+/).each do |line|
1373
+ next unless line.include?('VZWI')
1374
+
1375
+ # Find all positions of "VZWI" in the string
1376
+ positions = []
1377
+ pos = -1
1378
+ while (pos = line.index('VZWI', pos + 1))
1379
+ positions << pos
1380
+ end
1381
+
1382
+ # If we have at least 2 occurrences, extract between the last pair
1383
+ if positions.length >= 2
1384
+ # Get the last two VZWI positions
1385
+ last_pair_start = positions[-2]
1386
+ last_pair_end = positions[-1]
1387
+
1388
+ # Extract between these positions (adding 4 to skip "VZWI")
1389
+ adapter_name = line[(last_pair_start + 4)...last_pair_end]
1390
+ end
1391
+ break
1392
+ end
1393
+
1394
+ # Only proceed if we got a valid adapter name
1395
+ if adapter_name && !adapter_name.empty?
1396
+ # Rename the adapter to the VNIC name
1397
+ rename_adapter = %(netsh interface set interface name="#{adapter_name}" newname="#{vnic_name}")
1398
+ uii.info(I18n.t('vagrant_zones.win_applied_rename_adapter')) if zlogin(uii, rename_adapter)
1399
+
1400
+ # Configure the interface with IP, mask, and gateway
1401
+ cmd = %(netsh interface ipv4 set address name="#{vnic_name}" static #{ip} #{opts[:netmask]} #{defrouter})
1402
+ uii.info(I18n.t('vagrant_zones.win_applied_static')) if zlogin(uii, cmd)
1403
+
1404
+ # Configure DNS if provided
1405
+ unless opts[:dns].nil?
1406
+ ip_addresses = dnsservers(uii, opts).map { |hash| hash['nameserver'] }
1407
+ dns1 = %(netsh int ipv4 set dns name="#{vnic_name}" static #{ip_addresses[0]} primary validate=no)
1408
+ uii.info(I18n.t('vagrant_zones.win_applied_dns1')) if zlogin(uii, dns1)
1409
+ ip_addresses[1..].each_with_index do |dns, index|
1410
+ additional_nameservers = %(netsh int ipv4 add dns name="#{vnic_name}" #{dns} index="#{index + 2}" validate=no)
1411
+ uii.info(I18n.t('vagrant_zones.win_applied_dns2')) if zlogin(uii, additional_nameservers)
1412
+ end
1413
+ end
1414
+ else
1415
+ uii.info('Could not extract adapter name from output')
1361
1416
  end
1362
1417
  end
1363
1418
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module VagrantPlugins
4
4
  module ProviderZone
5
- VERSION = '0.1.99'
5
+ VERSION = '0.1.101'
6
6
  NAME = 'vagrant-zones'
7
7
  end
8
8
  end
@@ -34,4 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency 'log4r', '~> 1.1'
35
35
  spec.add_dependency 'netaddr', '~> 2.0', '>= 2.0.4'
36
36
  spec.add_dependency 'ruby_expect', '~> 1.7', '>= 1.7.5'
37
+ spec.add_dependency 'strings-ansi', '~> 0.2.0'
37
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-zones
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.99
4
+ version: 0.1.101
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Gilbert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-04 00:00:00.000000000 Z
11
+ date: 2025-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -92,6 +92,20 @@ dependencies:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: 1.7.5
95
+ - !ruby/object:Gem::Dependency
96
+ name: strings-ansi
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: 0.2.0
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: 0.2.0
95
109
  description: Vagrant provider plugin to support zones
96
110
  email:
97
111
  - support@prominic.net