Refactor DSDB syncronization in add_host and del_host

The check that the host has a primary IP address, which is derived
from its primary name, is already handed by DSDBRunner.  The check
that an Aurora host is should be done early.  Finally we only need
a snapshot if we are going to touch DSDB.

Change-Id: I11aa25a3e9cd3e56e3d1dbb1a847094a6041786d
Reviewed-by: Gabor Gombas <Gabor.Gombas@morganstanley.com>
Refactoring host creation into a dbwrapper

This commit moved the generic logic for creating a host object
into a dbwapper.  This will allow it to be reused by the network
device creation.

Change-Id: Ia11511df230a7f7e5e2a80611437801271e8a625
Reviewed-by: Gabor Gombas <Gabor.Gombas@morganstanley.com>
Refactor 'host' formatting

This change moves the raw formatter for a host object into a new
method in the hardware entity class.  The current host formatter just
delegates to the associated hardware entity, which may or may not
include a host.  This hardware entity formatter can now call this
common method to display the host information.

Change-Id: I38e6dbbb84d35ff6f8522e568d69ab0259eb90c4
Reviewed-by: Gabor Gombas <Gabor.Gombas@morganstanley.com>
Refactoring host deletion into a dbwrapper

This commit moves the host deletion logic into a dbwrapper; this
will later allow network devices to delete host objects.

Change-Id: I799e583485ca6d3f2d99af72d1462f2c8f70358f
Reviewed-by: Gabor Gombas <Gabor.Gombas@morganstanley.com>
Deprecate the use of switchdata

This commit renames the Network Device plenary back to switchdata.  All
pleanarly lookups are now done explicitly using PlenarySwitchData and
not Plenary.  This permits us to remove the association between a network
device and this plenary; allowing us to create a real network device
plenary associated with the hardware.

Change-Id: Iafdfbc2bba1e39e6939469dabf8b6d10dc0f6c6a
Reviewed-by: Gabor Gombas <Gabor.Gombas@morganstanley.com>
Fix model type bug in update network devices

When updating the model of a network device you should be able to
specify any valid model type for network devices, not just switches.

Change-Id: I1c3bfede6499c2d8313c39bf3869a4e784762ed2
Reviewed-by: Gabor Gombas <Gabor.Gombas@morganstanley.com>
Escape interface names

Interface and port names of network devices can contain characters that
are not valid in nlist keys (e.g. "Ten Gigabit Ethernet Port 10"). We
can't escape everything unconditionally though, because the templates do
not call unescape() yet, and e.g. VLAN interfaces like "eth0.123" would
get munged by escaping.

Change-Id: Iecf9c130a9b18c6ae4202cf18e74e259a3e71dd0
Reviewed-by: Gabor Gombas <Gabor.Gombas@morganstanley.com>
Add a pleanary for network devices

Network devices now have a skeleton plenary created for them;
it is not expected that it will be possible to complile network
devices using this pleanary.

All of the commands that can update a network device now use
a PlenaryCollection.  Where applicable the existing SwitchData
plenary has been included.

Change-Id: I9bcb16e50deffba192fd8937ae95bb890206c0b9
Reviewed-by: Gabor Gombas <Gabor.Gombas@morganstanley.com>
Root access improvements

Drop unneeded relations. Sort the user and netgroup lists to prevent the
plenaries getting re-written if the DB returns the entries in a
different order. Make the plenary tests stricter.

Change-Id: Ia0e9ad80bdb3de5be68e5625df2e15e0ba8b2e4e
Reviewed-by: Dave Reeve <Dave.Reeve@morganstanley.com>
Make --archetype optional for "compile --personality"

Most of the time the personality name alone is enough.

Change-Id: I4fef859f08dba1b854f61f20572111cdda454c81
Reviewed-by: Dave Reeve <Dave.Reeve@morganstanley.com>
Drop dead code

Change-Id: I98c05657ec88c5b2e31400b9fd9f85bc5ab29310
Reviewed-by: Dave Reeve <Dave.Reeve@morganstanley.com>
Fix enum type generation

Expressions like type(NicType.Nic) throwed an error, because special
attributes were not handled properly during class creation.

Change-Id: Ie9b7a8a0a20d7b9e356b5cb535484f5bf5b1eccb
Reviewed-by: Dave Reeve <Dave.Reeve@morganstanley.com>
Add helper for populating utsandbox

Use a helper function for copying data into the sandbox, instead of
writing every file one by one.

Change-Id: I2225958a734b02650fd92ecdb38dc1a0263df43b
Reviewed-by: Dave Reeve <Dave.Reeve@morganstanley.com>
Restructure add_hardware_data()

Let it take a Machine message as argument, not Host.

Change-Id: Ic05844e05892bf788f0512ad397cfea0da508872
Reviewed-by: Dave Reeve <Dave.Reeve@morganstanley.com>
Report disks/interfaces in consistent order

Make the protobuf formatter report disks and interfaces in a
deterministic order, as it makes testing easier.

Change-Id: I6915e2c2a6ec6b177037e05888f65d41b88e01f3
Reviewed-by: Dave Reeve <Dave.Reeve@morganstanley.com>
Restructure the hardware formatters

Make the machine, chassis and network device formatters inherit from the
generic hardware entity formatter.

Change-Id: Ifef9ffc3244b9f1ffbbcaefb09d9767f792ea26d
Reviewed-by: Dave Reeve <Dave.Reeve@morganstanley.com>
PEP8 cleanups

Change-Id: Iff360325e3c8a67ee580a47ce8457aaf5f1196b6
Reviewed-by: Dave Reeve <Dave.Reeve@morganstanley.com>
Adding host object to network devices

Change-Id: I90803eb5900428547de6f97373fdbcbf9bffc214
Reviewed-by: Gabor Gombas <Gabor.Gombas@morganstanley.com>
Add protobuf output to {show,search}_machine

Also extend the information provided for disks and interfaces.

Addresses-Issue: Jira/AQUILONAQD-320
Addresses-Issue: Jira/AQUILON-1661
Change-Id: Ibc863ae0eeea023af3dce55b127673b415a095f8
Reviewed-by: Dave Reeve <Dave.Reeve@morganstanley.com>
Add protobuf support to show_archetype

Change-Id: Ie288ac7b3d6fd588386278c1b86729c7aa12d23d
Reviewed-by: Dave Reeve <Dave.Reeve@morganstanley.com>