41
Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE CISCO INTERCLOUD FABRIC PROVIDER PLATFORM ADAPTER DEVELOPER GUIDE ............... 3 GETTING STARTED ..................................................................................................................................................... 3 Tools and Environment .................................................................................................................................... 3 Service Provider Infrastructure Requirements ................................................................................................. 3 Deployment Network Topology ....................................................................................................................... 3 Provider Platform Capability ............................................................................................................................ 4 Provider Network Models ................................................................................................................................ 5 Cloud VM Deployment ..................................................................................................................................... 6 Public Network Address Assignment................................................................................................................ 7 Multi-Site Support ............................................................................................................................................ 8 DEVELOPMENT ENVIRONMENT .................................................................................................................................... 9 Development Methodology ............................................................................................................................. 9 Development Steps .......................................................................................................................................... 9 CISCO ICFPP PROGRAMMING MODEL ........................................................................................................................ 10 ADAPTER JAVA DOCUMENTATION............................................................................................................................... 11 SAMPLE ADAPTER CODE ........................................................................................................................................... 11 API PROGRAMMING ........................................................................................................................................ 11 OVERVIEW ............................................................................................................................................................. 11 SERVICE LOADER CONFIGURATION .............................................................................................................................. 12 RESOURCE FILES ...................................................................................................................................................... 12 BUILD INFRASTRUCTURE ........................................................................................................................................... 12 PACKAGING THE ADAPTER ......................................................................................................................................... 12 APIS.................................................................................................................................................................. 12 CAPIPLUGINSERVICESIF ............................................................................................................................................ 12 listLocations ................................................................................................................................................... 12 listCapabilities ................................................................................................................................................ 13 getName ........................................................................................................................................................ 14 getDescription ................................................................................................................................................ 14 getVersion ...................................................................................................................................................... 14 getNetworkService ......................................................................................................................................... 14 getSecurityService .......................................................................................................................................... 15 getSessionService ........................................................................................................................................... 15

Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

  • Upload
    others

  • View
    20

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 1

Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1

2015-11-13

Contents INTRODUCING THE CISCO INTERCLOUD FABRIC PROVIDER PLATFORM ADAPTER DEVELOPER GUIDE ............... 3

GETTING STARTED ..................................................................................................................................................... 3 Tools and Environment .................................................................................................................................... 3 Service Provider Infrastructure Requirements ................................................................................................. 3 Deployment Network Topology ....................................................................................................................... 3 Provider Platform Capability ............................................................................................................................ 4 Provider Network Models ................................................................................................................................ 5 Cloud VM Deployment ..................................................................................................................................... 6 Public Network Address Assignment ................................................................................................................ 7 Multi-Site Support ............................................................................................................................................ 8

DEVELOPMENT ENVIRONMENT .................................................................................................................................... 9 Development Methodology ............................................................................................................................. 9 Development Steps .......................................................................................................................................... 9

CISCO ICFPP PROGRAMMING MODEL ........................................................................................................................ 10 ADAPTER JAVA DOCUMENTATION ............................................................................................................................... 11 SAMPLE ADAPTER CODE ........................................................................................................................................... 11

API PROGRAMMING ........................................................................................................................................ 11

OVERVIEW ............................................................................................................................................................. 11 SERVICE LOADER CONFIGURATION .............................................................................................................................. 12 RESOURCE FILES ...................................................................................................................................................... 12 BUILD INFRASTRUCTURE ........................................................................................................................................... 12 PACKAGING THE ADAPTER ......................................................................................................................................... 12

APIS.................................................................................................................................................................. 12

CAPIPLUGINSERVICESIF ............................................................................................................................................ 12 listLocations ................................................................................................................................................... 12 listCapabilities ................................................................................................................................................ 13 getName ........................................................................................................................................................ 14 getDescription ................................................................................................................................................ 14 getVersion ...................................................................................................................................................... 14 getNetworkService ......................................................................................................................................... 14 getSecurityService .......................................................................................................................................... 15 getSessionService ........................................................................................................................................... 15

Page 2: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 2

getStorageService .......................................................................................................................................... 15 getTemplateService........................................................................................................................................ 15 getVmService ................................................................................................................................................. 15 getVpcService ................................................................................................................................................. 16

CAPIPLUGINNETWORKIF ........................................................................................................................................... 16 listPublicIpAddress ......................................................................................................................................... 16

CAPIPLUGINSESSIONIF ............................................................................................................................................. 17 createClientSession ........................................................................................................................................ 17 deleteClientSession ........................................................................................................................................ 17 validateClientSession ..................................................................................................................................... 18

CAPIPLUGINSTORAGEIF ............................................................................................................................................ 18 CAPIPLUGINSECURITYIF ............................................................................................................................................ 18

createSecurityGroup ...................................................................................................................................... 18 deleteSecurityGroup....................................................................................................................................... 19 updateSecurityGroup ..................................................................................................................................... 20 addSecurityRule ............................................................................................................................................. 20 updateSecurityRule ........................................................................................................................................ 21 deleteSecurityRule.......................................................................................................................................... 21

CAPIPLUGINTEMPLATESIF ......................................................................................................................................... 22 createTemplate .............................................................................................................................................. 22 deleteTemplate .............................................................................................................................................. 24 discoverTemplate ........................................................................................................................................... 25

CAPIPLUGINVMIF .................................................................................................................................................... 26 deployVirtualMachine .................................................................................................................................... 26 destroyVirtualMachine .................................................................................................................................. 29 rebootVirtualMachine/ startVirtualMachine/ stopVirtualMachine ............................................................... 30 downloadVMInstance .................................................................................................................................... 32 listVirtualMachines ........................................................................................................................................ 33 getVirtualMachines ........................................................................................................................................ 33 updateVirtualMachine ................................................................................................................................... 33 updateVirtualMachines ................................................................................................................................. 35

CAPIPLUGINVPCIF ................................................................................................................................................... 35 listProviderVPC ............................................................................................................................................... 36 listVpcById ...................................................................................................................................................... 36 createVpc ....................................................................................................................................................... 37 deleteVpc ....................................................................................................................................................... 37 listVpcNetworkById ........................................................................................................................................ 38 createVpcNetwork ......................................................................................................................................... 39 deleteVpcNetwork.......................................................................................................................................... 40

ABBREVIATIONS AND ACRONYMS ................................................................................................................... 41

REFERENCES ..................................................................................................................................................... 41

OBTAINING DOCUMENTATION, OBTAINING SUPPORT, AND SECURITY GUIDELINES ........................................ 41

Page 3: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 3

Introducing the Cisco Intercloud Fabric Provider Platform Adapter Developer Guide Cisco Intercloud Fabric Provider Platform (ICFPP) is a virtual appliance deployed in the Service Provider (SP) cloud data center that enables SP customers to access cloud resources. SPs can extend Cisco ICFPP to add support for their cloud platform.

This document describes how to develop adapters for Cisco ICFPP. Cisco provides an adapter framework that allows SPs to write adapters to expose their cloud platform to customers.

Note

The VMware vCloud Director cloud platform is one of the Cisco ICFPP supported platforms. Cisco ICFPP includes a built-in adapter for this platform.

Getting Started This document assumes that you are familiar with the Cisco ICFPP architecture. For information about the Cisco ICFPP architecture, see the white papers at http://www.cisco.com/c/en/us/products/cloud-systems-management/intercloud-fabric/white-paper-listing.html.

The Cisco ICFPP Software Development Kit (SDK) includes sample plug-in for the VMware vCloud Director cloud platform. This documentation refers frequently to this sample plug-in.

Tools and Environment The following tools are required for adapter development: ● Java Version 1.6─See http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-

javase6-419409.html.

Note

Only version 1.6 is supported.

● Ant Version 1.8.2─See http://archive.apache.org/dist/ant/binaries/. ● Eclipse─See http://www.eclipse.org.

Service Provider Infrastructure Requirements Cisco ICFPP provides a simple programmable cloud adapter interface for ease of integration with service provider cloud platforms. Most of the southbound adapter interfaces are straightforward and adapter developers can develop the interfaces quickly. However, adapter developers must pay attention to the following areas in the provider infrastructure: ● Deployment Network Topology ● Provider Platform Capability ● Provider Network Models ● Cloud VM Deployment Functions ● Public Network Address Assignment

Deployment Network Topology Although the Cisco ICFPP deployment network topology is straightforward, its implementation can vary for different SPs and different cloud platforms. Use the following conventions and guidelines when setting up Cisco ICFPP deployment networks: ● Cisco ICFPP must be accessible from the Internet, SP-managed inter-data center networks, or both. ● Service providers usually can expose Cisco ICFPP through a NAT rule configured at an SP edge router or a

web-proxy. ● Cisco ICFPP and cloud platforms should be able to communicate to each other so they can initiate

management connections with each other. ● If uploading or downloading images is required, and Cisco ICFPP and the cloud platform use shared storage,

Cisco ICFPP must be able to access to the shared storage network.

Page 4: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 4

Figure 1 depicts an example of a Cisco ICFPP deployment network topology.

Figure 1 – Cisco ICFPP Deployment Network Topology Example

Provider Platform Capability The provider platform must describe the capabilities supported by the platform.

The information in the following table is required:

Parameter Description Example Values

cloudStyle Tenant network. Shared network, isolated networks

imageFormat Image format. VMDK, RAW virtualizationType Virtualization type. KVM, XEN hypervisorType Hypervisor type. ESXi, Xen, KVM imageContainerType Image package type. OVA, None platformType Array of platform type of service appliances. VSG, CSR cloudAgent Array of VM agent types. Azure-WAA, AWS-getkeys,

Vmware-VMTools templateContainment Template containment can be based on

Location-locationType or ProviderVpc. Location examples are: Location-Region Location-Zone

partitionType Disk partition types. Flat-Disk, Multi-Disk securityGroupContainment Security group containment can be based

on Location, VM, ProviderVPCNetwork, and ProviderVPC.

locationHierarchy The location hierarchy based on location objects.

Region, Availability Zone

providerVpcManagement Provider supports create, update, and delete of ProviderVpc.

CREATE, UPDATE, DELETE, READ, autoAssignSubnet in which the provider automatically assigns the subnet address

Page 5: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 5

Parameter Description Example Values

providerNetworkManagement Indicates whether or not the provider supports create and delete of ProviderVpcNetwork or discovery (read) of ProviderVpcNetwork.

CREATE, DELETE, READ

supportedOsTypes Comma-separated list of supported operating systems for cloud VMs in the format category_version_architecture. The version can be major or major.minor. The architecture is optional.

RHEL_6, CentOS_6_3, Windows_2008.R2_64

serverMemoryRange In MB, the memory range supported by the VM.

Default range: 512-65536

fractionalMemorySupport Whether the memory specified for the VM should not be at the gigabyte boundary.

Default: True

serverCpuRange Range of virtual CPUs supported by the VM.

Default range: 1-64

initICSOnFirstBoot Whether to initialize the Intercloud Switch (ICS) on the first boot.

Default: True

Based on the values returned, Cisco Intercloud Fabric Director (ICFD) determines: ● How to transform a workload image to an appropriate format. ● How to allocate the required network resources (such as public IP addresses, network segments, subnets, and

so on) to build the secure network extender. ● The platform type to use for deploying infrastructure VMs (such as CSR or VSG). ● How to create template containments based on the provider's cloud site hierarchy (such as a region or

availability zone). ● How to create a security group within a cloud site containment.

For more information about provider capability details, see the CapiPluginServicesIf interface API listCapabilities.

Provider Network Models Cisco Intercloud Fabric (ICF) extends enterprise network segments to a public cloud data center by means of a secure network extension that facilitates enterprise workload migration. The secure network extension is achieved through a Layer 2 overlay network that is built on top of a provider's network. The overlay network functions are transparent to the underlying provider network architecture. However, the provider network architecture impacts how Cisco ICFD deploys infrastructure VMs and operationally builds the secure extender.

Cloud service providers commonly offer the following network architectures: ● Shared Network─All tenants share the same network infrastructure; isolation is achieved by using security-

groups. ● Isolated Network─A tenant dynamically creates one or more tenant-specific, isolated networks, which protect

and isolate the tenant from other networks.

Based on the values of cloudStyle and providerVpcManagement returned from the provider platform, Cisco ICFD performs the operations required to build the overlay networks and deploy the infrastructure VMs, such as Cisco Cloud Services Router 1000V (CSR) and Cisco VSG (VSG).

Figure 2 depicts how Cisco ICF Secure Extender can be built on a shared network architecture. Because all overlay network functions are provided by the infrastructure VMs (such as the ICS, CSR, and VSG), the only infrastructure requirements needed from the provider are: ● Cloud VM deployment ● Provider private IP address assignments ● Provider public IP address assignment to ICS

For more information about VM deployment, see the CapiPluginVmIf interface API.

Page 6: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 6

Figure 2 – Secure Extender Built on a Shared Provider Network

Figure 3 depicts how ICF Secure Extender can be built on an isolated network architecture. In addition to the infrastructure requirements mentioned previously, Cisco ICFD must be able to access provider network management APIs for dynamically allocated networks. In many cases, provider isolated-network functions are built on top of a VPC-based tenant provisioning architecture, which isolates the network, compute, and storage resources from other tenants.

See the CapiPluginVmIf and CapiPluginVpcIf interface APIs for more detail.

Figure 3 – Secure Extender Built on an Isolated Per-Tenant Network

Cloud VM Deployment In the current Cisco Intercloud Fabric implementation, four types of cloud VMs must be deployed in public cloud provider data centers: ● Application VM – VM running business customers’ applications ● Infra-ICS – VM providing Intercloud Fabric Switch overlay functions

Page 7: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 7

● Infra-CSR – VM providing routing, NAT, and VPN functions ● Infra-VSG – VM offering firewall and isolation functions

The following table identifies the infrastructure VM deployment requirements:

Provider VM Deployment Requirements

Cloud VM Types

Infra-CSR Application VM, and Infra-ICS and Infra-VSG

O/S Platform Supported 64-bit Monta Vista Linux with 2.6.32 Kernel

N/A

OVF Customization Required N/A VM Tool Installation VMware VM-Tool Required Open VM-Tool Required Provider IP Address Assignments

Static DHCP or Static

The OVF customization required for an infrastructure VM, such as Infra-CSR, allows a cloud orchestrator (Cisco ICFPP) to programmatically pass a set of OVF configuration parameters to the Infra-CSR VM during VM instantiation. Depending on the approach that the SP cloud platform takes in supporting OVF parameter-passing features, the OVF customization process can vary.

Using the CloudStack platform as an example, passing OVF parameters involves the following tasks:

1. Obtaining all necessary OVF parameters from the enterprise IT admin. These parameters include the IP address, netmask address, gateway IP address, DNS server address, domain name, and hostname. Cisco ICFPP uses this information to create an OVF configuration XML file named ovf-env.xml.

2. Converting the ovf-env.xml file to an ISO image and using the registerIso ( ) API to register the image so it can be attached to a given user.

3. Deploying a VM in a Stopped state (that is, with the startvm parameter set to False) with the deployVirtualMachine ( ) API.

4. Attaching the OVF configuration XML file ovf-env.xml to the previously deployed VM with the attachIso ( ) API.

5. Starting the VM with the startVirtualMachine ( ) API. The VM will pick up the parameters passed through the configuration file.

For more information about any of the CloudStack API operations, see http://cloudstack.apache.org/api.html.

For more information about VM deployment, see the CapiPluginVmIf interface APIs.

Public Network Address Assignment Depending on the situation, cloud VMs might need to communicate with systems on external networks, such as the Internet. Examples of such situations include: ● An application VM hosts a web server. ● An application VM must communicate with external web servers. ● An application VM provides VPN services for branch offices. ● An infrastructure VM, such as Infra-ICS, must provide a secure network extension for the enterprise.

In the Cisco ICF Secure Extender architecture, most external connectivity is handled by the CSR. The exception is the Infra-ICS VM, which is responsible for establishing the Cisco ICF Secure Extension by connecting with the Intercloud Extender (ICX) running in the enterprise. The following table summarizes the public IP address assignment requirements and how NAT rules can be configured to address various situations.

Page 8: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 8

ICF Use Cases

Infrastructure Configuration Required

Application VM Infra-CSR Infra-ICS Provider Router Hosting a Web Server

Set the default gateway to CSR

NAT rules for translating the

enterprise private IP address to the

provider private IP address

N/A NAT rules for translating the provider private address to

the provider public IP address

Connecting to Internet Servers Offering VPN Services Offering Secure Extension

N/A N/A Set the default gateway to the provider router

For more information about VM public network address assignment, see the CapiPluginVmIf interface APIs.

Multi-Site Support Provider cloud platforms commonly support multiple regions and availability zones for scaling and high availability purposes: ● A region has a separate API endpoint for each cloud platform deployment, allowing for a more discrete

separation of locations and, thus, services. Users who want to run instances across sites must explicitly select a region.

● An availability zone is a logical separation within a cloud platform deployment that provides physical isolation or redundancy. When users provision resources, they specify the availability zone to use for an instance. This allows cloud consumers to ensure that their application resources are spread across multiple machines and benefit from high availability configurations in the event of hardware failure.

Cisco ICF architecture adheres to the following guidelines with regard to multi-site support: ● Cisco ICF assumes that the service provider will deploy one Cisco ICFPP instance per region and provides a

separate URL or IP address for each Cisco ICFPP instance. ● After the Cisco ICFPP cloud adapter has signed on with the cloud platform, Cisco ICFPP uses the southbound

adapter listLocations API to determine the number of availability zones that are supported by the platform and provides a list of the availability zones and regions to Cisco ICFD.

● Upon receiving the availability zone information, Cisco ICFD displays the information in the Cisco ICFD admin and end-user portals, where users can specify the availability zone to use for an instance.

Page 9: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 9

Figure 4 depicts an overview of multi-site support in Cisco ICF. For more information about multi-site support, see the CapiPluginServicesIf interface API (for example, listLocations).

Figure 4 – Cisco Intercloud Fabric Multi-Site Support Overview

Development Environment

Development Methodology We recommend that you use the following method when developing an adapter for use with Cisco ICFPP:

1. Create a custom module project.

2. Implement the cloud adapter plug-in interfaces.

3. Unit test with a Java test framework to verify that the adapter makes the correct API calls to the backend cloud platform.

4. After verifying that the API calls are successful, test with Cisco ICFPP.

5. To validate each cloud adapter interface in Cisco ICFPP, use the Python-based test harness that is provided with the SDK.

6. After validating the cloud adapter interfaces, perform integration testing with Cisco ICFD and the provider cloud platform.

Development Steps The following conventions and guidelines are required when developing the plug-in so that it will be compatible with Cisco ICFPP. If adapter development does not adhere to the naming conventions and identified procedures, the plug-in might fail to function.

1. Choose a unique name for the Custom Module Type. The Custom Module Type name that you choose must be the same string that is passed when the Service Provider provisions a cloud instance on Cisco ICFPP. For this discussion, we will assume that the Custom Module Type name is “custom1”.

2. Implement the adapter interfaces. The interfaces that must be implemented are available in the Java documentation under com.cloupia.feature.capiController.api package.

Page 10: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 10

3. Unit test each interface that is implemented by using any Java unit test harness. Cisco ICFPP is not required to validate the API. Developers can write unit test programs that exercise the feature being implemented to confirm that it works as expected.

4. After the adapter interfaces are implemented and unit-tested, test with Cisco ICFPP by using the Cisco ICFPP test harness.

Cisco ICFPP Programming Model After a custom cloud adapter is developed, use the following workflow to load the adapter plug-in code on to the Cisco ICFPP platform and enable the cloud adapter functions for the targeted tenants:

1. SP developers download the cloud adapter plug-in SDK from Cisco Connection Online (CCO) site for developing a custom cloud adapter.

2. When the customer cloud adapter plug-in code is ready to use, the developer can load the package file (for example, custom.tar.gz that contains jars/custom1.jar) to the file system on the targeted Cisco ICFPP by using standard Linux tools or the GUI.

3. The Cloud Instance Provision Intercloud Provider API is used to add an instance to the Cisco ICFPP platform. In the Cloud Instance Provision API request, an SP admin can use the cloud module field to specify the name of the JAR file (for example, custom1). This will bind the plug-in code with the cloud instance to be added.

4. When an SP admin provisions tenants on the Cisco ICFPP platform using the Tenant Provision Intercloud Provider API, the SP admin can bind the tenants with the newly added cloud instance.

5. When a tenant issues Intercloud cloud API requests with a Cisco ICFD instance, the API requests are handled by the newly added cloud adapter plug-in code.

Figure 5 depicts the logical flow for loading custom cloud adapter plug-in code on to a Cisco ICFPP platform and processing incoming Intercloud cloud API requests issued by a tenant.

Page 11: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 11

Figure 5 – Cisco ICFPP Programming Model Overview

Adapter Java Documentation To support other new cloud platforms, the Cisco ICFPP Adapter defines a set of Java-based interfaces. Java documentation is available from your Cisco ICFPP virtual appliance by using the URL http://icfpp-ip-address/capi/docs/index.html.

Sample Adapter Code Cisco ICFPP supports vcdp, which is a southbound cloud adapter. The vcdp adapter was written to interact with the back end of the VMware vCloud Director cloud infrastructure. It is a fully working adapter and provides an implementation example for developers. This example adapter is provided only as a reference implementation, and will not work with other cloud platforms.

API Programming This section describes how to code an adapter. Details about the methods specified in this section can be found in the Java documentation that is provided with the Cisco ICFPP software. All of the following APIs have an object CapiTenantAccountVO, which is used to derive any and all information for the user performing the cloud operations. This can be an API key or password details.

Overview Each adapter is expected to implement the interfaces mentioned in the following sections.

Do not directly access the database from the adapter code. Doing so could break the adapter when the infrastructure is updated.

Note

Do not populate class variables that are marked Read-Only in the Java documentation. Those items are candidates for removal in future drops. For the exact details of the following classes, refer to the Java documentation.

Page 12: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 12

Service Loader Configuration You must define a provider configuration file in the META-INF/services directory. The filename is the fully qualified com.cloupia.feature.capiController.api.CapiPluginServicesIf. The content of this file is the package name in which the CapiPluginServicesIf is implemented.

META-INF |____services | |____com.cloupia.feature.capiController.api.CapiPluginServicesIf

Resource Files To control the timeouts of various tasks spawned in the system, create an <adapter_type>.properties file. When packaged in the final JAR, this file must reside in the top-level resources directory. The following example shows a directory structure for an adapter JAR:

|____com |____META-INF | |____MANIFEST.MF | |____services | | |____com.cloupia.feature.capiController.api.CapiPluginServicesIf |____resources |____CSP.properties

Build Infrastructure Adapter developers are welcome to use any build infrastructure, such as Ant, Maven, or Gradle. The example provided in this release is an Ant-based adapter. Only one dependency JAR is provided by Cisco; it must be appropriately incorporated as a dependency library.

Packaging the Adapter After building an adapter, you must package the adapter in a specific directory structure so that it can be installed by the Cisco ICFPP infrastructure, as follows:

1. Create a jars directory.

2. Copy the adapter and other required JAR files into the jars directory by using the following command:

tar –czvf adapter.tar.gz jars

APIs

CapiPluginServicesIf This umbrella defines service-related interfaces. Methods are identified in the following subsections.

listLocations This method returns the list of locations supported for this account. Depending on the cloud, the locations can be either flat or in a hierarchy. For example, a cloud provider might have a region that contains multiple zones. Alternatively, it might have a flat Region/Data Center with no hierarchy. Cisco ICFPP uses this API to determine the number of locations supported by the platform and reports the realized location information to Cisco ICFD. Upon receiving this information, Cisco ICFD displays it to the end-user portals, where users can select the desired location for deploying services.

API public CapiLocationDetailsList listLocations( CapiTenantAccountVO tenantAccountInfo) throws CapiPluginServicesException;

Page 13: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 13

Adapter Development

Adapters must:

1. Fetch locations from the respective cloud providers and/or manually populate the CapiLocationDetailsList object and return it.

2. In the event of a failure, return a CapiPluginServicesException exception with a message that clearly states the reason for the failure.

Code Stub

VcdpPluginServices.java public CapiLocationDetailsList listLocations( CapiTenantAccountVO tenantAccountInfo) throws CapiPluginServicesException { CapiLocationDetailsList locationList = null; try { locationList = new CapiLocationDetailsList(); CapiLocationDetails locationElement = new CapiLocationDetails(); // Cloud Specific Code Start // Cloud Specific Code End List<CapiLocationDetails> locationElementArray = new ArrayList<CapiLocationDetails>(); locationElementArray.add(locationElement); locationList.setLocations(locationElementArray); } catch (Exception e) { logger.error(e.getMessage(), e); throw new CapiPluginServicesException( CapiPluginErrorCodes.SERVICE_ERROR, "Location could not be fetched", e); } return locationList; }

listCapabilities This method returns the capabilities supported for this account. Based on the platform capability values returned, Cisco ICFD can determine: ● How to transform a workload image to an appropriate format. ● How to build the secure network extender. ● How to pass VM parameters to the infrastructure and/or workload VMs.

API public CapiCapabilities listCapabilities( CapiTenantAccountVO tenantAccountInfo) throws CapiPluginServicesException;

Adapter Development 1. Populate and return the CapiCapabilities object with values that reflect the cloud provider and its supported

features. It is important to accurately obtain all elements of this object because it determines Cisco ICFD’s interaction with the cloud.

2. In the event of a failure, return a CapiPluginServicesException exception with a message that clearly states the reason for the failure.

Page 14: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 14

Code Stub

VcdpPluginServices.java public CapiCapabilities listCapabilities( CapiTenantAccountVO tenantAccountInfo) throws CapiPluginServicesException { try { CapiCapabilities providerCapability = new CapiCapabilities(); // Cloud Specific Code Start // Cloud Specific Code End return providerCapability; } catch (Exception e) { logger.error(e.getMessage(), e); throw new CapiPluginServicesException( CapiPluginErrorCodes.SERVICE_ERROR, "Capablities could not be fetched", e); } }

getName This API returns the name of the adapter. This name is used for all subsequent adapter operations, including upgrading the existing adapter.

API public String getName();

Adapter Development Return a string name of the adapter. The name cannot include any special characters or spaces.

getDescription Provide a brief description of the adapter (display only).

API public String getDescription();

Adapter Development

Return a string with the description.

getVersion Return the adapter version.

API public String getVersion();

Adapter Development

Return a string with the version number.

getNetworkService Return the adapter class object associated with the CapiPluginNetworkIf service. The service loader uses this object.

API public CapiPluginNetworkIf getNetworkService();

Page 15: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 15

Adapter Development

Return the class.

getSecurityService Return the adapter class object associated with the CapiPluginSecurityIf service. The service loader uses this object.

API public CapiPluginSecurityIf getSecurityService();

Adapter Development

Return the class.

getSessionService Return the adapter class object associated with the CapiPluginSessionIf service. The service loader uses this object.

API public CapiPluginSessionIf getSessionService();

Adapter Development Return the class.

getStorageService Return the adapter class object associated with the CapiPluginStorageIf service. The service loader uses this object.

API public CapiPluginStorageIf getStorageService();

Adapter Development

Return the class.

getTemplateService Return the adapter class object associated with the CapiPluginTemplateIf service. The service loader uses this object.

API public CapiPluginTemplatesIf getTemplateService();

Adapter Development

Return the class.

getVmService Return the adapter class object associated with the CapiPluginVmIf service. The service loader uses this object.

API public CapiPluginVmIf getVmService();

Adapter Development Return the class.

Page 16: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 16

getVpcService Return the adapter class object associated with the CapiPluginVpcIf service. The service loader uses this object.

API public CapiPluginVpcIf getVpcService();

Adapter Development

Return the class.

CapiPluginNetworkIf This umbrella defines methods that are relevant for network-related operations. This umbrella currently supports listing public IP addresses only.

listPublicIpAddress This method lists the public IP addresses assigned for the tenant user. In some Cisco ICF environments, cloud VMs might need to communicate with systems on external networks such as the Internet. Examples of these situations are the following: ● An application VM hosts a web server. ● An application VM must communicate with external web servers. ● An application VM provides VPN services for branch offices. ● An infrastructure VM, such as Infra-ICS, must provide a secure network extension for the enterprise.

There are several variations for different cloud providers. For example, some cloud providers initially allocate public IP addresses while others return a few IP addresses initially and subsequent queries must be made by the account admin.

API CapiPublicIpPools listPublicIpAddress( CapiTenantAccountVO tenantAccountInfo) throws CapiPluginNetworkException;

Adapter Development 1. Fetch the required public IP details from the cloud backend and populate and return the CapiPublicIpPools

object.

2. Clearly define any exception with a message that can be used by the account admin.

Note

If the cloud platform does not have the concept of a public IP pool, it can return empty object. The adapter is responsible for programming or assigning a public IP address during virtual machine deployment.

Code Stub public class VcdpPluginNetwork implements CapiPluginNetworkIf { private Logger logger = Logger.getLogger(VcdpPluginNetwork.class); /* * (non-Javadoc) * * @seecom.cloupia.feature.capiController.api.CapiPluginNetworkIf# * listPublicIpAddress() */ public CapiPublicIpPools listPublicIpAddress( CapiTenantAccountVO tenantAccountInfo) throws CapiPluginNetworkException { CapiPublicIpPools publicIpPools = null; try { // Cloud Specific Code Start // Cloud Specific Code End

Page 17: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 17

} catch (Exception e) { logger.error("Exception while getting public ip pools ", e); throw new CapiPluginNetworkException( CapiPluginErrorCodes.NETWORK_ERROR, e.getMessage(), e.getCause()); } return publicIpPools; } }

CapiPluginSessionIf This section defines all session-based methods. These methods are used to either validate a cloud provider session, or create or destroy a session for each transaction performed on the cloud backend.

createClientSession

API boolean createClientSession( CapiTenantAccountVO tenantAccountInfo) throws CapiPluginSessionException;

Adapter Development

1. Use account credentials and establish a session with the backend.

2. Create the session object and save it as part of the class.

3. If a session handle cannot be established, return an exception.

Code Stub public boolean createClientSession(CapiTenantAccountVO tenantAccountInfo) throws CapiPluginSessionException { try { // Cloud Specific Code Start // Cloud Specific Code End } catch (Exception e) { throw new CapiPluginSessionException( CapiPluginErrorCodes.CONNECTION_NOT_AVAILABLE, e.getMessage(), e.getCause()); } return true; }

deleteClientSession

API boolean deleteClientSession() throws CapiPluginSessionException;

Adapter Development 1. Fetch the session that was created as part of the createSession() method.

2. Delete the session and return.

3. If a session cannot be deleted, return an exception.

Page 18: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 18

Code Stub public boolean deleteClientSession(CapiTenantAccountVO tenantAccountInfo) throws CapiPluginSessionException { try { // Cloud Specific Code Start // Cloud Specific Code End } catch (Exception e) { throw new CapiPluginSessionException( CapiPluginErrorCodes.CONNECTION_NOT_AVAILABLE, e.getMessage(), e.getCause()); } return true; }

validateClientSession This method validates a session whenever the adapter makes a call to the cloud provider API. All adapters must populate this method.

API boolean validateClientSession( CapiTenantAccountVO tenantAccountInfo) throws CapiPluginSessionException;

Adapter Development This method validates connectivity to the cloud backend. Adapters can do one of the following: ● Use the tenantAccountInfo API and, depending on the cloud, either the username and password or the API

key and Secret key combination can be used to validate connectivity to the cloud provider infrastructure. ● After a connection is validated, return a boolean to reflect the operation.

Code Stub public boolean validateClientSession(CapiTenantAccountVO tenantAccountInfo) throws CapiPluginSessionException { boolean validated = false; // Cloud Specific Code Start // Cloud Specific Code End } else { logger.error("Can not create connection to " + tenantAccountInfo.getCloudEndPoint()); throw new CapiPluginSessionException( CapiPluginErrorCodes.CONNECTION_NOT_AVAILABLE, "Unable to connect", null); } return validated; }

CapiPluginStorageIf No APIs are currently implemented as part of this interface.

CapiPluginSecurityIf This interface deals with create, read, update, and delete (CRUD) operations that pertain to security rules applied to a virtual machine or a network in the cloud.

createSecurityGroup This method creates a security group.

Page 19: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 19

API CapiSecurityResource createSecurityGroup( CapiTenantAccountVO tenantAccountInfo, CapiSecurityResource securityResourceModel) throws CapiPluginSecurityException;

Adapter Development

If the cloud backend supports the security group concept:

1. Read securityResourceModel.

2. Fetch the providerVpcId and locationId.

3. Invoke the cloud API to create a security group.

4. Return the status SecurityGroupEnum.CREATED.

Code Stub @Override public CapiSecurityResource createSecurityGroup(CapiTenantAccountVO tenantInfo, CapiSecurityResource securityResource) throws CapiPluginSecurityException { try { // Cloud Specific Code Start // Cloud Specific Code End securityResource.setStatus(SecurityGroupEnum.CREATED.value()); } catch (final Exception e) { logger.error(e.getMessage(), e); throw new CapiPluginSecurityException( CapiPluginErrorCodes.SECURITY_ERROR, "Error while creating security group" + e.getMessage(), e); } return securityResource; }

deleteSecurityGroup

API boolean deleteSecurityGroup( CapiTenantAccountVO tenantAccountInfo, String securityRuleId) throws CapiPluginSecurityException;

Adapter Development 1. Use securityGroupId to fetch providerVpcId and locationId.

2. Invoke the cloud API to delete the security group.

3. Update the status to DELETED.

4. In the event of a failure, issue an exception.

Code Stub @Override public boolean deleteSecurityGroup(CapiTenantAccountVO tenantInfo, String securityGroupId) throws CapiPluginSecurityException { try { // Cloud Specific Code Start // Cloud Specific Code End securityResource.setStatus(SecurityGroupEnum.DELETED.value()); } catch (final Exception e) { logger.error(e.getMessage(), e);

Page 20: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 20

throw new CapiPluginSecurityException( CapiPluginErrorCodes.SECURITY_ERROR, "Error while deleting security group" + e.getMessage(), e); } return true; }

updateSecurityGroup

API CapiSecurityResource updateSecurityGroup( CapiTenantAccountVO tenantAccountInfo, CapiSecurityResource securityResourceModel) throws CapiPluginSecurityException;

Adapter Development 1. Using securityGroupId, fetch providerVpcId and locationId.

2. Invoke the cloud API to update the security group information.

3. Update the status to UPDATED.

4. In the event of failure, issue an exception.

Code Stub @Override public CapiSecurityResource updateSecurityGroup(CapiTenantAccountVO tenantInfo, CapiSecurityResource securityResource) throws CapiPluginSecurityException { try { // Cloud Specific Code Start // Cloud Specific Code End securityResource.setStatus(SecurityGroupEnum.UPDATED.value()); } catch (final Exception e) { logger.error(e.getMessage(), e); throw new CapiPluginSecurityException( CapiPluginErrorCodes.SECURITY_ERROR, "Error while updating security group" + e.getMessage(), e); } return securityResource; }

addSecurityRule

API CapiSecurityRule addSecurityRule( CapiTenantAccountVO tenantAccountInfo, String securityGroupId, CapiSecurityRule securityRule) throws CapiPluginSecurityException;

Adapter Development 1. Using securityGroupId, fetch providerVpcId and locationId.

2. Read the security rule and apply it on the cloud back end.

3. In the event of failure, issue an exception.

Code Stub @Override public CapiSecurityRule addSecurityRule(CapiTenantAccountVO tenantInfo,

Page 21: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 21

String securityGroupId, CapiSecurityRule securityRule) throws CapiPluginSecurityException { try { // Cloud Specific Code Start // Cloud Specific Code End } catch (Exception e) { throw new CapiPluginSecurityException( CapiPluginErrorCodes.SECURITY_ERROR, "Error while adding security rule" + e.getMessage(), e); } finally { } return securityRule; }

updateSecurityRule

API CapiSecurityRule updateSecurityRule( CapiTenantAccountVO tenantAccountInfo, String securityGroupId, CapiSecurityRule securityRule) throws CapiPluginSecurityException;

Adapter Development Reviewers: Is there content for this section?

Code Stub @Override public CapiSecurityRule updateSecurityRule(CapiTenantAccountVO tenantInfo, String securityGroupId, CapiSecurityRule securityRule) throws CapiPluginSecurityException { try { // Cloud Specific Code Start // Cloud Specific Code End } catch (Exception e) { throw new CapiPluginSecurityException( CapiPluginErrorCodes.SECURITY_ERROR, "Error while updating security rule" + e.getMessage(), e); } finally { } return securityRule; }

deleteSecurityRule

API boolean deleteSecurityRule( CapiTenantAccountVO tenantAccountInfo, String securityGroupId, String securityRuleId) throws CapiPluginSecurityException;

Adapter Development Reviewers: Is there content for this section?

Code Stub @Override public boolean deleteSecurityRule(CapiTenantAccountVO tenantInfo, String securityGroupId, String securityRuleId)

Page 22: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 22

throws CapiPluginSecurityException { // TODO Auto-generated method stub return true; }

CapiPluginTemplatesIf Template operations are implemented as methods with the signature as discussed in the following sections. These methods are invoked by the infrastructure code in the context of a Java thread.

createTemplate This method creates a new template based on an image that was uploaded to the Cisco ICFPP data store.

API CapiTemplate createTemplate( CapiTenantAccountVO tenantAccountInfo, CapiTemplate templateDetails) throws CapiPluginTemplateException;

Adapter Development 1. Using templateDetails, fetch the imageId.

2. Using the imageId, fetch the CapiImage object as follows: CapiImage image = ImageUtils.getImage(String imageId);

3. Fetch the image details from the image object. Image details include the image path, image name, length, and so on.

4. Invoke the cloud provider’s template creation API.

This call results in an identifier that is returned by the cloud provider.

5. Save the identifier into templateBackendId in the templateDetails object.

6. Wait for the creation status to be returned. We recommend that you check status once every 20 or 30 seconds, while being sure to minimize CPU impact.

7. If the returned status indicates a successful upload, set the templateStatus variable to TemplateStatusEnum.COMPLETE. If the status that is returned indicates failure, set it to TemplateStatusEnum.FAILED.

8. If an exception is issued, return a clear message string with the exception by using the following: throw new CapiPluginTemplateException(errorCode, errorMessage, e.getCause());

This method should not return unless one of the above templateStatus statuses has been reached.

9. If this method exceeds the specified timeout period, the operation is stopped and cleaned up. In addition, the templateStatus is marked failed and a fault is posted with appropriate error comments.

10. Return the templateDetails object.

Multi-Disk Support

A template can have a single disk or multiple disks. Depending on the cloud provider infrastructure, there are several ways to support this situation. The following describes a generic approach that is specific to multiple disks. In a multi-disk system, index 0 is considered the root disk and any other disks are data disks.

1. As part of the template creation task, uncompress the original image bundle received from Cisco ICFD.

The package contains a manifest file and the disk images.

The manifest file contains the following items: 1:filename1:os 2:filename2:data

Page 23: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 23

3:filename3:data

2. Upload the operating system disk image as a template to the backend cloud and retrieve the template IDs.

3. Upload the data disk as volume disks on the cloud platform and retrieve the volume IDs.

4. Populate the CapiTemplate object with the above disk information.

Code Stub

VcdpPluginTemplate.java public CapiTemplate createTemplate(CapiTenantAccountVO tenantAccountInfo, CapiTemplate template) throws CapiPluginTemplateException { try { VcdpCreateTemplate createTemplate = new VcdpCreateTemplate( tenantAccountInfo, template); createTemplate.executeMethod(); } catch (Exception e) { throw new CapiPluginTemplateException( CapiPluginErrorCodes.TEMPLATE_ERROR, "Error while creating the Template :" + template, e); } return template; }

VcdpCreateTemplate.java public class VcdpCreateTemplate { public static CapiLogger logger = CapiLogger .getLogger(VcdpCreateTemplate.class); private CapiTenantAccountVO tenantAccountInfo; private CapiTemplate templateDetails; public VcdpCreateTemplate(CapiTenantAccountVO tenantAccountInfo, CapiTemplate templateDetails) { logger.setCurrentAppenderId(tenantAccountInfo.getAccountUsername() + ":" + templateDetails.getTemplateId()); this.tenantAccountInfo = tenantAccountInfo; this.templateDetails = templateDetails; } public void executeMethod() throws CapiPluginTemplateException, InterruptedException { logger.info("templateid: " + templateDetails.getTemplateId()); String templateId = null; logger.info("Scheduler started for template:" + templateDetails); try { // Cloud Specific Code Start // Cloud Specific Code End templateDetails.setTemplateStatus(TemplateStatusEnum.COMPLETE); logger.info("Updated the status to (Complete) :" + templateId); } } catch (Exception e) { throw new CapiPluginTemplateException(CapiPluginErrorCodes.TEMPLATE_ERROR, e.getMessage()); } finally { } return; } }

Page 24: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 24

deleteTemplate This method deletes a previously uploaded template.

API void deleteTemplate( CapiTenantAccountVO tenantAccountInfo, String templateId) throws CapiPluginTemplateException;

Adapter Development This method gets templateId and the implicit object TenantAccountVO. The object name is tenantAccountInfo.

1. Fetch the template object as follows: template = TemplateUtils.getTemplate(templateId);

2. Using this object, fetch the templateStatus variable of the template object.

3. The adapter method is invoked only if the state of the template is “completed” or “Failed”.

4. Fetch the templateBackendId from the template object and call the corresponding cloud provider API to clean up the template.

5. Depending on the cloud provider, one of the following occurs:

◦ The deletion is a synchronous call. If so, wait for the deletion to complete.

◦ You wait for a status to be returned. We recommend that you check status once every 20 or 30 seconds, while being sure to minimize CPU impact.

6. If the cloud platform indicates that the template was successfully deleted, set the templateStatus variable to TemplateStatusEnum.DELETED.

7. If the cloud platform indicates that the template deletion failed:

a. Set the templateStatus variable to TemplateStatusEnum.DELETED.

b. Issue an error message that states that manual cleaning is required for this template.

This task should not return until the status is set to TemplateStatusEnum.DELETED.

8. If this method exceeds the specified timeout limit:

a. The process is stopped and cleaned up.

b. The templateStatus is marked failed.

c. Manual cleanup might be required.

Code Stub

VcdpPluginTemplate.java public void deleteTemplate(CapiTenantAccountVO tenantAccountInfo, String templateId) throws CapiPluginTemplateException { try { CapiTemplate template = TemplateUtils.getTemplate(templateId); VcdpDeleteTemplate deleteTemplate = new VcdpDeleteTemplate( tenantAccountInfo, template); deleteTemplate.executeMethod(); } catch (Exception e) { throw new CapiPluginTemplateException( CapiPluginErrorCodes.TEMPLATE_ERROR, "Error while deleting the TemplateId :" + templateId, e); } }

Page 25: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 25

VcdpDeleteTemplate.java public class VcdpDeleteTemplate { private static CapiLogger logger = CapiLogger .getLogger(VcdpDeleteTemplate.class); private CapiTenantAccountVO tenantAccountInfo; private CapiTemplate template; public VcdpDeleteTemplate(CapiTenantAccountVO tenantAccountInfo, CapiTemplate template) { logger.setCurrentAppenderId(tenantAccountInfo.getAccountUsername() + ":" + template); this.tenantAccountInfo = tenantAccountInfo; this.template = template; } /* * (non-Javadoc) * */ public void executeMethod() throws CapiPluginTemplateException, InterruptedException { VappTemplate apptemplate = null; String templateId = template.getTemplateId(); try { // Cloud Specific Code Start // Cloud Specific Code End } catch (CapiPluginTemplateException e) { throw e; } catch(InterruptedException ie){ throw ie; } catch (Exception e) { logger.error("Exception ..." + e.getMessage(), e); throw new CapiPluginTemplateException(CapiPluginErrorCodes.GENERAL_ERROR, e.getMessage(), e.getCause()); } finally { template.setTemplateStatus(TemplateStatusEnum.DELETED); template.setTemplateBackendId(null); logger.info("Updating the deleted status :" + templateId); try { boolean insert = TemplateUtils.saveTemplate(template); logger.info(" Update SuccessFul ? " + insert); } catch (Exception e) { logger.error("Template status cannot be updated" + e.getMessage(), e); } } return; } }

discoverTemplate This method discovers ICR (Intercloud-ready) templates in the cloud based on certain filter criteria.

API List<CapiTemplate> discoverTemplate( CapiTenantAccountVO tenantAccountInfo, Properties criteria) throws CapiPluginTemplateException;

Page 26: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 26

Adapter Development

This method fetches a list of templates from the cloud template catalog that matches the specified criteria. The criteria can be: ● name: A template name that matches a regular expression. ● tags: Tags in the template object. ● status: Status of the template. ● locationName: Name of the template location.

Code Stub public List<CapiTemplate> discoverTemplates( CapiTenantAccountVO tenantAccountInfo, Properties criteria) throws CapiPluginTemplateException { List<CapiTemplate> listTemplates = new ArrayList<CapiTemplate>(); logger.info("Discover Templates"); if (criteria != null && !criteria.isEmpty()) { /* * Dummy implementation only!! */ // Cloud Specific Code Start // Cloud Specific Code End if (criteria.get(TemplateFilterCriteriaEnum.NAME.value()) != null) { CapiTemplate template = new CapiTemplate(); template.setTemplateBackendId("111111111111111111"); template.setTemplateStatus(TemplateStatusEnum.COMPLETE); listTemplates.add(template); } } return listTemplates; }

CapiPluginVmIf

deployVirtualMachine This method deploys a virtual machine (server). The CapiServer class contains several embedded classes and lists. It is important to understand the structure of the class to take full advantage of its contents. Some of the contents are network, storage, CPU, memory, tags, parameters, and security-related instance variables and methods.

API CapiServer deployVirtualMachine( CapiTenantAccountVO tenantAccountInfo, CapiServer serverDetails) throws CapiPluginServerException;

Adapter Development This method gets the CapiServer and the TenantAccountVO. The object names are serverDetails and tenantAccountInfo, respectively.

1. Using this object, fetch the templateId.

2. From the serverDetails object, fetch the templateId.

3. From the templateId, fetch the CapiTemplate object.

There are several data structures that the code must read to create a VM. They are CapiNetworkResource, memory, numCpus, the template to be used, and so on. See the provided VCDP adapter and Java documentation for more information.

Page 27: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 27

4. Before processing the VM, this method must obtain the type of VM this template corresponds to. This means that, based on the templateId, it must fetch the imageId and the serverType variable within the image object. The possible values are:

◦ INFRA_ICS

◦ SERVICE_VSG

◦ SERVICE_CSR

◦ APPLICATION

Note

CSR Service VMs are handled differently and are explained in other sections. This section pertains specifically to Infra-ICS, VSG, and application VM instantiations.

5. After reading all variables, the method must call the cloud provider’s create VM API.

6. Poll the VM status without consuming CPU cycles. Reading the status every 20-30 seconds is sufficient.

7. If the VM status is Failed, save the vmStatus variable in the serverDetails to Failed in the return from the deployVirtualMachine method.

8. If the VM powers up successfully, fetch the private IP address assigned to the VM. Also look at the assignPublicIP field in CapiNetworkItem to determine whether or not a public IP was requested for the VM. If it was requested, do the following depending on the cloud provider API:

a. Obtain an available public IP address and program the router sitting on the network to map the public IP address to the private IP address of the VM.

b. After mapping the public IP address, set the status flag to Running.

9. Save the following variables that are populated by the adapter into the serverDetails object:

◦ vmStatus

◦ CapiNetworkItem (ID, vNICs, netmask, IP address, and so on).

◦ CapiDiskItem

◦ Hostname

◦ Cpu speed

◦ Memory

◦ lastActionPerformed (== “creating”)

10. If an exception is issued, set vmStatus to Failed, populate the CapiErrorDetails object, and persist it in the database.

Code Stub

VcdpPluginServer.java @Override public CapiServer deployVirtualMachine( CapiTenantAccountVO tenantAccountInfo, CapiServer serverModel) throws CapiPluginServerException { logger.info("template=======>" + serverModel.getTemplateId()); logger.info("Server Name=======>" + serverModel.getVmName()); try { VcdpCreateServer createServer= new VcdpCreateServer( tenantAccountInfo, serverModel); createServer.executeMethod(); } catch (Exception e) { logger.error(e); throw new CapiPluginServerException(CapiPluginErrorCodes.VM_ERROR, e.getMessage(), e.getCause()); } return serverModel; }

Page 28: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 28

VcdpCreateServer.java Public VcdpCreateServer(CapiTenantAccountVO tenantAccountInfo, CapiServer serverDetails) { this.tenantAccountInfo = tenantAccountInfo; this.serverDetails = serverDetails; } public void executeMethod() throws CapiPluginServerException, InterruptedException { VcdpVMLyfecycle api= null; try { // Cloud Specific Code Start // Cloud Specific Code End } catch (CapiPluginSessionException e) { logger.error( "CapiPluginSessionException in capi create server task.." + e.getMessage(), e); serverDetails.setVmStatus(VMStatusEnum.FAILED); throw new CapiPluginServerException( CapiPluginErrorCodes.SESSION_ERROR, e.getMessage(), e.getCause()); } catch (InterruptedException ie) { serverDetails.setVmStatus(VMStatusEnum.FAILED); throw ie; } catch (Exception e) { logger.error("Exception ..." + e.getMessage(), e); serverDetails.setVmStatus(VMStatusEnum.FAILED); throw new CapiPluginServerException( CapiPluginErrorCodes.GENERAL_ERROR, e.getMessage(), e.getCause()); } finally { } return; }

Adapter Development for CSR This section describes how to instantiate a CSR VM with Cisco ICFPP. Use this procedure to ensure that CSR VM-specific OVA parameters are passed to the CSR VM during VM instantiation.

1. Create a template from the CSR OVA.

Cisco PNSC/ICFD generates the name-and-value pairs for generating the file ovf-env.xml on Cisco ICFPP based on the CSR configuration in PNSC. This file contains the parameters for customizing the CSR configuration. The server type in the incoming create server request has the type ServerTypeEnum.SERVICE_CSR.

The name-and-value pairs are passed to Cisco ICFPP in a create server request as part of the CapiParameterResource object.

Cisco ICFPP uses the name-and-value parameters to generate an ovf-env.xml file based on a CSR XML template file. The filename must be ovf-env.xml.

2. Save the ovf-env.xml file in the folder /opt/capi-images/csr/server_uuid/.

3. Convert the XML configuration file to an ISO image by using the following Linux command:

mkisofs -relaxed-filenames -o csr_ova_config.iso ./ovf-env.xml

4. Save the resulting ISO file in the folder specified in Step 2.

5. Register the ISO image with the cloud provider user so that it can be attached to VMs for that user.

6. Start the CSR VM in a Stopped state.

7. Attach the ISO image to the CSR VM.

8. Start the CSR VM that has the attached ISO.

Page 29: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 29

destroyVirtualMachine This method deletes a virtual machine that was previously deployed.

API void destroyVirtualMachine( CapiTenantAccountVO tenantAccountInfo, String serverId) throws CapiPluginServerException;

Adapter Development 1. The method gets the serverId which is used to fetch the CapiServer object and the backendServerId.

2. If the status is returned as successful/failed, set the status variable to VMStatusEnum.DELETED.

3. In the event of a failure, update the error message to state that manual cleaning is required for the server. The SP admin can look at the Faults tab in the Cisco ICFPP GUI and manually clean up the servers.

4. Update the CapiServer vmStatus variable.

Code Stub

VcdpPluginVM.java @Override public void destroyVirtualMachine(CapiTenantAccountVO tenantAccountInfo, String serverId) throws CapiPluginServerException { try { VcdpDeleteServer deleteServer = new VcdpDeleteServer( tenantAccountInfo, serverModel); deleteServer.executeMethod(); } catch (Exception e) { logger.error(e); throw new CapiPluginServerException(CapiPluginErrorCodes.VM_ERROR, e.getMessage(), e.getCause()); } }

VcdpDeleteServer.java public class VcdpDeleteServer { private CapiLogger logger = CapiLogger.getLogger(VcdpDeleteServer.class); private CapiTenantAccountVO tenantAccountInfo; private CapiServer serverDetails; public VcdpDeleteServer(CapiTenantAccountVO tenantAccountInfo, CapiServer serverDetails) { this.serverDetails =serverDetails; this tenantAccountInfo = tenantAccountInfo; } public void executeMethod() throws CapiPluginServerException, InterruptedException { try { // Cloud Specific Code Start // Cloud Specific Code End logger.info("Server id is deleting ....." + serverDetails.getServerId()); } catch (CapiPluginServerException e) { logger.error("CapiPluginServerException in delete server " + serverDetails.getServerId() + ".. " + e.getMessage(), e); throw new CapiPluginServerException(CapiPluginErrorCodes.VM_ERROR, e.getMessage(), e.getCause()); } catch (Exception e) { logger.error(

Page 30: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 30

"Exception in delete server " + serverDetails.getServerId() + ".. " + e.getMessage(), e); throw new CapiPluginServerException( CapiPluginErrorCodes.GENERAL_ERROR, e.getMessage(), e.getCause()); } finally { serverDetails.setBackendServerId(null); serverDetails.setVmStatus(VMStatusEnum.DELETED); } return; } }

rebootVirtualMachine/ startVirtualMachine/ stopVirtualMachine

API void rebootVirtualMachine( CapiTenantAccountVO tenantAccountInfo, CapiServer server, CapiAction actionType) throws CapiPluginServerException; void startVirtualMachine( CapiTenantAccountVO tenantAccountInfo, CapiServer server, CapiAction actionType) throws CapiPluginServerException; void stopVirtualMachine( CapiTenantAccountVO tenantAccountInfo, CapiServer server, CapiAction actionType) throws CapiPluginServerException;

Adapter Development This method gets the CapiServer object as input. You can use this procedure to start, stop or reboot a virtual machine.

1. Retrieve the backendServerId for the serverId.

2. Using the backendServerId, call the cloud provider’s VM API to stop, start, or reboot the VM.

3. Poll the VM status without consuming CPU cycles. Reading the status once every 20-30 seconds is sufficient.

4. If the VM status is reported as Failed, set the vmStatus variable in serverDetails to failed.

5. If the VM was successfully powered on or off (depending on the action), fetch the private IP address assigned to the VM.

6. In the assignPublicIP field in the CapiNetworkItem determine whether or not a public IP address was requested for the VM. If a public IP address was requested, do the following depending on the cloud provider API:

a. Obtain an available public IP address and program the router on the network to map the public IP address to the private IP address of the VM.

b. After the mapping is established, set the status flag to Running.

7. Save the following into the serverDetails object:

◦ vmStatus

◦ CapiNetworkItem (such as ID, vNICs, netmask, IP address, and so on)

Page 31: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 31

8. If an exception is issued, set the vmStatus to VMStatusEnum.FAILED and populate the CapiErrorDetails object.

Code Stub

VcdpPluginVM.java @Override public void rebootVirtualMachine(CapiTenantAccountVO tenantAccountInfo, CapiServer serverModel, CapiAction actionType) throws CapiPluginServerException { try { VcdpServerAction serverAction = new VcdpServerAction(serverModel, actionType, tenantAccountInfo); serverAction.executeMethod(); } catch (CapiPluginServerException pluginServerEx) { throw pluginServerEx; } catch (Exception e) { logger.error(e, e); throw new CapiPluginServerException(CapiPluginErrorCodes.VM_ERROR, e.getMessage(), e.getCause()); } }

@Override public void startVirtualMachine(CapiTenantAccountVO tenantAccountInfo, CapiServer serverModel, CapiAction actionType) throws CapiPluginServerException { try { VcdpServerAction serverAction = new VcdpServerAction(serverModel, actionType, tenantAccountInfo); serverAction.executeMethod(); } catch (CapiPluginServerException pluginServerEx) { throw pluginServerEx; } catch (Exception e) { logger.error(e, e); throw new CapiPluginServerException(CapiPluginErrorCodes.VM_ERROR, e.getMessage(), e.getCause()); } }

@Override public void stopVirtualMachine(CapiTenantAccountVO tenantAccountInfo, CapiServer serverModel, CapiAction actionType) throws CapiPluginServerException { try { VcdpServerAction serverAction = new VcdpServerAction(serverModel, actionType, tenantAccountInfo); serverAction.executeMethod(); } catch (CapiPluginServerException pluginServerEx) { throw pluginServerEx; } catch (Exception e) { logger.error(e, e); throw new CapiPluginServerException(CapiPluginErrorCodes.VM_ERROR, e.getMessage(), e.getCause()); } }

VcdpServerAction.java public class VcdpServerAction{ private static CapiLogger logger = CapiLogger.getLogger(VcdpServerAction.class); private CapiServer serverDetails; private CapiAction actionType; private CapiTenantAccountVO tenantAccountInfo; public VcdpServerAction(CapiServer serverDetails, CapiAction actionType, CapiTenantAccountVO tenantAccountInfo) { this.actionType = actionType;

Page 32: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 32

this.serverDetails = serverDetails; this.tenantAccountInfo = tenantAccountInfo; } public void executeMethod() throws CapiPluginServerException, InterruptedException { try { // Cloud Specific Code Start // Cloud Specific Code End } catch (CapiPluginServerException e) { logger.error( "Exception in " + actionType + " " + serverDetails.getServerId() + ".. " + e.getMessage(), e); throw e; } catch (Exception e) { logger.error( "Exception in " + actionType + " " + serverDetails.getServerId() + ".. " + e.getMessage(), e); throw new CapiPluginServerException( CapiPluginErrorCodes.GENERAL_ERROR, e.getMessage(), e.getCause()); } } }

downloadVMInstance This method downloads a VM disk from the cloud provider catalog to Cisco ICFPP.

API void downloadVMInstance( CapiTenantAccountVO tenantAccountInfo, CapiServer server, String diskId, CapiVMAction vmAction) throws CapiPluginServerException;

Adapter Development This task gets the CapiServer object as input.

1. Using this method, fetch the backendServerId and diskId. The CapiVMAction is “downloading”.

All files are downloaded to the CapiCommonConstants.DOWN_IMAGE_PATH directory.

2. Check the vmStatus variable in the CapiServer object. Confirm that the virtual machine is stopped before copying the disk, and wait in this thread while you shut down the virtual machine.

3. After the virtual machine has stopped, invoke the backend cloud API to download the disk with the diskId obtained in Step 1 to the location specified in Step 1.

4. After invoking the backend API, wait in this thread while polling for the status of the download once every 30 to 60 seconds without consuming CPU cycles.

5. After the cloud backend reports that the download status is complete, update the downloadStatus variable in the CapiDiskItem object to DownloadStatus.COMPLETED.

6. The cloud adapter can choose to download either one disk at a time or download all the disks at the same time if that makes the download efficient. But respective downloadStatus fields have to be set to COMPLETED.

7. If an exception is issued, set the vmStatus to “VMStatusEnum.FAILED", populate the CapiErrorDetails object, and persist it in the database.

Page 33: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 33

listVirtualMachines

API CapiServer listVirtualMachines( CapiTenantAccountVO tenantAccountInfo, CapiServer server) throws CapiPluginServerException;

Adapter Development

Not implemented in this release.

getVirtualMachines

API CapiServer getVirtualMachines( CapiTenantAccountVO tenantAccountInfo, CapiServer server) throws CapiPluginServerException;

Adapter Development

This API is required for the Cisco ICFPP platform to provide accurate information regarding the system in case of any status change that occurs in the cloud infrastructure VM.

For example, if a VM becomes unreachable or a new disk is inserted, Cisco ICFPP cannot discover this information if this API is not implemented.

To retrieve such information Cisco ICFPP uses an inventory process that periodically queries the backend through this API to fetch the current VM state. The contents of the CapiServer class are similar to deployVirtualMachine.

updateVirtualMachine This method updates a virtual machine (server). The CapiServer class contains several embedded classes and lists. It is important to understand the structure of the class to take full advantage of its contents. Some of the contents are network, storage, CPU, memory, tags, parameters and methods. It also contains the updated security rule.

API CapiServer updateVirtualMachine( CapiTenantAccountVO tenantAccountInfo, CapiServer serverDetails) throws CapiPluginServerException;

Adapter Development This method gets the CapiServer and the TenantAccountVO. The object names are serverDetails and tenantAccountInfo, respectively.

1. From the serverDetails object, fetch the serverBackendId.

2. From the serverBackendId, fetch the VApp object.

3. From VApp object fetch the child Vm and other information.

4. For fetched private and public IP addresses, old rules are deleted and new rules are created.

5. Update the CapiServer vmStatus variable.

Code Stub

VcdpPluginVm.java @Override public CapiServer updateVirtualMachine(final CapiTenantAccountVO tenantAccountInfo, final CapiServer server) throws Exception {

Page 34: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 34

logger.info("Updating Server Name=======>" + server.getVmName()); try { final VcdpUpdateServerAction updateServer = new VcdpUpdateServerAction(tenantAccountInfo, server); updateServer.executeAction(); } catch (final Exception e) { logger.error(e, e); throw new CapiPluginServerException(CapiPluginErrorCodes.VM_ERROR, e.getMessage(), e.getCause()); } return server; }

VcdpUpdateServerAction.java

public class VcdpUpdateServerAction { private static CapiLogger logger = CapiLogger.getLogger(VcdpUpdateServerAction.class); private CapiTenantAccountVO tenantAccountInfo; private CapiServer serverDetails; public VcdpUpdateServerAction(CapiTenantAccountVO tenantAccountInfo, CapiServer serverDetails) { this.tenantAccountInfo = tenantAccountInfo; this.serverDetails = serverDetails; } public void executeAction() throws CapiPluginServerException, InterruptedException { VcdpVMLyfecycle vcdpvmUtils= null; VcdpApi api = null; VM vmInstance = null; Vapp vapp = null; String privIpAddr = null; String publicIp = null; try { api = new VcdpApi(VcdpSession.getVcdpSession(tenantAccountInfo)); vcdpvmUtils = new VcdpVMLyfecycle( VcdpSession.getVcdpSession(tenantAccountInfo)); vapp = vcdpvmUtils.getVapp(serverDetails.getBackendServerId()); vmInstance = vapp.getChildrenVms().get(0); String accName = tenantAccountInfo.getAccountVirtualAccountName(); String vpcId = api.getVpcBackendId(accName, serverDetails.getProviderId()); String networkName = vcdpvmUtils.getNetworkName(accName, serverDetails); List<IpRangeType> ipRangeList = api.getPrivateIpRangeList(vpcId, networkName); for(IpRangeType ipRange : ipRangeList) { privIpAddr = vcdpvmUtils.getPrivateIPAddress(vmInstance, networkName, ipRange); } if (serverDetails.getNetworkList() != null) { for (CapiNetworkResource capiNetworkResource : serverDetails .getNetworkList()) { if (capiNetworkResource.getVnicItem() != null) for (CapiNetworkItem capiNetworkItem : capiNetworkResource .getVnicItem()) { publicIp = capiNetworkItem.getPublicIpAddress(); break; } } } boolean isSecurityRulesApplied = api.executeSecurityRulesTask( "UpdatingSecurityRules", privIpAddr, publicIp, vpcId, networkName,

Page 35: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 35

tenantAccountInfo.getAccountVirtualAccountName(), api, serverDetails); if (!isSecurityRulesApplied) { if (!serverDetails.getVmStatus().equals(VMStatusEnum.FAILED)) { serverDetails.setVmStatus(VMStatusEnum.FAILED); throw new CapiPluginServerException(CapiPluginErrorCodes.NETWORK_ERROR, "Not able to update Security rules"); } return; } logger.info("Securtiy Rule updated successfully."); serverDetails.setVmStatus(VMStatusEnum.RUNNING); logger.info("updating Server status to Running: " + serverDetails.getServerId()); } catch (VCloudException e) { String vCloudErrMsg = ""; if(e.getVcloudError() != null){ vCloudErrMsg = e.getVcloudError().getMessage(); } logger.error("VCloudException ..." + e.getMessage() + ".." + vCloudErrMsg, e); serverDetails.setVmStatus(VMStatusEnum.FAILED); throw new CapiPluginServerException(CapiPluginErrorCodes.VM_ERROR, e.getMessage() + ".." + vCloudErrMsg, e.getCause()); } catch (CapiPluginSessionException e) { logger.error( "CapiPluginSessionException in capi create server task.." + e.getMessage(), e); serverDetails.setVmStatus(VMStatusEnum.FAILED); throw new CapiPluginServerException( CapiPluginErrorCodes.SESSION_ERROR, e.getMessage(), e.getCause()); } catch (InterruptedException ie) { serverDetails.setVmStatus(VMStatusEnum.FAILED); throw ie; } catch (Exception e) { logger.error("Exception ..." + e.getMessage(), e); serverDetails.setVmStatus(VMStatusEnum.FAILED); throw new CapiPluginServerException( CapiPluginErrorCodes.GENERAL_ERROR, e.getMessage(), e.getCause()); } finally { } return; } }

updateVirtualMachines

API CapiServer uodateVirtualMachines( CapiTenantAccountVO tenantAccountInfo, CapiServer server) throws CapiPluginServerException;

Adapter Development

Not implemented in this release.

CapiPluginVpcIf This interface defines VPC-related operations that must be implemented by the adapters. It is important to understand that, in the context of Cisco ICFPP, VPC is an abstraction for storing information related to networking-related objects in the backend provider. A VPC object usually represents an isolated entity that can contain one or more isolated networks. You program a VPC object by using the following APIs.

Page 36: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 36

For example, for a provider such as VMware vCloud Director, the VPC maps to an orgVdc and the networks map to orgNetworks. For CloudStack, the VPC object is used to store the provider networks that are created by the user.

listProviderVPC This API queries the list of provider VPCs for a given tenant.

API CapiProviderVpcDetailsList listProviderVPC( CapiTenantAccountVO tenantAccountInfo) throws CapiPluginVpcException;

Adapter Development

1. The adapter is provided with the tenant object.

2. The adapter queries the backend cloud provider for the details expected in the CapiProviderVpcDetailsList object. These details are the networks associated with the location, and so on.

3. If no VPC object exists, the adapter should:

a. Issue the VPC exception CapiPluginVpcException.

b. Update CAPI error code PROVIDER_VPC_NOT_EXISTS.

c. Populate the error information text so that it can be passed to the caller.

Code Stub @Override public CapiProviderVpcDetailsList listProviderVPC( CapiTenantAccountVO tenantAccountInfo) throws CapiPluginVpcException { logger.setCurrentAppenderId(tenantAccountInfo .getAccountVirtualAccountName()); CapiProviderVpcDetailsList vpcs = null; try { vpcs = VPCUtils.getVPCs(tenantAccountInfo.getAccountVirtualAccountName()); if (vpcs == null) { throw new CapiPluginVpcException( CapiPluginErrorCodes.PROVIDER_VPC_NOT_EXISTS, "There are no configured VPC for this account : " + tenantAccountInfo.getAccountVirtualAccountName(), null); } } catch (Exception e) { logger.error("There are no configured VPC for this account : " + tenantAccountInfo.getAccountVirtualAccountName(), e); } return vpcs; }

listVpcById This API queries details for a VPC with a specific ID.

API CapiProviderVpcDetails listVpcById( CapiTenantAccountVO tenantAccountInfo, String vpcId) throws CapiPluginVpcException;

Adapter Development 1. The input VPC string contains the vpcId string.

Page 37: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 37

2. The adapter queries the VPC details table CapiProviderVpcDetailsList to query by vpcId.

It returns the VPC object CapiProviderVpcDetails upon successful retrieval of the details.

3. If no VPC object exists, the adapter should:

a. Issue the VPC exception CapiPluginVpcException.

b. Update CAPI error code PROVIDER_VPC_NOT_EXISTS.

c. Populate the error information text so that it can be passed to the caller.

createVpc This API creates a VPC and is required for providers whose users create networking-related objects. In Cisco ICFPP, a VPC object is a container for networking-related objects that are created in the provider. The adapter must create the corresponding object in the provider and set the backend ID for it. It should also set other fields, such as the time of creation and so on.

The CloudStack adapter does not currently use a backend VPC object. Instead, the adapter creates a backend ID as a placeholder and places it in the VPC object.

API CapiProviderVpcDetails createVpc( CapiTenantAccountVO tenantAccountInfo, CapiProviderVpcDetails vpcModel) throws CapiPluginVpcException;

Adapter Development

The input VPC object contains the information required to create a VPC, such as the VPC name. To create a valid VPC object:

1. On the cloud provider side, create a VPC or similar object, as needed.

2. Update the backendId variable in the CapiProviderVpcDetails object.

3. Return the CapiProviderVpcDetails object with all populated values.

4. In the event of an error, the adapter:

◦ Issues a CapiPluginVpcException.

◦ Updates the CAPI error code VPC_ERROR.

◦ Populates error information text, so that it can be passed to the caller.

deleteVpc This method deletes a VPC and its associated networks.

API boolean deleteVpc( CapiTenantAccountVO tenantAccountInfo, String vpcId) throws CapiPluginVpcException;

Adapter Development 1. The input VPC string contains the vpcId string.

2. The adapter queries the VPC details table CapiProviderVpcDetailsList to query by vpcId. It returns the VPC object CapiProviderVpcDetails on success.

3. If no VPC object exists, the adapter needs to:

a. Issue the VPC exception CapiPluginVpcException.

b. Update the CAPI error code PROVIDER_VPC_NOT_EXISTS.

c. Populate the error information text, so that it can be passed to the caller.

Page 38: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 38

4. The adapter needs to do the following:

a. Iterate through all the VPC network objects CapiProviderVpcNetwork for the VPC.

b. Delete both the resources from the provider and the local network objects by using the deleteVpcNetwork handler.

c. Delete the VPC object CapiProviderVpcDetails from the VPC table CapiProviderVpcDetailsList.

Code Stub @Override public boolean deleteVpc(CapiTenantAccountVO tenantAccountInfo, String vpcId) throws CapiPluginVpcException { logger.error("Received delete request for VPC: " + vpcId); boolean flag = false; try { // Cloud Specific Code Start // Cloud Specific Code End } } catch (CapiPluginVpcException e) { logger.info("deleteVpc exception:", e); throw e; } catch (Exception e) { logger.error("Error while deleting VPC, VPCId: " + vpcId, e); throw new CapiPluginVpcException( CapiPluginErrorCodes.PROVIDER_VPC_NOT_EXISTS, "Provider VPC not available, VPCId: " + vpcId, null); } return flag; }

listVpcNetworkById Given a vpcId and networkId, this method retrieves the CapiProviderVpcNetwork object from the database.

API CapiProviderVpcNetwork listVpcNetworkById( CapiTenantAccountVO tenantAccountInfo, String vpcId, String networkId) throws CapiPluginVpcException;

Adapter Development 1. Retrieve the backendId from the database by a query based on vpcId and networkId.

2. Use the backendId to contact the cloud provider VPC API and fetch the VPC network information.

3. Populate and return CapiProviderVpcNetwork with the fields populated accordingly.

Code Stub @Override public CapiProviderVpcDetails listVpcById( CapiTenantAccountVO tenantAccountInfo, String vpcId) throws CapiPluginVpcException { logger.setCurrentAppenderId(tenantAccountInfo .getAccountVirtualAccountName() + ":" + vpcId); logger.info("listVpcById: " + vpcId); try { // Cloud Specific Code Start // Cloud Specific Code End CapiProviderVpcDetailsList vpcs = VPCUtils

Page 39: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 39

.getVPCs(tenantAccountInfo.getAccountVirtualAccountName()); for (CapiProviderVpcDetails item : vpcs.getProviderVpcList()) { if (item.getVpcId().equals(vpcId)) { return item; } } throw new CapiPluginVpcException( CapiPluginErrorCodes.PROVIDER_VPC_NOT_EXISTS, "Provider VPC not available", null); } catch (CapiPluginVpcException e) { logger.info("listVpcById exception:" + vpcId, e); throw e; } catch (Exception e) { logger.error("listVpcById exception:" + vpcId, e); throw new CapiPluginVpcException( CapiPluginErrorCodes.GENERAL_ERROR, "Error while listing vpc : " + vpcId); } }

createVpcNetwork This method creates a new isolated network.

API CapiProviderVpcNetwork createVpcNetwork( CapiTenantAccountVO tenantAccountInfo, CapiProviderVpcNetwork networkModel, CapiProviderVpcDetails addToVpc) throws CapiPluginVpcException;

Adapter Development The input VPC object contains the information required to create a VPC, such as the VPC name, CIDR block, and so on. To create a valid VPC object:

1. On the cloud provider side, create an isolated network with the information provided. Mostly the CIDR information is used from the configuration and provider specific network creation APIs are used to create a private/isolated network.

2. After the network is created:

a. Populate the CapiProviderVpcNetwork with the backendId variable with the ID received from the cloud platform.

b. Populate the vpcId for the CapiProviderVpcNetwork object with the vpcId from the VPC object.

3. If an error occurs, the adapter needs to:

a. Issue the VPC exception CapiPluginVpcException.

b. Update the CAPI error code INVALID_INPUT.

c. Populate the error information text so that it can be passed to the caller.

Code Stub @Override public CapiProviderVpcDetails createVpc( CapiTenantAccountVO tenantAccountInfo, CapiProviderVpcDetails vpcModel) throws CapiPluginVpcException { // Cloud Specific Code Start // Cloud Specific Code End vpcModel.setBackendid(CAPIUtils.generateUUID());

Page 40: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 40

logger.info("ProviderVpc created.. " + vpcModel); return vpcModel; }

deleteVpcNetwork This method deletes a previously created isolated network.

API boolean deleteVpcNetwork( CapiTenantAccountVO tenantAccountInfo, String vpcId, String networkId) throws CapiPluginVpcException;

Adapter Development 1. Use the vcpId to retrieve the CapiProviderVpc object.

2. From the CapiProviderVpc object, retrieve the CapiProviderVpcNetwork that has the specified networkId.

3. From the CapiProviderVpcNetwork, fetch the backendid to contact the cloud provider VPC API and delete the VPC Network

4. Update the status of the operation to ProviderVpcEnum.DELETED.

5. Return true or false accordingly.

6. If an error occurs, the adapter needs to:

a. Issue the VPC exception CapiPluginVpcException.

b. Update the CAPI error code PROVIDER_VPC_NETWORK_NOT_EXISTS.

c. Populate the error information text, so that it can be passed to the caller.

Code Stub @Override public boolean deleteVpcNetwork(CapiTenantAccountVO tenantAccountInfo, String vpcId, String networkId) throws CapiPluginVpcException { try { // Cloud Specific Code Start // Cloud Specific Code End return Boolean.TRUE; } catch (CapiPluginVpcException e) { logger.info("Error in deleting vpc network:" + networkId, e); throw e; } catch (Exception e) { } }

Page 41: Cisco Intercloud Fabric Provider Platform Adapter …...Page 1 Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1 2015-11-13 Contents INTRODUCING THE

Page 41

Abbreviations and Acronyms

Cisco ICFD Cisco Intercloud Fabric Director

Cisco ICFPP Cisco Intercloud Fabric Provider Platform

CSR Cisco Cloud Services Router 1000V

ICF Cisco Intercloud Fabric

ICS Intercloud Fabric Switch

ICX Intercloud Fabric Extender

PNSC Cisco Prime Network Services Controller

SP Service Provider

VCD VMware vCloud Director

VSG Cisco Virtual Security Gateway

References Cisco Intercloud Fabric Provider Platform Installation Guide

Cisco Intercloud Fabric Provider Platform Administrator Guide

Obtaining Documentation, Obtaining Support, and Security Guidelines For information on obtaining documentation, obtaining support, providing documentation feedback, security guidelines, and also recommended aliases and general Cisco documents, see the monthly What's New in Cisco Product Documentation, which also lists all new and revised Cisco technical documentation, at:

http://www.cisco.com/c/en/us/td/docs/general/whatsnew/whatsnew.html

Cisco and the Cisco logo are trademarks or registered trademarks of Cisco and/or its affiliates in the U.S. and other countries. To view a list of Cisco trademarks, go to this URL: www.cisco.com/go/trademarks. Third-party trademarks mentioned are the property of their respective owners. The use of the word partner does not imply a partnership relationship between Cisco and any other company. (1110R)

Any Internet Protocol (IP) addresses and phone numbers used in this document are not intended to be actual addresses and phone numbers. Any examples, command display output, network topology diagrams, and other figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses or phone numbers in illustrative content is unintentional and coincidental.

Any Internet Protocol (IP) addresses used in this document are not intended to be actual addresses. Any examples, command display output, and figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses in illustrative content is unintentional and coincidental.

Cisco Intercloud Fabric Provider Platform Adapter Developer Guide, Release 2.3.1

© 2015 Cisco Systems, Inc. All rights reserved.