Refactor unit tests for consistency

Signed-off-by: John Else <john.else@citrix.com>
CA-100561: Fix bash completion with grep color

Signed-off-by: Harrie Pieters <harrie.pieters@citrix.com>
CA-46110 Tab completion on xe-switch-network-backend
Revert "XOP-261: Fix xapissl to initially start stunnel."

This reverts commit 0e1953118e86b813e4b9548f5c2328f45ca82619.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Revert "XOP-261: Restart stunnel only if conf file changed."

This reverts commit ef89d6f3d86e4d5598a74a89d33ae38d4e0f2bf7.

The original patch is not the right thing to do: the expectation
is that the restart function always restarts the service.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Revert "XOP-261: Make the himn_address persistent across reboot."

This reverts commit 59e987594ffebb66758293e48e7d7c8da779f306.

The original patch was not necessary.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Remove some unused stuff in Xapi_mgmt_iface

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Only restart stunnel when actually changing which IP xapi is listening on

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Merge pull request #1070 from robhoes/himn

XOP-261: HIMN-related fixes
Merge pull request #1054 from johnelse/unit-test-refactor

Refactor unit tests for consistency
CA-92553: Thoroughly clear PCI attachments for stopped VMs

This should not be necessary if many-to-many relations in the DB
work properly. People have reported issues that may indicate that this is
not the case, but we have not yet found the root cause. Therefore, this
code is added "just to be sure".

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
CA-96950: Fix HIMN bridge name if needed

Previously, the bridge name used for the Host Internal Management Network
(HIMN) was usually xapi0, i.e. a normal name in the xapi* range. Now, the HIMN
has a special bridge name ("xenapi").

This commit ensures that the new name is used on existing HIMNs.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
CA-96541/SCTX-1188: Fix race condition when creating metrics for VLAN PIFs

This fixes a race condition between the thread that copies bonds and VLANs from
the master when a new slave joins the pool, and the thread that creates/updates
the PIF_metrics (the "monitor thread"). Or in fact a race between anything that
creates a bond and very soon after that a VLAN on top of it.

Since XCP1.6/XS6.1, VLANs no longer have their own PIF_metrics. Rather, they point
to the PIF_metrics of the underlying PIF, which can be either a physical PIF
(e.g. for eth0), or a bond PIF. Therefore, the carrier of a VLAN PIF is the same
as the carrier of the underlying PIF.

When a physical PIF or bond PIF is created, it does not immediately have
PIF_metrics (PIF.metrics = "OpaqueRef:NULL"). The PIF_metrics object is created
and assigned to the PIF by the monitor thread a short while after that. If you
create a VLAN before the PIF_metrics have been created, the PIF.metrics field from
the underlying PIF will still be copied, which is "OpaqueRef:NULL". This will never
get updated, because the monitor thread ignores VLANs.

The fix is simply to immediately create an (empty) metrics object when creating a
bond.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Merge pull request #1083 from robhoes/ca96541

CA-96541/SCTX-1188: Fix race condition when creating metrics for VLAN PIFs
Merge pull request #1081 from robhoes/ca96950

CA-96950: Fix HIMN bridge name if needed
Merge pull request #1073 from robhoes/gpu

CA-92553: Thoroughly clear PCI attachments for stopped VMs
Merge pull request #1066 from HPieters/CA-100561

CA-100561: Fix bash completion with grep color
Merge pull request #1069 from HPieters/CA-46110

CA-46110 Tab completion on xe-switch-network-backend