Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrofit network plugin to work on Windows Nano Server #872

Merged
merged 1 commit into from
Sep 6, 2016
Merged

Conversation

mwrock
Copy link
Member

@mwrock mwrock commented Sep 2, 2016

Windows Nano exposes the Win32_* WMI classes but they are empty. Instead we should populate network metadata from the newer MSFT_* classes. This PR will continue to use the deprecated classes if they have data and use the new ones if they are empty.

Note that the data in these new schemas is slightly different but I have tried to make the data exposed in the network interfaces as close to identical to that exposed on other versions of windows. Attempts to get an IP address will succeed but some of the subnet metadata is missing since I could not find that in the new classes.

I think this is a good first stab and we should fill in missing data later if needed. The primary objective here is to allow chef client runs to work and not raise an error when trying to use the node's IP.

@mwrock mwrock changed the title Retrofit network plugin to work on nano Retrofit network plugin to work on Windows Nano Server Sep 2, 2016
@tas50
Copy link
Contributor

tas50 commented Sep 2, 2016

@mwrock What windows release first shipped with the new classes?

@mwrock
Copy link
Member Author

mwrock commented Sep 2, 2016

I think 8.1/2k12r2

@mwrock
Copy link
Member Author

mwrock commented Sep 2, 2016

Here is a diff of output on a NON nano box looking at before this change vs after:

diff --git a/now.txt b/new.txt
index a135db7..861748c 100644
--- a/now.txt
+++ b/new.txt
@@ -2,6 +2,10 @@
   "interfaces": {
     "0xe": {
       "configuration": {
+        "ip_address": [
+          "192.168.1.141",
+          "fe80::193f:82c3:5afa:f282"
+        ],
         "arp_always_source_route": null,
         "arp_use_ether_snap": null,
         "caption": "[00000001] Broadcom 802.11ac Network Adapter",
@@ -35,10 +39,6 @@
         "igmp_level": null,
         "index": 1,
         "interface_index": 14,
-        "ip_address": [
-          "192.168.1.141",
-          "fe80::193f:82c3:5afa:f282"
-        ],
         "ip_connection_metric": 20,
         "ip_enabled": true,
         "ip_filter_security_enabled": false,
@@ -168,6 +168,10 @@
     },
     "0x4": {
       "configuration": {
+        "ip_address": [
+          "192.168.137.1",
+          "fe80::88ef:9283:5216:bd"
+        ],
         "arp_always_source_route": null,
         "arp_use_ether_snap": null,
         "caption": "[00000013] Hyper-V Virtual Ethernet Adapter",
@@ -195,10 +199,6 @@
         "igmp_level": null,
         "index": 13,
         "interface_index": 4,
-        "ip_address": [
-          "192.168.137.1",
-          "fe80::88ef:9283:5216:bd"
-        ],
         "ip_connection_metric": 5,
         "ip_enabled": true,
         "ip_filter_security_enabled": false,
@@ -333,6 +333,10 @@
     },
     "0x10": {
       "configuration": {
+        "ip_address": [
+          "172.27.236.133",
+          "fe80::fcb8:c7b:6626:5624"
+        ],
         "arp_always_source_route": null,
         "arp_use_ether_snap": null,
         "caption": "[00000015] TAP Adapter OAS NDIS 6.0",
@@ -360,10 +364,6 @@
         "igmp_level": null,
         "index": 15,
         "interface_index": 16,
-        "ip_address": [
-          "172.27.236.133",
-          "fe80::fcb8:c7b:6626:5624"
-        ],
         "ip_connection_metric": 20,
         "ip_enabled": true,
         "ip_filter_security_enabled": false,

The only difference is the ordering of the ip_address properties in the property set because I had to change the way they were manipulated that worked with both sets of claees. The values are identical and the ordering does not matter.

@mwrock
Copy link
Member Author

mwrock commented Sep 2, 2016

Here is the output on nano:

[192.168.137.73]: PS C:\Users\vagrant\Documents> ohai network
{
  "interfaces": {
    "0x4": {
      "configuration": {
        "ip_address": [
          "fe80::d957:4b8b:b10e:44bd%4",
          "192.168.137.73"
        ],
        "address": null,
        "address_family": 23,
        "address_origin": 0,
        "address_state": 4,
        "address_type": null,
        "available_requested_states": null,
        "caption": null,
        "communication_status": null,
        "creation_class_name": "",
        "description": null,
        "detailed_status": null,
        "element_name": null,
        "enabled_default": 2,
        "enabled_state": null,
        "health_state": null,
        "install_date": null,
        "instance_id": null,
        "interface_alias": "Ethernet 2",
        "interface_index": 4,
        "i_pv4_address": "192.168.137.73",
        "i_pv6_address": "fe80::d957:4b8b:b10e:44bd%4",
        "ip_version_support": null,
        "name": "poB:DDnC?AD>lBlDl;:oD>>ln/>55>55;55;",
        "name_format": null,
        "operating_status": null,
        "operational_status": null,
        "other_enabled_state": null,
        "other_type_description": null,
        "preferred_lifetime": "99999999235959.000000:000",
        "prefix_length": 64,
        "prefix_origin": 2,
        "primary_status": null,
        "protocol_if_type": 4096,
        "protocol_type": null,
        "requested_state": 12,
        "skip_as_source": false,
        "status": null,
        "status_descriptions": null,
        "store": 1,
        "subnet_mask": null,
        "suffix_origin": 4,
        "system_creation_class_name": "",
        "system_name": "",
        "time_of_last_state_change": null,
        "transitioning_to_state": 12,
        "type": 1,
        "valid_lifetime": "99999999235959.000000:000"
      },
      "instance": {
        "active_maximum_transmission_unit": "1500",
        "additional_availability": null,
        "admin_locked": false,
        "auto_sense": null,
        "availability": null,
        "available_requested_states": null,
        "caption": null,
        "communication_status": null,
        "component_id": "VMBUS\\{f8615163-df3e-46c5-913f-f2d2f965ed0e}",
        "connector_present": true,
        "creation_class_name": "MSFT_NetAdapter",
        "description": null,
        "detailed_status": null,
        "device_id": "{DE5E138A-4E9A-4A4A-A45F-8407FB661EE4}",
        "device_name": "\\Device\\{DE5E138A-4E9A-4A4A-A45F-8407FB661EE4}",
        "device_wake_up_enable": false,
        "driver_date": "2006-06-21",
        "driver_date_data": "127953216000000000",
        "driver_description": "Microsoft Hyper-V Network Adapter",
        "driver_major_ndis_version": 6,
        "driver_minor_ndis_version": 60,
        "driver_name": "\\SystemRoot\\System32\\drivers\\netvsc.sys",
        "driver_provider": "Microsoft",
        "driver_version_string": "10.0.14393.0",
        "element_name": null,
        "enabled_default": 2,
        "enabled_state": 5,
        "end_point_interface": false,
        "error_cleared": null,
        "error_description": null,
        "full_duplex": null,
        "hardware_interface": true,
        "health_state": null,
        "hidden": false,
        "higher_layer_interface_indices": [
          5
        ],
        "identifying_descriptions": null,
        "im_filter": false,
        "install_date": null,
        "instance_id": "{DE5E138A-4E9A-4A4A-A45F-8407FB661EE4}",
        "interface_admin_status": 1,
        "interface_description": "Microsoft Hyper-V Network Adapter #2",
        "interface_guid": "{DE5E138A-4E9A-4A4A-A45F-8407FB661EE4}",
        "interface_index": 4,
        "interface_name": "ethernet_32770",
        "interface_operational_status": 1,
        "interface_type": 6,
        "i_scsi_interface": false,
        "last_error_code": null,
        "link_technology": null,
        "lower_layer_interface_indices": null,
        "major_driver_version": 6,
        "max_quiesce_time": null,
        "max_speed": null,
        "media_connect_state": 1,
        "media_duplex_state": 0,
        "minor_driver_version": 1,
        "mtu_size": 1500,
        "name": "Ethernet 2",
        "ndis_medium": 0,
        "ndis_physical_medium": 0,
        "net_luid": "1689399649632256",
        "net_luid_index": 32770,
        "network_addresses": [
          "00155D01B4C4"
        ],
        "not_user_removable": false,
        "operating_status": null,
        "operational_status": null,
        "operational_status_down_default_port_not_authenticated": false,
        "operational_status_down_interface_paused": false,
        "operational_status_down_low_power_state": false,
        "operational_status_down_media_disconnected": false,
        "other_enabled_state": null,
        "other_identifying_info": null,
        "other_link_technology": null,
        "other_network_port_type": null,
        "other_port_type": null,
        "permanent_address": "00155D01B4C4",
        "pn_p_device_id": "VMBUS\\{F8615163-DF3E-46C5-913F-F2D2F965ED0E}\\{0F94738D-F785-461D-882F-DA54BDF7C618}",
        "port_number": 0,
        "port_type": null,
        "power_management_capabilities": null,
        "power_management_supported": null,
        "power_on_hours": null,
        "primary_status": null,
        "promiscuous_mode": false,
        "receive_link_speed": "10000000000",
        "requested_speed": null,
        "requested_state": 12,
        "speed": "10000000000",
        "state": 2,
        "status": null,
        "status_descriptions": null,
        "status_info": null,
        "supported_maximum_transmission_unit": null,
        "system_creation_class_name": "CIM_NetworkPort",
        "system_name": "Nano",
        "time_of_last_state_change": null,
        "total_power_on_hours": null,
        "transitioning_to_state": 12,
        "transmit_link_speed": "10000000000",
        "usage_restriction": null,
        "virtual": false,
        "vlan_id": 0,
        "wdm_interface": false
      },
      "counters": {

      },
      "addresses": {
        "fe80::d957:4b8b:b10e:44bd%4": {
          "prefixlen": "128",
          "family": "inet6",
          "scope": "Link"
        },
        "192.168.137.73": {
          "prefixlen": "32",
          "family": "inet"
        },
        "00:15:5D:01:B4:C4": {
          "family": "lladdr"
        }
      },
      "arp": {
        "192.168.137.1": "00:15:5d:01:b4:bf",
        "224.0.0.22": "01:00:5e:00:00:16",
        "224.0.0.252": "01:00:5e:00:00:fc",
        "239.255.255.250": "01:00:5e:7f:ff:fa",
        "255.255.255.255": "ff:ff:ff:ff:ff:ff"
      }
    }
  }
}

@thommay
Copy link
Contributor

thommay commented Sep 5, 2016

👍

wmi = WmiLite::Wmi.new
data[:addresses] = wmi.instances_of("Win32_NetworkAdapterConfiguration")

# If we are running on windows nano or anothe roperating system from the future
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"another operating"

@tas50
Copy link
Contributor

tas50 commented Sep 6, 2016

👍

@tas50 tas50 merged commit 24c7ece into master Sep 6, 2016
@tas50 tas50 deleted the nano branch September 6, 2016 16:10
@thommay thommay added Type: Enhancement Adds new functionality. and removed Enhancement labels Jan 24, 2017
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Enhancement Adds new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants