Package: ciscodnacapphosting
ciscodnacapphostingDisclaimerThis solution leverages currently unpublished Cisco DNA Center APIs (as of DATE)Do not use in productionciscodnacapphostingis a Python SDK for Cisco DNA Center Application Hosting API.It uses local docker environment to pull and save docker images.PrerequisitesCisco DNA CenterSupported release: 2.1.2+Cisco Catalyst 9000 Switches/APsPythonVersion: 3.8+Import Docker images to Cisco DNA Center application hostingIf you develop your own container images, then you can use this tool to automatically upload or update those container to any Cisco DNA Center Application Hosting Repository (using the Platform API).It's possible to use this tool together with your CI/CD by adding these stepspip install ciscodnacapphostingciscodnacapphosting upgrade --id 71257f4a-1f68-43a5-85f0-3347137107bb --tag 1.31 --file busybox-1.32.tar --categories IOTCreating containers on your own workstation/development environment?No worries, just install this tool throughpipand upload your container directly to Cisco DNA Center.This code is also shared on Cisco DevNet Code Exchange -cisco-dnac-app-hosting-import-docker-imagesApplication HostingApplication Hosting on Catalyst 9000 series switchesRelated SandboxIOS XE on Catalyst 9000 16.12 CodeLinks to DevNet Learning LabsApplication Hosting on IOS XE Learning LabDemociscodnacapphostingapp--imagebusybox
GetApp(busybox)data:
-_links:configuration:href:/api/v1/appmgr/apps/71257f4a-1f68-43a5-85f0-3347137107bb/1.32/configicon:href:nullimages:href:/api/v1/appmgr/apps/71257f4a-1f68-43a5-85f0-3347137107bb/1.32/imagespackages:href:/api/v1/appmgr/apps/71257f4a-1f68-43a5-85f0-3347137107bb/1.32/packagesself:href:/api/v1/appmgr/apps/71257f4a-1f68-43a5-85f0-3347137107bb/1.32appId:71257f4a-1f68-43a5-85f0-3347137107bbappType:dockercategories:-IOTclassification:APPcpuUsage:0description:contentType:textdescriptor:app:cpuarch:x86_64env:PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binresources:network:-interface-name:eth0ports:{}profile:c1.largestartup:rootfs:fogd_upload_8699102144278681062.tartarget:-shtype:dockerdescriptor-schema-version:'2.2'info:name:busyboxversion:'1.32'icon:caption:iconhref:nullimages:[]lastUpdatedDate:1604930943165localAppId:71257f4a-1f68-43a5-85f0-3347137107bbmemoryUsage:0name:busyboxpackages:-href:/api/v1/appmgr/apps/71257f4a-1f68-43a5-85f0-3347137107bb/1.32/packages/b55be543-b969-415b-b47d-da95df834a5fprofileNeeded:c1.largeproperties:[]published:truereleaseNotes:contentType:textservices:[]signed:falseversion:'1.32'ciscodnacapphostingdocker--downloadalpine:3.12.0--save
Downloadcompleted(alpine)-savedasalpine-3.12.0.tarciscodnacapphostingupload--filealpine-3.12.0.tar--categoriesIOT
UploadApp(alpine-3.12.0.tar)-IOT
NewAppId(1a12b3d9-22d5-40ee-8aff-e2ccfb79c59f)alpine:3.12.0-IOTInstallationUse the package managerpipto installciscodnacapphosting.pipinstallciscodnacapphostingUsageConfiguration can be stored in config.json in JSON format.{
    "dnac": {
        "hostname": "dnac.example.tld",
        "username": "superadmin",
        "password": "superpassword",
        "secure": true
    }
}(secure parameter is for HTTPS verification)The configuration can be encoded as base64 string.ewogICAgImRuYWMiOiB7CiAgICAgICAgImhvc3RuYW1lIjogImRuYWMuZXhhbXBsZS50bGQiLAogICAgICAgICJ1c2VybmFtZSI6ICJzdXBlcmFkbWluIiwKICAgICAgICAicGFzc3dvcmQiOiAic3VwZXJwYXNzd29yZCIsCiAgICAgICAgInNlY3VyZSI6IHRydWUKICAgIH0KfQ==If using base64 encoded, then it's possible to set EnvironmentDNAC_CONFIGexportDNAC_CONFIG=ewogICAgImRuYWMiOiB7CiAgICAgICAgImhvc3RuYW1lIjogImRuYWMuZXhhbXBsZS50bGQiLAogICAgICAgICJ1c2VybmFtZSI6ICJzdXBlcmFkbWluIiwKICAgICAgICAicGFzc3dvcmQiOiAic3VwZXJwYXNzd29yZCIsCiAgICAgICAgInNlY3VyZSI6IHRydWUKICAgIH0KfQ==CLIciscodnacapphostingconfig--hostnamednac.example.tld--usernamesuperadmin--passwordsuperpassword--secure--encode

ciscodnacapphostingapp
ciscodnacapphostingapp--imagebusybox

ciscodnacapphostingdocker
ciscodnacapphostingdocker--downloadbusybox:1.31--save

ciscodnacapphostingupload--filebusybox-1.31.tar--categoriesIOT

ciscodnacapphostingupgrade--id71257f4a-1f68-43a5-85f0-3347137107bb--tag1.31--filebusybox-1.32.tar--categoriesIOT

ciscodnacapphostingupdate--id71257f4a-1f68-43a5-85f0-3347137107bb--categoriesSecurity

ciscodnacapphostingdelete--id71257f4a-1f68-43a5-85f0-3347137107bb--tag1.31Helpciscodnacapphosting--help
Usage:ciscodnacapphosting[OPTIONS]COMMAND1[ARGS]...[COMMAND2[ARGS]...]...

Options:--versionShowtheversionandexit.--helpShowthismessageandexit.

Commands:appconfigdeletedockerupdateupgradeuploadwhoamiInclude in Pythonimportciscodnacapphostingdnac_app=ciscodnacapphosting.Api()download=dnac_app.docker.download(image="busybox",tag="1.31")save=dnac_app.docker.save(image=download["image"],tag=download["tag"])upload=dnac_app.upload(tar=save["filename"],categories="IOT")upgrade=dnac_app.upgrade(appId=appId,tag=tag,tar="busybox-1.32.tar",categories="IOT")update=dnac_app.update(appId="46e54562-83c9-4183-8632-c597c8cc5a2b",categories="IOT")delete=dnac_app.delete(appId=appId,tag=tag)(More examples inexamples/folder)Dockerdockerrun-it--rm--privileged-eDNAC_CONFIG=ewogICAgImRuYWMiOiB7CiAgICAgICAgImhvc3RuYW1lIjogImRuYWMuZXhhbXBsZS50bGQiLAogICAgICAgICJ1c2VybmFtZSI6ICJzdXBlcmFkbWluIiwKICAgICAgICAicGFzc3dvcmQiOiAic3VwZXJwYXNzd29yZCIsCiAgICAgICAgInNlY3VyZSI6IHRydWUKICAgIH0KfQ==robertcsapo/ciscodnacapphosting/# ciscodnacapphosting whoamiConfig:{"dnac":{"hostname":"dnac.example.tld","username":"superadmin","password":"superpassword","secure":true}}/#/# ciscodnacapphosting app --image alpineGetApp(alpine)data:
-_links:configuration:href:/api/v1/appmgr/apps/1a12b3d9-22d5-40ee-8aff-e2ccfb79c59f/3.12.0/configicon:href:nullimages:href:/api/v1/appmgr/apps/1a12b3d9-22d5-40ee-8aff-e2ccfb79c59f/3.12.0/imagespackages:href:/api/v1/appmgr/apps/1a12b3d9-22d5-40ee-8aff-e2ccfb79c59f/3.12.0/packagesself:href:/api/v1/appmgr/apps/1a12b3d9-22d5-40ee-8aff-e2ccfb79c59f/3.12.0appId:1a12b3d9-22d5-40ee-8aff-e2ccfb79c59fappType:dockercategories:-IOTclassification:APPcpuUsage:0creationDate:1604950418368description:contentType:textdescriptor:app:cpuarch:x86_64env:PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binresources:network:-interface-name:eth0ports:{}profile:c1.largestartup:rootfs:fogd_upload_7626901429300115262.tartarget:-/bin/shtype:dockerdescriptor-schema-version:'2.2'info:name:alpineversion:3.12.0icon:caption:iconhref:nullimages:[]localAppId:1a12b3d9-22d5-40ee-8aff-e2ccfb79c59fmemoryUsage:0name:alpinepackages:-href:/api/v1/appmgr/apps/1a12b3d9-22d5-40ee-8aff-e2ccfb79c59f/3.12.0/packages/10d8de54-9c21-4f65-bda1-540ef5e4e1acprofileNeeded:c1.largeproperties:[]published:truereleaseNotes:contentType:textservices:[]signed:falseversion:3.12.0Technologies & Frameworks UsedCisco Products & Services:Cisco DNA Center Platform APIDockerdockerpyAuthors & MaintainersRobert Csaporcsapo@cisco.comContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.LicenseThis project is licensed to you under the terms of theCisco Sample
Code License.