how powercli gives day 1 access to the latest vmware apis

18
#vmworld CODE2649U How PowerCLI Gives Day 1 Access to the Latest VMware APIs Nikola Klinkachev, VMware, Inc. #CODE2649U VMworld 2019 Content: Not for publication or distribution

Upload: others

Post on 24-Mar-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

#vmworld

CODE2649U

How PowerCLI Gives Day 1 Access to the Latest VMware APIs

Nikola Klinkachev, VMware, Inc.

#CODE2649U

VMworld 2019 Content: Not for publication or distribution

Page 2: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

©2019 VMware, Inc.

Disclaimer

This presentation may contain product features or functionality that are currently under development.

This overview of new technology represents no commitment from VMware to deliver these features in any generally available product.

Features are subject to change, and must not be included in contracts, purchase orders, or sales agreements of any kind.

Technical feasibility and market demand will affect final delivery.

Pricing and packaging for any new features/functionality/technology discussed or presented, have not been determined.

2

The information in this presentation is for informational purposes only and may not be incorporated into any contract. There is no commitment or obligation to deliver any items presented herein. VMworld 2019 Content: Not for publication or distribution

Page 3: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

©2019 VMware, Inc.

Agenda

3

PowerCLI

CLI tool for management and automation

Dynamic Bindings

The value of runtime generated bindings

Exploring the API and Built-in Help

Everything you need to make an API call

Instantiating Parameters and Invoking Operations

Q&A

VMworld 2019 Content: Not for publication or distribution

Page 4: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

4©2019 VMware, Inc.

PowerCLICLI tool for management and automation

VMworld 2019 Content: Not for publication or distribution

Page 5: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

©2019 VMware, Inc. 5

Command-Line Interface tool

Built on Microsoft’s PowerShell

Runs on Windows, Linux and MacOS

Provides High-Level Cmdlets and Low-Level Bindings for management and automation of VMWare products

CLI tool for management and automation

PowerCLI

VMworld 2019 Content: Not for publication or distribution

Page 6: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

6©2019 VMware, Inc.

Dynamic BindingsThe value of runtime generated bindings

VMworld 2019 Content: Not for publication or distribution

Page 7: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

©2019 VMware, Inc. 7

No PowerCLI update required

New API features are available faster

You see only what’s relevant to your environment

Great for writing high-level cmdlets

PowerCLI update required

Static

Dynamic

Dynamic BindingsThe value of runtime generated bindings

Generate Code

Build Bindings

Release PowerCLI

Upgrade PowerCLI

Generate CLI Metadata

vProduct development and Release

API Description

API Description

CLI Metadata

Connect and Start Scripting

Connect and Start Scripting

Build Bindings

VMworld 2019 Content: Not for publication or distribution

Page 8: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

©2019 VMware, Inc. 8

The building process

Dynamic Bindings

CLI Metadata

Type Descriptions

Operation Descriptions

Service Descriptions

Help

Metadata Manager

Type Mappings

Operation Definitions

Service Definitions

Help

REST/SOAP Mapping

Service Objects

Name

Methods

Help Object

Documentation

Static Analysis

Parsing Build Bindings

VMworld 2019 Content: Not for publication or distribution

Page 9: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

9©2019 VMware, Inc.

Exploring the API and Built-in HelpEverything you need to make an API call

VMworld 2019 Content: Not for publication or distribution

Page 10: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

©2019 VMware, Inc. 10

Exploring the API and Built-in HelpExploring and filtering the API capabilities

Get-*Service

• List everything the API can do

Get-*Service –Name ‘*name*’

• Filter only the services you’re interested in

Get-*Service –Name ‘service_name’

• Retrieve a specific service to script against

VMworld 2019 Content: Not for publication or distribution

Page 11: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

©2019 VMware, Inc. 11

Exploring the API and Built-in HelpAccessing and using the Built-in help

$service.Help

• List all available methods and documentation

$service.Help.{operation}

• Overloads, parameters, return type and possible errors

$service.Help.{operation}.{parameter}

• Parameter type definition and documentationVMworld 2019 Content: Not for publication or distribution

Page 12: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

12©2019 VMware, Inc.

Instantiating Parameters and Invoking Operations

VMworld 2019 Content: Not for publication or distribution

Page 13: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

©2019 VMware, Inc. 13

Instantiating Parameters and Invoking OperationsInstantiating parameters

$param = $jsonStr | Convert-FromJson

• Form json string

• Good option when you have the HTTP request

$param = @{‘key1’=‘value1’}

• As PowerShell HashTable

• Good option when you know the fields of the parameter object

$param = $service.Help.{operation}.{parameter}.Create()

• Automatic instantiation through the help object

• Good option when you don’t know the parameter fields

• Good for object types that inherit a base type

VMworld 2019 Content: Not for publication or distribution

Page 14: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

©2019 VMware, Inc. 14

Instantiating Parameters and Invoking OperationsParameter objects, dynamic structures and invoking methods

Parameter objects

• Display all properties

• Only modified fields are sent top the server

Dynamic Structures

• Can be any object or

• Can be duck-typed/base type

$service.{method}($params)

• No surprises – invokes the method and returns a PowerShell object of the specified type

VMworld 2019 Content: Not for publication or distribution

Page 15: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

15©2019 VMware, Inc.

Additional Resources

VMworld 2019 Content: Not for publication or distribution

Page 16: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

©2019 VMware, Inc. 16

https://code.vmware.com/web/tool/11.4.0/vmware-powercli

• Latest (Aug 2019) PowerCLI downloads, user’s guide, documentation and examples

https://communities.vmware.com/community/vmtn/automationtools/powercli

• PowerCLI community forum

https://blogs.vmware.com/PowerCLI

• PowerCLI blog

https://powercli.ideas.aha.io/

• User requests and ideas for PowerCLI

Additional resources

VMworld 2019 Content: Not for publication or distribution

Page 17: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

VMworld 2019 Content: Not for publication or distribution

Page 18: How PowerCLI Gives Day 1 Access to the Latest VMware APIs

VMworld 2019 Content: Not for publication or distribution