vagrant-zones 0.1.99 → 0.1.100

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: 4f3b4be02798563d9d0f4fce9a66a07ac6cd1ea7ef09edfdeb4f9fe232a67341
4
+ data.tar.gz: 9ed384b15f7ee5d4f81552116580fb94c72aa9dcff84f644d8d74e9fa4db7d66
5
5
  SHA512:
6
- metadata.gz: 1c570fc6fc3aa56962c3b6da0ce3d4a95dd78cb5d41dbf27af426a331842e4d6084da3a7dc62a7b897911050fc2a88d4fcbfa6ea0305df408669b1f531b86117
7
- data.tar.gz: 0a5f59044ce1e5524fe044858de4757932a05f84341dca3c8eaafcff4e9ab12ce1187c871639d6eba79bfa68577f86ef362affe1c72c138eae42d55926534d68
6
+ metadata.gz: 4bf472087023060df2fe90c19a12410cf7e73b805dc78e3f1de4addf173466b50306257dfacabfb436d016b359b65f39a37a490fd7eaf77a0a3d26ed18e38643
7
+ data.tar.gz: faea40fce30d5dfc5be5915ec4c68c11d8df94afcc846707fbcad16818e0396b1209e4dc9fbb473ac147be574b4faded2fb5a63f90e23f1325c3177e69ab192a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.100](https://github.com/STARTcloud/vagrant-zones/compare/v0.1.99...v0.1.100) (2025-05-09)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * adding ansi-strings to fix issue with windows output ([bc67454](https://github.com/STARTcloud/vagrant-zones/commit/bc674546d79419496bb781c7aabf2004126c29a5))
9
+ * linting file ([0455ae0](https://github.com/STARTcloud/vagrant-zones/commit/0455ae0677dc593dea0b43f66ac64ba1930b274f))
10
+ * linting file ([9996594](https://github.com/STARTcloud/vagrant-zones/commit/999659499ca65153527ac9222a500b0fefaf0014))
11
+ * linting file ([0e6c345](https://github.com/STARTcloud/vagrant-zones/commit/0e6c34515147617d6f0d233d7400d65515eea2cd))
12
+
3
13
  ## [0.1.99](https://github.com/STARTcloud/vagrant-zones/compare/v0.1.98...v0.1.99) (2025-05-04)
4
14
 
5
15
 
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,88 @@ 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
+ # Debug output
1362
+ uii.info("Looking for adapter with MAC: #{normalized_mac}")
1363
+
1364
+ # Use the bash command with sed to wrap adapter name with VZWI markers
1365
+ ## DO NOT EVER ADJUST THIS COMMAND, WE MUST USE THIS EXACT COMMAND TO GET THE DATA FROM THE MACHINE
1366
+ ## DO NOT ADJUST THE COMMAND, IT IS IMPORTANT THAT WE DO NOT EVER ADJUST THIS COMMAND
1367
+ ## DO NOT ADJUST THE COMMAND
1368
+ ## DO NOT ADJUST THE COMMAND!!!!!!!!!! SERIOUSLY
1369
+ getmac_cmd = %(bash -c "getmac /v /FO csv /NH | grep "#{normalized_mac}" | awk -F, '{print $1}' | sed 's/"/VZWI/g'")
1370
+ raw_output = zlogin(uii, getmac_cmd)
1371
+
1372
+ uii.info("Raw adapter result: #{raw_output.inspect}")
1373
+
1374
+ if raw_output.is_a?(String)
1375
+ hex_display = raw_output.bytes.map { |b| format('\\x%02X', b) }.join
1376
+ uii.info("Hex representation: #{hex_display}")
1377
+ elsif raw_output.is_a?(Array)
1378
+ # Handle array case
1379
+ hex_display = raw_output.join.bytes.map { |b| format('\\x%02X', b) }.join
1380
+ uii.info("Hex representation (array joined): #{hex_display}")
1381
+ end
1382
+
1383
+ # Use the strings-ansi gem to sanitize the raw output
1384
+ adapter_name = nil
1385
+
1386
+ # First sanitize the raw output to remove all ANSI escape sequences
1387
+ raw_output_str = raw_output.is_a?(Array) ? raw_output.join : raw_output.to_s
1388
+ sanitized_output = Strings::ANSI.sanitize(raw_output_str)
1389
+
1390
+ # Debug the sanitized output
1391
+ uii.info("Sanitized output: #{sanitized_output.inspect}")
1392
+
1393
+ # Find VZWI markers in the sanitized output
1394
+ sanitized_output.split(/[\r\n]+/).each do |line|
1395
+ next unless line.include?('VZWI')
1396
+
1397
+ uii.info("Found line with VZWI markers (sanitized): #{line}")
1398
+
1399
+ # Extract the adapter name between VZWI markers using direct match
1400
+ if line =~ /VZWI(.+?)VZWI/
1401
+ adapter_name = ::Regexp.last_match(1)
1402
+ uii.info("Extracted adapter name from sanitized output: '#{adapter_name}'")
1403
+ end
1404
+ break
1405
+ end
1406
+
1407
+ # Only proceed if we got a valid adapter name
1408
+ if adapter_name && !adapter_name.empty?
1409
+ # Rename the adapter to the VNIC name
1410
+ uii.info("Using extracted adapter name '#{adapter_name}' for rename")
1411
+ rename_adapter = %(netsh interface set interface name="#{adapter_name}" newname="#{vnic_name}")
1412
+ uii.info(I18n.t('vagrant_zones.win_applied_rename_adapter')) if zlogin(uii, rename_adapter)
1413
+
1414
+ # Configure the interface with IP, mask, and gateway
1415
+ cmd = %(netsh interface ipv4 set address name="#{vnic_name}" static #{ip} #{opts[:netmask]} #{defrouter})
1416
+ uii.info(I18n.t('vagrant_zones.win_applied_static')) if zlogin(uii, cmd)
1417
+
1418
+ # Configure DNS if provided
1419
+ unless opts[:dns].nil?
1420
+ ip_addresses = dnsservers(uii, opts).map { |hash| hash['nameserver'] }
1421
+ dns1 = %(netsh int ipv4 set dns name="#{vnic_name}" static #{ip_addresses[0]} primary validate=no)
1422
+ uii.info(I18n.t('vagrant_zones.win_applied_dns1')) if zlogin(uii, dns1)
1423
+ ip_addresses[1..].each_with_index do |dns, index|
1424
+ additional_nameservers = %(netsh int ipv4 add dns name="#{vnic_name}" #{dns} index="#{index + 2}" validate=no)
1425
+ uii.info(I18n.t('vagrant_zones.win_applied_dns2')) if zlogin(uii, additional_nameservers)
1426
+ end
1427
+ end
1428
+ else
1429
+ uii.info('Could not extract adapter name from output')
1361
1430
  end
1362
1431
  end
1363
1432
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module VagrantPlugins
4
4
  module ProviderZone
5
- VERSION = '0.1.99'
5
+ VERSION = '0.1.100'
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.100
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