CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Reviewed by: Sateesh Chodapuneedi, Devdeep Singh

Description:

This is the first in a series of commits for integrating the
Cloudstack Management Server with the Nexus 1000v Virtual
Supervisor Module.

These changes introduce the necessary API command interfaces
to work with a Cisco N1KV VSM. The backend logic is still to
be put in and will be incorporated in subsequent commits.
Please do not attempt to use these APIs until then. Also,
these are not yet filled in into commands.xml, so they are
not currently exposed.

Additional APIs would be added if required.

These changes will not break any current management server
functionality.

Given below is a description of the changes put in here:

	Added Cisco N1KV commands to core/api:
	    These are the added commands -

		AddCiscoNexusVSMCmd
		DeleteCiscoNexusVSMCmd
		ConfigureCiscoNexusVSMCmd
		ListCiscoNexusVSMCmd
		ListCiscoNexusVSMNetworksCmd

	Added a Network Element service file for Cisco N1KV.

	Declared the interface functions that we'll need for
	the N1KV VSM.

	Defined a DeviceVO file for the Cisco Nexus Element.

	Created a response file for Cisco Nexus VSM.

	Created new event types for external Switching Management devices.

	Put in logic to call interface methods in ListCiscoNexusVSMNetworksCmd
	and ListCiscoNexusVSMCmd

NOT VSM RELATED:
	Fixed minor typo in some of the event types for external load balancers.

       Added properties of a VSM in the VSM VO class.

       Replaced the "url" input parameter by "ipaddress"
       in the AddCiscoNexusVSMCmd API.

       Added a new file - CiscoNexusVSMElement.java to
       contain the implementation of the functions
       declared in the VSMElementService interface, and
       put in implementations of the functions for the
       Nexus VSM API commands. These functions are
       defined in the CiscoNexusVSMElement class.

       Added a class for Port Profiles (PortProfile.java).
       The fields in this class are still not correctly
       declared as of now. We'll make the required changes
       going forward.

	Added CiscoNexusVSMDeviceManagerImpl class.

	Added CiscoNexusVSMResource class.

	Created a new class to provide a package to
	connect to Cisco Nexus VSMs. This will be a
	set of Java wrapper functions that allow us
	to connect/disconnect and send commands and
	receive the results of those commands via
	XML-RPC. These functions are yet to be
	implemented, and will be checked in in future
	commits.

	Added two new classes, VSMCommand and
	VSMResponse, to encapsulate XML-RPCcommands
	and responses to and from a Ciscon Nexus VSM.

	Put in the following function stubs inside the
	CiscoNexusVSMService class:

		connectToVSM()
		disconnectFromVSM()
		executeVSMCommand()

	Added new field in the Type enum of the "Host"
	interface, for Cisco Nexus VSMs.

	Added two parameters to AddCiscoNexusVSMCommand
		vsmName
		zoneId

	Modified the CiscoNexusVSMDeviceVO constructor to
	take in an zoneId as a parameter when creating
	the VO object.

	Added new interface and class for the DeviceDao
	implementation for Cisco Nexus VSM devices:
		CiscoNexusVSMDeviceDao
		CiscoNexusVSMDeviceDaoImpl

	Removed the vsmvCenterDomainId property, since it's
	going to the same as vsmDomainId, which is the VSM's
	switch Domain Id.

	Have started putting in the following query functions
	in the CiscoNexusVSMDeviceDao interface:

	Put in DAO implementations of some of the above functions in the CiscoNexusVSMDeviceDaoImpl class.

	Added a vsmName parameter to the CiscoNexusVSMDeviceVO class.
Bug CS-9919: Support for Nexus Swiches (Cisco Vswitches)

	   At this point, the mgmt server comes up, loading the
	   Nexus related modules without dying.

Description:

	1) Added a new properties file for Cisco N1kv VSM commands:
		cisconexusvsm_commands.properties.in

	2) Added the CiscoNexusVSMElement to the components.xml file.

	3) Modified CiscoNexusVSMElement to implement NetworkElement.

		The NetworkElement interface functions are not
	  	relevant to the N1KV VSM, so we override them
	  	with noops.

	4) Added an addDao() of CiscoNexusVSMDeviceDaoImpl in populateDaos(),
	   else we'd run into a failure to look up the VSM's dao when the
	   mgmt server is starting up:

		com.cloud.utils.exception.CloudRuntimeException: Unable to find DAO com.cloud.network.dao.CiscoNexusVSMDeviceDao

	5) Also added the CiscoNexusVSMElementService in populateServices(),
	   and modified CiscoNexusVSMElement to implement Manager as well.

	6) populateServices() was running into an exception that indicated
	   that it was unable to find a commands.properties file for the
	   cisco n1kv vsm service. Fixed it by changing getProperties() in
	   CiscoNexusVSMElement to return the correct string
	   "cisconexusvsm_commands.properties", and putting in an @Override
	   for getProperties() in CiscoNexusVSMElement. Also fixed up all
	   the other functions in CiscoNexusVSMElement that needed to have
	   @Override. Also updated build/developers.xml with this file
	   location. And did other small cleanup.

	7) More clean up in CiscoNexusVSMDeviceManagerImpl.
Bug CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	This is work in progress. This set of changes will not
	compile. Checking in for team wide code sync up.

	Changes are underway to test if VMWareResource can be
	leveraged to talk to the VSM, instead of creating a
	new resource for the VSM, like we've been doing up
	until now.
Bug CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	1. Added a new VO class to represent a new table
	   "cluster_vsm_map". The class is ClusterVSMMapVO
	   in ClusterVSMMapVO.java. This table has only
	   two fields - clusterId, VSMId. The clusterId can
	   occur only once. But the same VSMId can be tied
	   to different clusterIds.

	2. Added the Dao interface + implementation of the
	   interface. This provides the functions required
	   to populate objects of type ClusterVSMMapVO with
	   records from the cluster_vsm_map table. The
	   interface is defined in ClusterVSMMapDao.java,
	   and the implementation is in ClusterVSMMapDaoImpl.java.

	3. Changed the table name that represents the VSM to
	   "virtual_supervisor_module" from the earlier overly
	   generic "external_virtual_switch_management_devices".

	4. Added search/remove functions to the Dao of the VSM.
	   This is the Dao for the Cisco Nexus VSM -

		CiscoNexusVSMDeviceDao:CiscoNexusVSMDeviceDaoImpl
		 --> This is the Dao Implementation that would let
		     us query/update records on the
		     "virtual_supervisor_module" table that contains
		     the records of all the VSMs that are added to
		     the Management Server.

NOTE::
======
These were some of the changes made as part of the previous commit (#7):

	1. Renamed CiscoNexusVSMResource.java to CiscoNexusVSM.java.

	2. Changed it to not implement a true resource, but to be
	   just a class providing functionality to talk to a VSM.

	3. Modified the AddCiscoNexusVSMCmd class to take in clusterId
	   instead of zoneId + your fix of the String to Long.
Bug CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	Fixing a wrong package path in CiscoNexusVSMResponse.

	More commits to follow.
CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	1. Missed replacing older table name for VSMs in a few
	   files (changed the name from
	   external_virtual_switch_management_devices to
	   virtual_supervisor_module). Fixed that in this commit.

	2. Missed adding the new Dao ClusterVSMMapDao in the Dao
	   loading in DefaultComponentLibrary. Fixed.

	3. Fixed wrong searchbuilder options passed to ipaddrSearch
	   in CiscoNexusVSMDeviceDaoImpl.
CS-9919:  Support for Nexus Swiches (Cisco Vswitches)

Description:

	Adding a netconf helper class for adding and
	deleting port profiles. These functions need
	to be further parameterized and error handling
	needs to be taken care of.
CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	Fixing failure to load ClusterVSMMapDao by
	putting in a constructor that takes no
	arguments, inClusterVSMMapVO.
CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	Update create-schema.sql to create tables for
	VSM and VSM-Cluster mapping.

	Fixed an incorrect exception path in
	CSExceptionErrorCode.
CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	Fixed type of argument taken by AddCiscoNexusVSMCmd
	from ZONE_ID to CLUSTER_ID.
CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	Updated the rpc request generation logic for
	creating and deleting port profiles.
CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	Removing unused classes and references to them.
CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	Added handling for error responses from vsm.
	Fixing an issue with port profile creation.
Bug CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

        1. Changed AddCiscoNexusVSMCmd to:
             a. Extend BaseCmd instead of BaseAsyncCmd.
             b. Take in more required parameters (viz
                vCenterDCName and vCenterIpAddress)

        1a. Changed DeleteCiscoNexusVSMCmd to also
            extend BaseCmd.

        2. Put in changes that will ensure that
           When a VSM is added, it is disabled by default.

        3. Fixed code that was leading to exceptions
           related to DB reads/writes to VSM related tables.

        4. Added new API Constants in ApiConstants.java.
           NOTE - Always initialize new attributes in
           ApiConstants.java to values in small case.
           Never put in upper case there. Also regardless
           of what names you give attributes in the
           *Cmd.java's class, you pass in parameters via
           API calls by specifying <key>=<value> where the
           <key> is taken from the value you specified in
           ApiConstants.java.

        5. Modified the addCiscoNexusVSM() function in
           CiscoNexusVSMDeviceManagerImpl.java to write VSM
           records to the db.
Bug CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

        1. Put in invocation to the deleteCiscoNexusVSM()
	   function in the deleteCiscoNexusVSM command
	   chain.

        2. Put in additional check for physical servers
	   present in a cluster that still is tied to a
	   VSM. The previous check would query for all
	   hosts in a cluster, causing the check to see
	   if a cluster has any physical servers in it
	   to always fail and thus block the VSM from
	   getting deleted. By putting in a check to see
	   if a host if of type "Routing", we refine this
	   search to only hypervisors.

        3. Other miscallaneous code + cleanup.
Bug CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	1. Modify addCiscoNexusVSMCmd to enable a VSM
           by default, when it is added to a cluster.

	2. Put in two new APIs exposed to the user -
                a. EnableCiscoNexusVSMCmd
                b. DisableCiscoNexusVSMCmd

        Disabling a VSM does not delete it. It only
        prevents the Management Server from using that
        VSM. This is useful if the VSM is in
        maintenance mode.
CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	Updated the add port profile routine to support
	more options (bindingtype, switchport mode, port
	profile types).
Bug CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	1. Added the PortProfile infrastructure:

	    a. PortProfileVO : The VO class to represent a db
	    record of the table port_profile. Each db record
	    represents one port profile.

	    b. PortProfileDao: The interface that declares search
	    functions on the port_profile table.

	    c. PortProfileDaoImpl: The class that defines the
	    interfaces declared in PortProfileDao.

	    d. PortProfileManagerImpl: The class that contains
	    routines that will add or delete db records from
	    the port_profile table. If you want to create/delete
	    a portprofile, call functions from this class.

	    e. Changes to create-schema.sql to create the port_profile
	    table.

	2. Cleaned up code:

	    a. Removed a number of unused Dao and Manager objects in
	    CiscoNexusVSMDeviceManagerImpl.

	    b. Removed the ListCiscoNexusVSMNetworksCmd command.

	    c. Removed a bunch of import statements in a few files.
CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	Adding a helper routine for modifying port
	profile configuration.
CS-9919: Support for Nexus Swiches (Cisco Vswitches)

Description:

	Made changes to persist the vsm configuration
	after updating it.