Skip to content

Commit

Permalink
Link Local Filtering (#19)
Browse files Browse the repository at this point in the history
* Link Local handling

* readme/docs
  • Loading branch information
h4ndzdatm0ld authored Aug 13, 2022
1 parent 0f9a152 commit 75f198b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

A plugin for [Nautobot](https://github.com/nautobot/nautobot) that leverages the SSoT plugin to create Virtual Machines, VMInterfaces, IPAddresses, Clusters, and Cluster Groups from VMWare vSphere.

![JobOverview](docs/images/job_overview.png)
![VirtualMachines](docs/images/virtualmachines.png)
![JobOverview](docs/images/job_overview.png) ![VirtualMachines](docs/images/virtualmachines.png)

## The future of Virtual Machine In Nautobot

There is discussion in place to that will bring big changes to VirtualMachine and VMInterface targeted for release 2.0.
See the [issue](https://github.com/nautobot/nautobot/issues/1178)
There is discussion in place to that will bring big changes to VirtualMachine and VMInterface targeted for release 2.0. See the [issue](https://github.com/nautobot/nautobot/issues/1178)

When that time comes, this application will need to be updated to handle the new core model structure

Expand Down Expand Up @@ -55,6 +53,7 @@ The plugin behavior can be controlled with additional configuration settings
- `PRIMARY_IP_SORT_BY` Defaults to "Lowest"
- `DEFAULT_USE_CLUSTERS` Defaults to `True`
- `DEFAULT_CLUSTER_NAME` Defaults to "vSphere Default Cluster"
- `DEFAULT_IGNORE_LINK_LOCAL` Defaults to `True`
```

To get a detailed description on each configuration setting, head over to the [Overview](https://h4ndzdatm0ld.github.io/nautobot-ssot-vsphere/overview.html) documentation.
13 changes: 13 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.3] - 2022-08-12

### Added

- Added default (configurable) setting to always drop link-local addresses from IPv6 assigned interfaces from vSphere
- Added logging to interface addresses dropped

### Changed

- Bumped Django to 3.2.15 due to security fix

### Removed

## [0.1.2] - 2022-07-20

### Added
Expand Down
6 changes: 5 additions & 1 deletion docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@

`DEFAULT_USE_CLUSTERS` and `DEFAULT_CLUSTER_NAME`

- This experimental feature allows users of vSphere which contain no `Clusters` in their environment. The `DEFAULT_USE_CLUSTERS` needs to be set to `False` and a name of your choosing would be assigned to `DEFAULT_CLUSTER_NAME`. A `Cluster` is a requirement of a `Virtual Machine` in Nautobot.
- This experimental feature allows users of vSphere which contain no `Clusters` in their environment. The `DEFAULT_USE_CLUSTERS` needs to be set to `False` and a name of your choosing would be assigned to `DEFAULT_CLUSTER_NAME`. A `Cluster` is a requirement of a `Virtual Machine` in Nautobot.

`DEFAULT_IGNORE_LINK_LOCAL`

- Defaults to `True` and drops any link-local address found on a vSphere vm that has an IPv6 address assigned.
9 changes: 7 additions & 2 deletions nautobot_ssot_vsphere/diffsync/adapters/adapter_vsphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ def load_ip_addresses(self, vsphere_vm_interfaces, mac_address, diffsync_vminter
self.job.log_debug(message=f"Loading IP Addresses {interface}")
# Convert to IP Object if IPV4 or IPV6 and add to list by version
addr = create_ipaddr(ip_address["ip_address"])
# Check if IPv6 is a Link Local. If it is, skip it.
if defaults.DEFAULT_IGNORE_LINK_LOCAL:
if addr.version == 6 and addr.is_link_local:
self.job.log_debug(message=f"Skipping Link Local Address: {ip_address}")
continue
_ = ipv4_addresses.append(addr) if addr.version == 4 else ipv6_addresses.append(addr)
# Update DiffsyncIpAddress
diffsync_ipaddress, _ = self.get_or_instantiate(
Expand Down Expand Up @@ -153,8 +158,8 @@ def load_vm_interfaces(self, vsphere_virtual_machine, vm_id, diffsync_virtualmac
nic_mac,
diffsync_vminterface,
)
[addrs4.append(str(addr)) for addr in ipv4_addresses] # pylint: disable=expression-not-assigned
[addrs6.append(str(addr)) for addr in ipv6_addresses] # pylint: disable=expression-not-assigned
_ = [addrs4.append(str(addr)) for addr in ipv4_addresses]
_ = [addrs6.append(str(addr)) for addr in ipv6_addresses]

# Sort through all IP's on
self.load_primary_ip(addrs4, addrs6, diffsync_virtualmachine)
Expand Down
1 change: 1 addition & 0 deletions nautobot_ssot_vsphere/diffsync/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
PRIMARY_IP_SORT_BY = CONFIG.get("PRIMARY_IP_SORT_BY", "Lowest")
DEFAULT_USE_CLUSTERS = CONFIG.get("DEFAULT_USE_CLUSTERS", True)
DEFAULT_CLUSTER_NAME = CONFIG.get("DEFAULT_CLUSTER_NAME", "vSphere Default Cluster")
DEFAULT_IGNORE_LINK_LOCAL = CONFIG.get("DEFAULT_IGNORE_LINK_LOCAL", True)
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 75f198b

Please sign in to comment.