Managing Cisco UCS with the Python SDK

Similar documents
Cisco UCS Agentless Configuration Management Ansible or Microsoft DSC

Cisco UCS PowerTool Deploy at Scale

NXOS in the Real World Using NX-API REST

DEVNET Introduction to Git. Ashley Roach Principal Engineer Evangelist

NetDevOps Style Configuration Management for the Network

Cisco Spark Messaging APIs - Integration Platforms as a Service Real World Use-Cases

Your API Toolbelt Tools and techniques for testing, monitoring, and troubleshooting REST API requests

CloudCenter for Developers

Hands-On with IoT Standards & Protocols

Coding Getting Started with Python

Git, Atom, virtualenv, oh my! Learn about dev tools to live by!

Finesse APIs: Getting started with the REST APIs and XMPP events

Hands On Exploration of NETCONF and YANG

DevNet Workshop-Hands-on with CloudCenter and Jenkins

Cisco Spark Widgets Technical drill down

Get Hands On With DNA Center APIs for Managing Intent

WORKSHOP: from Zero to a Network Application with #golang

An Introduction to Developing for Cisco Kinetic

An Introduction to Monitoring Encrypted Network Traffic with "Joy"

Introduction to OpenConfig

Magical Chatbots with Cisco Spark and IBM Watson

Automation and Programmability using Cisco Open NXOS and DevOps Tools

TRex Realistic Traffic Generator

Automation with Meraki Provisioning API

Creating a custom gadget using the Finesse JavaScript Library API

Coding Intro to APIs and REST

Empower your testing with Cisco Test Automation Solution Featuring pyats & Genie

BGP in the Enterprise for Fun and (fake) Profit: A Hands-On Lab

2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Privacy Requirements Scoping

European DevNet Pros Panel

Hybrid Cloud Automation using Cisco CloudCenter API

Getting Started with OpenStack

Spark SDK Video - Overview and Coding Demo

Deploying Cloud-Agnostic Applications with Cisco CloudCenter

Cisco SD-Access Hands-on Lab

Who wants to be a millionaire? A class in creating your own cryptocurrency

Cisco Spark. Questions? Use Cisco Spark to communicate with the speaker after the session. How

Managing The Digital Network Workforce Transformation

NSO in Brownfield: Fully Automated One-Click Reconciliation

Tetration Hands-on Lab from Deployment to Operations Support

Tour the latest Cisco Spark API features

Insights into your WLC with Wireless Streaming Telemetry

Kuber-what?! Learn about Kubernetes

Cisco Container Platform

Routing Underlay and NFV Automation with DNA Center

PnP Deep Dive Hands-on with APIC-EM and Prime Infrastructure

Consuming Model-Driven Telemetry

DevOps CICD for VNF a NetOps Approach

Cisco WAN Automation Engine (WAE) Network Programmability with Segment Routing

Cisco Firepower NGIPS Tuning and Best Practices

Serviceability of SD-WAN

Cisco Enterprise Agreement

Cisco VIRL. The Swiss-Army Knife of Network Simulators. Simon Knight, Software Engineer Brian Daugherty, Technical Leader.

Cisco DNA Center and Italtel Netwrapper Evolution: Network and Applications come together

Cisco UCS Director and ACI Advanced Deployment Lab

Customer s journey into the private cloud with Cisco Enterprise Cloud Suite

Cloud Mobility: Meraki Wireless & EMM

BRKCOC-2399 Inside Cisco IT: Integrating Spark with existing large deployments

The Transformation of Media & Broadcast Video Production to a Professional Media Network

DevNet Workshop-Learning Cisco platform Exchange Grid (pxgrid) Dynamic Topics

Introduction to Cisco IoT Tools for Developers IoT 101

Cloud-Ready WAN For IAAS & SaaS With Cisco s Next- Gen SD-WAN

Getting Started With Containers

Simplifying Collaboration Deployments with Prime Collaboration

UCS Management Deep Dive

Orange: Cisco & Orange: a human touch for a digital experience

Catalyst 9K High Availability Lab

VXLAN EVPN Fabric and automation using Ansible

Threat Centric Network Security

ICE / TURN / STUN Tutorial

How to be a Network Engineer in a Programmable Age Cisco DevNet Webinar Series

NetBrain Technologies: Achieving Agile Network Operations: How Automation Can Improve Visibility Across Hybrid Infrastructures

Introducing Cisco Network Assurance Engine

Internet of Things Field Network Director

Real time Location Services Overview and Use cases

UCS Management Architecture Deep Dive

Enterprise Recording and Live Streaming Architecture with VBrick

PSOACI Why ACI: An overview and a customer (BBVA) perspective. Technology Officer DC EMEAR Cisco

Migrating Applications with CloudCenter

Next Generation Mobile Collaboration

Cisco pxgrid: A New Architecture for Security Platform Integration

NetDevOps for the Network Dude How to get started with API's, Ansible and Python

Ipswitch: The New way of Network Monitoring and how to provide managed services to its customers

Introduction to Python Network Programming for Network Architects and Engineers

Contiv installation and integration with ACI

Building Applications with IOx

Automating Cisco Spark with Cloud Integration Cisco DevNet Webinar Series

Machine Learning with Python

Inside Cisco IT: Automated end user services via Cisco Prime Service Catalog, Process Orchestrator and AppDynamics

Delivering HCI with VMware vsan and Cisco UCS

DevNet Technical Breakout: Introduction to ACI Programming and APIs.

Cisco SD-Access Building the Routed Underlay

Radware: Anatomy of an IoT Botnet and Economics of Defense

Is your IT Infrastructure Ready for Machine Learning & Artificial Intelligence?

Using Cisco pxgrid for Security Platform Integration

ucsmsdk Documentation

Cisco Integrated System for Microsoft Azure Stack

AlgoSec: How to Secure and Automate Your Heterogeneous Cisco Environment

Writing your first Web Data Connector

Transcription:

DEVNET-2060 Managing Cisco UCS with the Python SDK John McDonough, Technical Leader Developer Evangelist

Cisco Spark How Questions? Use Cisco Spark to communicate with the speaker after the session 1. Find this session in the Cisco Live Mobile App 2. Click Join the Discussion 3. Install Spark or go directly to the space 4. Enter messages/questions in the space cs.co/ciscolivebot#devnet-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Agenda DEVNET 2060 Managing Cisco UCS with the Python SDK Installation Overview Connect / Query / Filter / Dump XML Get Help / Variable Inspection / Meta Data Configure / Transactions Compare / Sync / Code Generation Conclusion

UCS Python SDK

Installation

Cisco UCS Python SDKs - Install Hosted on Github UCS Manager SDK Source https://github.com/ciscoucs/ucsmsdk Samples https://github.com/ciscoucs/ucsmsdk_samples Documents https://ciscoucs.github.io/ucsmsdk_docs UCS IMC SDK Source https://github.com/ciscoucs/imcsdk Documents https://ciscoucs.github.io/imcsdk_docs UCS Central Python SDK Source https://github.com/ciscoucs/ucscentralsdk DEVNET-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 7

Cisco UCS Python SDKs - Install Install Python 2.7.X or 3.5.X / 3.6.X Or both UCS Python SDKs can coexist! pip Preferred Installer Program (package manager) Installs latest Release from https://pypi.python.org/pypi pip install ucsmsdk git Install from github.com works for ucsmsdk, imcsdk, ucscentralsdk Installs latest SDK source code from https://github.com/ciscoucs/ucsmsdk git clone https://github.com/ciscoucs/ucsmsdk.git cd ucsmsdk C:\Python27\python.exe.\setup.py install Python 2 'C:\Program Files\Python35\python.exe'.\setup.py install Python 3 DEVNET-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 8

Connect / Query / Filter / Dump XML

Connect / Query / Filter / Dump XML from ucsmsdk.ucshandle import UcsHandle handle = UcsHandle("198.18.133.91","admin","password") handle.login() handle.cookie blades = handle.query_classid("computeblade") len(blades) for blade in blades: print blade.dn, blade.serial, blade.model handle.set_dump_xml() blades = handle.query_classid("computeblade") handle.unset_dump_xml() DEVNET-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 10

Connect / Query / Filter / Dump XML filter_exp='(model,"ucsb-b200-m4")' blades = handle.query_classid("computeblade",filter_str=filter_exp) len(blades) filter_exp='(model,"ucsb-b200-m4", type="eq")' blades = handle.query_classid("computeblade",filter_str=filter_exp) len(blades) filter_exp='(model,"ucsb-b200-m4", flag="i")' for blade in blades: print blade.dn blade_by_dn = handle.query_dn("sys/chassis-1/blade-2") print blade_by_dn DEVNET-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 11

Connect / Query / Filter / Dump XML blades_and_chassis = handle.query_classids("computeblade","equipmentchassis") print blades_and_chassis print blades_and_chassis['computeblade'] for blade in blades_and_chassis['computeblade']: print blade.dn for chassis in blades_and_chassis['equipmentchassis']: print chassis.dn blade_and_chassis = handle.query_dns("sys/chassis-1/blade-1","sys/chassis-1") print blade_and_chassis print blade_and_chassis['sys/chassis-1/blade-1'].dn handle.logout() DEVNET-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 12

Get Help / Variable Inspection / Meta Data

Get Help / Variable Inspection / Metadata vars(handle) dir(ucshandle) help(ucshandle) from ucsmsdk.ucscoreutils import get_meta_info meta = get_meta_info(class_id="fabricvlan") print meta meta = get_meta_info(class_id="fabricvlan", include_prop=false, show_tree=false) print meta meta = get_meta_info(class_id="fabricvlan", include_prop=false, show_tree=true) print meta DEVNET-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 14

Configure / Transactions

Configure from ucsmsdk.ucshandle import UcsHandle from ucsmsdk.mometa.fabric.fabricvlan import FabricVlan handle = UcsHandle("198.18.133.91", "admin", "password") handle.login() fabric_lan_cloud = handle.query_classid("fabriclancloud") vlan = FabricVlan(parent_mo_or_dn=fabric_lan_cloud[0], sharing="none", name="vlan100", id="100", mcast_policy_name="", policy_owner="local", default_net="no", pub_nw_name="", compression_type="included") handle.add_mo(vlan) handle.commit() handle.logout() DEVNET-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 16

Transactions from ucsmsdk.ucshandle import UcsHandle from ucsmsdk.mometa.fabric.fabricvlan import FabricVlan handle = UcsHandle("192.168.220.212", "admin", "password") handle.login() fabric_lan_cloud = handle.query_classid("fabriclancloud") vlans = ['200','300'] for vlan in vlans: vlan = FabricVlan(parent_mo_or_dn=fabric_lan_cloud[0], sharing="none", name="vlan" + vlan, id=vlan, mcast_policy_name="", policy_owner="local", default_net="no", pub_nw_name="", compression_type="included") handle.add_mo(vlan) handle.commit() handle.logout() DEVNET-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 17

Compare / Sync from ucsmsdk.ucshandle import UcsHandle from ucsmsdk.utils import comparesyncmo source_ucs=ucshandle("192.168.220.212", "admin", "password") target_ucs=ucshandle("192.168.220.209", "admin", "password") source_ucs.login() target_ucs.login() source_ucs_vlans=source_ucs.query_classid("fabricvlan") target_ucs_vlans=target_ucs.query_classid("fabricvlan") difference_vlans=comparesyncmo.compare_ucs_mo(target_ucs_vlans, source_ucs_vlans) # print the difference to the console comparesyncmo.write_mo_diff(difference_vlans) comparesyncmo.sync_ucs_mo(target_ucs, difference_vlans, delete_not_present=true) source_ucs.logout() target_ucs.logout() DEVNET-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 18

Code Generation 1. control-option/alt-q (MAC) Ctrl-Alt-q (Windows) 2. Click Record XML 3. Do Configuration 4. Click Stop XML Recording 5. Download XML file 6. Feed XML file to UCS Python SDK conversion method from ucsmsdk.utils.converttopython import convert_to_ucs_python convert_to_ucs_python(xml=true, literal_path="c:\\users\\demouser\\downloads\\vlan_ops_xmlreq.log"") DEVNET-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 19

Conclusion

Get hands-on with APIs and SDKs in the DevNet Zone LEARN CODE INSPIRE CONNECT In the DevNet Zone we offer: Classrooms Learn about a specific topic/technology NEW! Hack, Defend and Win! Embrace your inner hacker, then defend the network! Black Hat, White Hat Security Challenge DevNet Sandbox Explore free technology-packed 24x7 labs and play IoT foosball! Go for a 5-minute mini-hack challenge or complete all three in 15- minutes to win Learning Labs Find an open seat to start coding with self-paced tutorials (experts available) Panels Get inspired & interact with industry experts Connected Women s Event Join Susie Wee on Monday for this event followed by a DevNet Zone open house NEW! Application Developer Zone and Challenge Win a special-edition t-shirt and bragging rights complete a learning lab, a workshop, and an application developer demo Demos Exciting demos and inspiring partner solutions showcase Join DevNet! developer.cisco.com/join/cleur1 8 All DevNet members win a prize, visit the Info Desk to learn more! Workshops code with an instructor in @CiscoDevNet #DevNet #CLEUR

Hack, Defend, and Win! Come play the Black Hat, White Hat Security Challenge in the DevNet Zone! >>> Hack Embrace your inner hacker and try to access the network >>> Defend Be the heavily-armed Cisco defender that saves the day >>> Win Collect your prize and claim your bragging rights @CiscoDevNet #DevNet #CLEUR

Cisco Spark How Questions? Use Cisco Spark to communicate with the speaker after the session 1. Find this session in the Cisco Live Mobile App 2. Click Join the Discussion 3. Install Spark or go directly to the space 4. Enter messages/questions in the space cs.co/ciscolivebot#devnet-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Please complete your Online Session Evaluations after each session Complete 4 Session Evaluations & the Overall Conference Evaluation (available from Thursday) to receive your Cisco Live T-shirt All surveys can be completed via the Cisco Live Mobile App or the Communication Stations Complete Your Online Session Evaluation Don t forget: Cisco Live sessions will be available for viewing on-demand after the event at www.ciscolive.com/global/on-demand-library/. 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public

Continue Your Education DevNet: https://developer.cisco.com DevNet Learning Labs: https://learninglabs.cisco.com Demos in the Cisco campus Walk-in Self-Paced Labs Tech Circle Meet the Engineer 1:1 meetings Related sessions DEVNET-2060 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 25

Got more questions? Come find me! jomcdono@cisco.com @johnamcdonough http://github.com/movinalot @CiscoDevNet facebook.com/ciscodevnet http://github.com/ciscodevnet DEVNET-3607 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 26

Thank you