Services Module

This module provides an interface to uploading L4-7 device packages to the controller. Refer to the Developing L4-L7 Device Packages document for more information on creating device packages.

Example:

session = cobra.mit.session.LoginSession('https://apic', 'admin',
                                         'password', secure=False)
moDir = cobra.mit.access.MoDirectory(session)
moDir.login()

packageUpload = cobra.services.UploadPackage('asa-device-pkg.zip')
response = moDir.commit(packageUpload)

The following sections describe the classes in the services module.

UploadPackage

Class for uploading L4-L7 device packages to APIC

class cobra.services.UploadPackage(devicePackagePath, validate=False)[source]

Upload L4-L7 device packages to APIC.

data

A string containing the payload for this request in JSON format - readonly

Type:str
devicePackagePath

Path to the device package on the local file system. No Path verification is performed, so any errors accessing the specified file will be raised directly to the calling function.

Note

If validation is requested, the device package contents are verified to contain a device specification XML/JSON document

Type:str
options

The HTTP request query string for this object - readonly

Type:str
id

An internal troubleshooting value useful for tracing the processing of a request within the cluster

Type:None or int
uriBase

The base URI used to build the URL for queries and requests

Type:str
__init__(devicePackagePath, validate=False)[source]

Upload a device package to an APIC.

cobra.mit.access.MoDirectory.commit() is required to commit the upload.

Parameters:
  • devicePackagePath (str) – Path to the device package on the local file system
  • validate (bool, optional) – If true, the device package will be validated locally before attempting to upload. The default is False.
data

Get the data for the request.

devicePackagePath

Get the device package path.

Returns:The path to the device package.
Return type:str
getUrl(session)[source]

Get the URL for this request, includes all options as well.

Parameters:session (cobra.mit.session.AbstractSession) – The session to use for this query.
Returns:A string containing the request url
Return type:str
requestargs(session)[source]

Get the request arguments for this object.

Parameters:session (cobra.mit.session.AbstractSession) – The session to be used to build the the requestarguments
Returns:A dictionary containing the arguments
Return type:dict