+ All Categories
Home > Documents > Start Now Cisco UCS and Intersight Programmability...UCS Manger – Object Model Managed Object Tree...

Start Now Cisco UCS and Intersight Programmability...UCS Manger – Object Model Managed Object Tree...

Date post: 19-Feb-2021
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
42
#CiscoLive | #DevNetDay John McDonough – DevNet Developer Advocate @johnamcdonough Start Now Cisco UCS and Intersight Programmability
Transcript
  • #CiscoLive | #DevNetDay

    John McDonough – DevNet Developer Advocate@johnamcdonough

    Start Now Cisco UCS and Intersight Programmability

  • Agenda

    #CiscoLive | #DevNetDay © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public

    • Introduction• Cisco UCS• PowerTool• Python SDK• Ansible

    • Intersight• REST API – Native Python• Ansible

    2DEVNET-DC

  • Cisco UCS

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    UCS Management Information Model

    4

    Everything is an ObjectObjects are hierarchically organized

    Objects have Class InheritancecomputeBlade is a subclass of computePhysical

    Objects have attributes

    Objects represent physical & logical entities

    UCS XML Database contains comprehensive system information § Discovered components§ System configuration§ Operational status including statistics and faults

    Managed Object

    Root

    Objects are uniquely identified by a DN

    Objects belong to a Class: Card, Port, VNIC…

    DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Distinguished Names

    5

    DN: Slash delimited sequence of RNs

    RN: identifies an object relative to its parent object.

    DN: Immutable

    dn = {rn1}/{rn2}/{rn3}

    rn1

    rn2

    rn3

    Example:

    DN: Provides a fully qualified path to object

    Root

    DN: unambiguously identifies a target object.

    is composed of the following relative names:topSystem MO: rn="sys"equipmentChassis MO: rn="chassis-"computeBlade MO: rn ="blade-"adaptorUnit MO: rn="adaptor-"adaptorHostEthIf MO: rn="host-eth-"

    DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Root

    sys org-root

    UCS Manger – Object ModelManaged Object Tree

    6DEVNET-DC

    switch-Achassis-1

    fabric

    ls-prodsrv

    org-prod

    blade-1 slot-2

    ether fc

    port-5port-1

    adaptor-1

    eth0

    compute board

    fc0 temp statspower stats

    macPool

    mac poolblock

    lsPowerlsBinding

    boot policy

    bios policyLAN cloud

    SAN cloud

    vlan10 vsan10

  • UCS PowerTool

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Windows PowerShell – UCS PowertoolInstall-Module / Count the Cmdlets• Install what you need - use Install-Module

    • PowerTool C:\> Get-Command -Module Cisco.UCSManager | Measure à 2472• PowerTool C:\> Get-Command -Module Cisco.IMC | Measure à 828• PowerTool C:\> Get-Command -Module Cisco.UCSCentral | Measure à 2398• PowerTool C:\> Get-Command -Module Cisco.UCS.DesiredStateConfiguration | Measure à 2• PowerTool C:\> Get-Command -Module Cisco.UCS.Core | Measure à16• 5716 Cmdlets and Functions in total

    DEVNET-DC 8

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Windows PowerShell – UCS PowertoolImport-Module

    DEVNET-DC 9

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Linux PowerShell Core – UCS PowerTool CoreDownload / Install / Count the Cmdlets• Download from community.cisco.com• https://community.cisco.com/t5/cisco-developed-ucs-integrations/cisco-ucs-powertool-core-

    suite-for-powershell-core-modules-for/ta-p/3985798• Latest Version – 2.5.3.0 Beta - ucspowertoolcore_v2.5.3.0.zip

    • PS /home/user/> Get-Command -Module Cisco.UCSManager | Measure à 2470• PS /home/user/> Get-Command -Module Cisco.IMC | Measure à 826• PS /home/user/> Get-Command -Module Cisco.UCSCentral | Measure à 2395• PS /home/user/> Get-Command -Module Cisco.UCS.Core | Measure à15• 5706 Cmdlets and Functions in total

    DEVNET-DC 10

    https://community.cisco.com/t5/cisco-developed-ucs-integrations/cisco-ucs-powertool-core-suite-for-powershell-core-modules-for/ta-p/3985798https://community.cisco.com/t5/cisco-developed-ucs-integrations/cisco-ucs-powertool-core-suite-for-powershell-core-modules-for/ta-p/3985798

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Linux PowerShell Core – UCS PowerTool CoreDownload / Install / Count the Cmdlets

    pwsh -NoExit -File ~/.local/share/powershell/Modules/Start-UcsPowerTool.ps1

    DEVNET-DC 11

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Connect / Query / Dump XML

    12DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Query – Filter

    13DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Configure

    14DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Transactions

    15DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Compare / Sync

    16DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Code Generation

    17

    1. control-option/alt-q (MAC)Ctrl-Alt-q (Windows)

    2. Click Record XML3. Do Configuration4. Click Stop XML Recording5. Download XML file6. Feed XML file to

    ConvertTo-UcsCmdLet

    ConvertTo-UcsCmdlet -Xml -LiteralPath C:\Users\demouser\Downloads\org_ops_xmlReq.log

    Code Generation

    DEVNET-DC

  • UCS Python SDK

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Cisco UCS Python SDKs - Install

    • Hosted on Github• UCS Manager SDK – 0.9.10• Source – https://github.com/CiscoUcs/ucsmsdk• Samples – https://github.com/CiscoUcs/ucsmsdk_samples• Documents – https://CiscoUcs.github.io/ucsmsdk_docs

    • UCS IMC SDK – 0.9.7• Source – https://github.com/CiscoUcs/imcsdk• Documents – https://ciscoucs.github.io/imcsdk_docs

    • UCS Central Python SDK – 0.9.0.1• Source – https://github.com/CiscoUcs/ucscentralsdk

    19DEVNET-DC

    https://github.com/CiscoUcs/ucsmsdkhttps://github.com/CiscoUcs/ucsmsdk_sampleshttps://ciscoucs.github.io/ucsmsdk_docs/https://github.com/CiscoUcs/imcsdkhttps://ciscoucs.github.io/imcsdk_docshttps://github.com/CiscoUcs/ucscentralsdk

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Cisco UCS Python SDKs - Install

    • Install Python 2.7.X or 3.5.X and greater• Both Python versions of UCS Python SDKs can coexist!• pip – Preferred Installer Program (package manager)• Installs latest “Release” from https://pypi.python.org/pypi

    pip install ucsmsdkpip install ucscsdkpip install imcmsdk

    • git – Install from github.com – works for ucsmsdk, imcsdk, ucscsdk• Installs latest SDK source code from https://github.com/CiscoUcs/ucsmsdk

    git clone https://github.com/CiscoUcs/ucsmsdk/

    cd ucsmsdk

    sudo make install

    20DEVNET-DC

    https://pypi.python.org/pypihttps://github.com/CiscoUcs/ucsmsdkhttps://github.com/CiscoUcs/ucsmsdk/

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Connect / Query / Dump XML

    21DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Query - Filter

    22DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Query - Returns

    23DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Configure

    24DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Transactions

    25DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Compare / Sync

    26DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Code Generation

    27

    1. control-option/alt-q (MAC)Ctrl-Alt-q (Windows)

    2. Click Record XML3. Do Configuration4. Click Stop XML Recording5. Download XML file6. Feed XML file to UCS Python SDK

    conversion method

    from ucsmsdk.utils.converttopython import convert_to_ucs_python# Windowsconvert_to_ucs_python(xml=True, literal_path=”C:\\User\demouser\Downloads\\vlan-ops_xmlReq.log")# Linuxconvert_to_ucs_python(xml=True, literal_path="/Users/demouser/Downloads/vlan-ops_xmlReq.log")

    DEVNET-DC

  • UCS Ansible

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Ansible Collections - Install• Install Python 2.7.X or 3.7.X OR BOTH!• pip – Preferred Installer Program (package manager)• Installs latest “Release” from https://pypi.python.org/pypi

    pip install ansible

    • Cisco Intersight and UCS Collections - Modules in Ansible Galaxy• Details at https://galaxy.ansible.com/cisco/ucs• Details at https://galaxy.ansible.com/cisco/intersight• ansible-galaxy commands to install/update without updates to Ansible core

    ansible-galaxy collection install cisco.ucs • ansible-doc has usage/examples, e.g., ansible-doc cisco.ucs.ucs_vlans

    ansible-galaxy collection install cisco.intersight• ansible-doc has usage/examples, e.g., ansible-doc cisco.Intersight.Intersight_facts

    29DEVNET-DC

    https://pypi.python.org/pypihttps://galaxy.ansible.com/cisco/ucshttps://galaxy.ansible.com/cisco/intersight

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    UCS Ansible Collection

    • Ensure Latest Ansible – 2.9 includes UCS Modulespip install ansible –U

    • Install UCS Python SDK – ucsmsdkpip install ucsmsdk -U

    • Install UCS Collectionansible-galaxy collection install cisco.ucs

    • Install/Update UCS Manager Ansible – ucsm-ansiblegit clone https://github.com/CiscoUcs/ucsm-ansible

    • Ansible with UCS just like Ansible with other devices

    30DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    UCS Ansible Collection Playbook

    31DEVNET-DC

  • Intersight Python

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Intersight REST APIhttps://github.com/movinalot/intersight-rest-api

    33DEVNET-DC

    https://github.com/movinalot/intersight-rest-api

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Python – Update Code with CredentialsUpdate intersight_ops.py with SecretKey.txt and API Key ID

    34DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Python – Run the Code

    35DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Intersight Python SDKhttps://intersight.com/apidocs/downloads/

    36DEVNET-DC

    https://intersight.com/apidocs/downloads/

  • Intersight Ansible

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Intersight Ansible Collection

    • Ensure Latest Ansible – 2.9 includes UCS Modulespip install ansible –U

    • Install Intersight Collectionansible-galaxy collection install cisco.Intersight

    • Ansible with Intersight just like Ansible with other devices

    38DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Intersight Ansible Collection Playbook

    39DEVNET-DC

  • © 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public#CiscoLive | #DevNetDay

    Explore More

    • UCS Learning LabsPython https://developer.cisco.com/learning/modules/ucs-python-sdk-introductionPowerTool https://developer.cisco.com/learning/modules/ucs-powertool-introduction

    • UCS Developer Centerhttps://developer.cisco.com/site/ucs-dev-center/

    • Intersight Learning Labshttps://developer.cisco.com/learning/modules/intersight-rest-api

    • Intersight Developer Centerhttps://developer.cisco.com/site/intersight/

    DEVNET-DC 40

    https://developer.cisco.com/learning/modules/ucs-python-sdk-introductionhttps://developer.cisco.com/learning/modules/ucs-powertool-introductionhttps://developer.cisco.com/site/ucs-dev-center/https://developer.cisco.com/learning/modules/intersight-rest-apihttps://developer.cisco.com/site/intersight/

  • Thank you

    #CiscoLive | #DevNetDay

  • #CiscoLive | #DevNetDay


Recommended