SlideShare une entreprise Scribd logo
1  sur  15
PSCLOUDSTACK 
INTERNALS 
PSCLOUDSTACK INTERNALS 
Managing Cloudstack using Windows 
PowerShell and the API Discovery Plugin
PSCLOUDSTACK 
INTERNALS 
AGENDA 
14:30 Introduction 
14.xx Why psCloudstack 
14:xx psCloudstack internals 
14:xx Demo 
14:55 Q||C (Questions or Coffee)
PSCLOUDSTACK 
INTERNALS 
INTRODUCTION 
Hans van Veen, Mission Critical Engineer 
Working for Schuberg Philis since 2007 
Main areas of expertise are MS SQL, IIS, EMC & NetApp storage and 
Windows servers. 
30+ years of IT experience, of which 20+ years in OpenVMS. 
Love scripting!
PSCLOUDSTACK 
INTERNALS 
WHY PSCLOUDSTACK 
Why psCloudstack 
• Actually …………………. just because I can! 
• No maintenance required! 
• ‘Native’ PowerShell Cloudstack control
PSCLOUDSTACK 
INTERNALS 
PSCLOUDSTACK FUNCTIONS 
Initialize-CSConfig to create a new (or update an existing) configuration file 
Set-CSConfig to activate a configuration 
Get-CSConfig to read the active configuration 
Connect-CSManager to connect to a Cloudstack server and to build the API functions of all to the 
user available API commands 
Invoke-CSApiCall – the engine which issues the actual API call and returns the result
PSCLOUDSTACK 
INTERNALS 
GLOSSARY OF TERMS 
API (Command) Cloudstack API command as described in the API Documentation 
API Function PowerShell function implementing a Cloudstack API command 
Cmdlet Lightweight command used in the PowerShell environment 
Apache CloudStack: API Documentation can be found at http://cloudstack.apache.org/docs/api/ 
PowerShell Cmdlets: http://msdn.microsoft.com/en-us/library/ms714395(v=vs.85).aspx
PSCLOUDSTACK 
INTERNALS 
BUILD THE POWERSHELLAPI FUNCTIONS 
Connect-CSManager uses the results from listApis command to 
generate the API functions using a ‘template’ 
Functions are ‘marked’ with the users API key. An API key mismatch will 
trigger the Connect-CSManager function. 
2 types of API functions; synchronous and asynchronous. Asynch 
functions will wait for completion unless –NoWait or –Wait xxx is 
specified
PSCLOUDSTACK 
INTERNALS 
INVOKE-CSAPICALL – THE ENGINE 
Logic is described in “The Little Cloudstack Clients and Tools Book” by 
Sebastien Goasquen 
Issues the web request and returns the result in JSON or XML format 
(default is XML) 
Errors are returned as an XML formatted object
# ============================================================================================================= 
# The PSCLOUDSTACK 
‘real’ psCloudstack internals 
# ============================================================================================================= 
INTERNALS 
param([parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$Command, 
[Parameter(Mandatory = $false)][string[]]$Parameters=$null, 
[Parameter(Mandatory = $false)][ValidateSet("XML","JSON")] [string]$Format="XML", 
# ============================================================================================================= 
# Build the query string using the provided command and parameters 
# ============================================================================================================= 
$Command = ([System.Web.HttpUtility]::UrlEncode($Command)).Replace("+","%20") 
$queryString = "response={0}" -f $Format.ToLower() 
$Parameters|%{ 
if ($_.Length -gt 0) 
{ 
$prmName,$prmVal = $_ -Split "=",2 
$prmVal = ([System.Web.HttpUtility]::UrlEncode($prmVal)).Replace("+","%20") 
$queryString += ("&{0}={1}" -f $prmName, $prmVal) 
} 
} 
Write-Verbose "Query String: $queryString" 
# ============================================================================================================= 
# Create the signature, add it to the query string and invoke the webrequest 
# ============================================================================================================= 
Write-Verbose "Secured web request for api call: $Command" 
$cryptString = (("apikey={0}&command={1}&{2}" -f $Connect.api, $Command,$queryString).split("&")|sort) -join "&" 
$crypt.key = [Text.Encoding]::ASCII.GetBytes($Connect.key) 
$cryptBytes = $crypt.ComputeHash([Text.Encoding]::ASCII.GetBytes($cryptString.ToLower())) 
$apiSignature = [System.Web.HttpUtility]::UrlEncode([System.Convert]::ToBase64String($cryptBytes)) 
Write-Verbose "Signature: $apiSignature" 
# ------------------------------------------------------------------------------------------------------------------ 
# The signature is ready, create the final url and invoke the web request 
# ------------------------------------------------------------------------------------------------------------------ 
$protocol = "http"; if ($Connect.UseSSL) { $protocol = "https" } 
$baseUrl = "{0}://{1}:{2}/client/api?" -f $protocol,$Connect.Server,$Connect.SecurePort 
$csUrl = "{0}command={1}&{2}&apikey={3}&signature={4}" -f $baseUrl, $Command,$queryString,$Connect.api,$apiSignature 
$prefProgress = $progressPreference; $progressPreference = 'silentlyContinue' 
$Response = Invoke-WebRequest "$csUrl" -ErrorVariable iwr
PSCLOUDSTACK 
INTERNALS 
DEMO TIME
PSCLOUDSTACK 
INTERNALS 
Q||C 
Questions……. or coffee……. 
15:30 – Global Poster Session: Discover the ‘API Discovery’ plugin 
Software available from: https://github.com/schubergphilis/psCloudstack 
Contact: 
hvanveen@schubergphilis.com
PSCLOUDSTACK 
INTERNALS 
FROM LISTAPIS TO PSCLOUDSTACK (1) 
What listApis in general returns: 
name : listApis 
description : lists all available apis on the server, 
provided by the Api Discovery plugin 
since : 4.1.0 
isasync : false 
related : 
params : params 
response : {name, type, response, description...}
PSCLOUDSTACK 
INTERNALS 
FROM LISTAPIS TO PSCLOUDSTACK (2) 
What listApis returns - a closer look on params; 
params => name : name 
description : API name 
type : string 
length : 255 
required : false
PSCLOUDSTACK 
INTERNALS 
FROM LISTAPIS TO PSCLOUDSTACK (3) 
What listApis returns - a closer look on response; 
name description type 
---- ----------- ---- 
name the name of the api command string 
type response field type string 
response api response fields set 
description description of the api string 
since version of CloudStack the api was in... string 
params the list params the api accepts set 
related comma separated related apis string 
isasync true if api is asynchronous boolean
PSCLOUDSTACK 
INTERNALS 
FROM LISTAPIS TO PSCLOUDSTACK (4) 
Which translates to Powershell function equivalents; 
name => Function name 
description => Function help synopsis & description 
since => - not used – 
isasync => Powershell code segments 
related => Function help links 
params => Function parameters 
response => Function output

Contenu connexe

Tendances

Spark Streaming Info
Spark Streaming InfoSpark Streaming Info
Spark Streaming Info
Doug Chang
 

Tendances (20)

BUILDING APPS WITH ASYNCIO
BUILDING APPS WITH ASYNCIOBUILDING APPS WITH ASYNCIO
BUILDING APPS WITH ASYNCIO
 
어릴 적 할머니가 들려주신 옛 wsgi
어릴 적 할머니가 들려주신 옛 wsgi어릴 적 할머니가 들려주신 옛 wsgi
어릴 적 할머니가 들려주신 옛 wsgi
 
Workshop Consul .- Service Discovery & Failure Detection
Workshop Consul .- Service Discovery & Failure DetectionWorkshop Consul .- Service Discovery & Failure Detection
Workshop Consul .- Service Discovery & Failure Detection
 
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
 
System Updates with Ansible - Ansible Brno #1 - Vincent van Scherpenseel
System Updates with Ansible - Ansible Brno #1 - Vincent van ScherpenseelSystem Updates with Ansible - Ansible Brno #1 - Vincent van Scherpenseel
System Updates with Ansible - Ansible Brno #1 - Vincent van Scherpenseel
 
Controlling multiple VMs with the power of Python
Controlling multiple VMs with the power of PythonControlling multiple VMs with the power of Python
Controlling multiple VMs with the power of Python
 
Consul - service discovery and others
Consul - service discovery and othersConsul - service discovery and others
Consul - service discovery and others
 
ElixirConf Lightning Talk: Elixir |> Production
ElixirConf Lightning Talk: Elixir |> ProductionElixirConf Lightning Talk: Elixir |> Production
ElixirConf Lightning Talk: Elixir |> Production
 
Flask With Server-Sent Event
Flask With Server-Sent EventFlask With Server-Sent Event
Flask With Server-Sent Event
 
Big data lambda architecture - Streaming Layer Hands On
Big data lambda architecture - Streaming Layer Hands OnBig data lambda architecture - Streaming Layer Hands On
Big data lambda architecture - Streaming Layer Hands On
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
 
How To Connect Amazon AWS EC2 with Key Pair – Linux
How To Connect Amazon AWS EC2 with Key Pair – LinuxHow To Connect Amazon AWS EC2 with Key Pair – Linux
How To Connect Amazon AWS EC2 with Key Pair – Linux
 
Spark Streaming Info
Spark Streaming InfoSpark Streaming Info
Spark Streaming Info
 
Tamir Dresher - Async Streams in C#
Tamir Dresher - Async Streams in C#Tamir Dresher - Async Streams in C#
Tamir Dresher - Async Streams in C#
 
Setup 3 Node Kafka Cluster on AWS - Hands On
Setup 3 Node Kafka Cluster on AWS - Hands OnSetup 3 Node Kafka Cluster on AWS - Hands On
Setup 3 Node Kafka Cluster on AWS - Hands On
 
Ansible with AWS
Ansible with AWSAnsible with AWS
Ansible with AWS
 
Atmosphere 2014
Atmosphere 2014Atmosphere 2014
Atmosphere 2014
 
Admins: Smoke Test Your Hadoop Cluster!
Admins: Smoke Test Your Hadoop Cluster!Admins: Smoke Test Your Hadoop Cluster!
Admins: Smoke Test Your Hadoop Cluster!
 
Tuning Solr for Logs
Tuning Solr for LogsTuning Solr for Logs
Tuning Solr for Logs
 
Recent Updates at Embulk Meetup #3
Recent Updates at Embulk Meetup #3Recent Updates at Embulk Meetup #3
Recent Updates at Embulk Meetup #3
 

Similaire à psCloudstack Internals

KSQL – The Open Source SQL Streaming Engine for Apache Kafka (Big Data Spain ...
KSQL – The Open Source SQL Streaming Engine for Apache Kafka (Big Data Spain ...KSQL – The Open Source SQL Streaming Engine for Apache Kafka (Big Data Spain ...
KSQL – The Open Source SQL Streaming Engine for Apache Kafka (Big Data Spain ...
Kai Wähner
 

Similaire à psCloudstack Internals (20)

Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...
Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...
Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...
 
Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...
Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...
Kai Waehner - KSQL – The Open Source SQL Streaming Engine for Apache Kafka - ...
 
KSQL Deep Dive - The Open Source Streaming Engine for Apache Kafka
KSQL Deep Dive - The Open Source Streaming Engine for Apache KafkaKSQL Deep Dive - The Open Source Streaming Engine for Apache Kafka
KSQL Deep Dive - The Open Source Streaming Engine for Apache Kafka
 
KSQL – The Open Source SQL Streaming Engine for Apache Kafka (Big Data Spain ...
KSQL – The Open Source SQL Streaming Engine for Apache Kafka (Big Data Spain ...KSQL – The Open Source SQL Streaming Engine for Apache Kafka (Big Data Spain ...
KSQL – The Open Source SQL Streaming Engine for Apache Kafka (Big Data Spain ...
 
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...Maxim Salnikov - Service Worker: taking the best from the past experience for...
Maxim Salnikov - Service Worker: taking the best from the past experience for...
 
How to deploy spark instance using ansible 2.0 in fiware lab v2
How to deploy spark instance using ansible 2.0 in fiware lab v2How to deploy spark instance using ansible 2.0 in fiware lab v2
How to deploy spark instance using ansible 2.0 in fiware lab v2
 
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE LabHow to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
 
Kafka pours and Spark resolves
Kafka pours and Spark resolvesKafka pours and Spark resolves
Kafka pours and Spark resolves
 
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
Deployment and Management on AWS:
 A Deep Dive on Options and ToolsDeployment and Management on AWS:
 A Deep Dive on Options and Tools
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
 
KSQL – An Open Source Streaming Engine for Apache Kafka
KSQL – An Open Source Streaming Engine for Apache KafkaKSQL – An Open Source Streaming Engine for Apache Kafka
KSQL – An Open Source Streaming Engine for Apache Kafka
 
KSQL: Streaming SQL for Kafka
KSQL: Streaming SQL for KafkaKSQL: Streaming SQL for Kafka
KSQL: Streaming SQL for Kafka
 
Just one-shade-of-openstack
Just one-shade-of-openstackJust one-shade-of-openstack
Just one-shade-of-openstack
 
Developingapiplug insforcs-151112204727-lva1-app6891
Developingapiplug insforcs-151112204727-lva1-app6891Developingapiplug insforcs-151112204727-lva1-app6891
Developingapiplug insforcs-151112204727-lva1-app6891
 
Building a Serverless company with Node.js, React and the Serverless Framewor...
Building a Serverless company with Node.js, React and the Serverless Framewor...Building a Serverless company with Node.js, React and the Serverless Framewor...
Building a Serverless company with Node.js, React and the Serverless Framewor...
 
KSQL - Stream Processing simplified!
KSQL - Stream Processing simplified!KSQL - Stream Processing simplified!
KSQL - Stream Processing simplified!
 
FrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) SwiftFrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) Swift
 
Un'introduzione a Kafka Streams e KSQL... and why they matter!
Un'introduzione a Kafka Streams e KSQL... and why they matter!Un'introduzione a Kafka Streams e KSQL... and why they matter!
Un'introduzione a Kafka Streams e KSQL... and why they matter!
 
Let's play with adf 3.0
Let's play with adf 3.0Let's play with adf 3.0
Let's play with adf 3.0
 
AWS Serverless Workshop
AWS Serverless WorkshopAWS Serverless Workshop
AWS Serverless Workshop
 
Splunk n-box-splunk conf-2017
Splunk n-box-splunk conf-2017Splunk n-box-splunk conf-2017
Splunk n-box-splunk conf-2017
 

Dernier

Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Sheetaleventcompany
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 

Dernier (20)

Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 

psCloudstack Internals

  • 1. PSCLOUDSTACK INTERNALS PSCLOUDSTACK INTERNALS Managing Cloudstack using Windows PowerShell and the API Discovery Plugin
  • 2. PSCLOUDSTACK INTERNALS AGENDA 14:30 Introduction 14.xx Why psCloudstack 14:xx psCloudstack internals 14:xx Demo 14:55 Q||C (Questions or Coffee)
  • 3. PSCLOUDSTACK INTERNALS INTRODUCTION Hans van Veen, Mission Critical Engineer Working for Schuberg Philis since 2007 Main areas of expertise are MS SQL, IIS, EMC & NetApp storage and Windows servers. 30+ years of IT experience, of which 20+ years in OpenVMS. Love scripting!
  • 4. PSCLOUDSTACK INTERNALS WHY PSCLOUDSTACK Why psCloudstack • Actually …………………. just because I can! • No maintenance required! • ‘Native’ PowerShell Cloudstack control
  • 5. PSCLOUDSTACK INTERNALS PSCLOUDSTACK FUNCTIONS Initialize-CSConfig to create a new (or update an existing) configuration file Set-CSConfig to activate a configuration Get-CSConfig to read the active configuration Connect-CSManager to connect to a Cloudstack server and to build the API functions of all to the user available API commands Invoke-CSApiCall – the engine which issues the actual API call and returns the result
  • 6. PSCLOUDSTACK INTERNALS GLOSSARY OF TERMS API (Command) Cloudstack API command as described in the API Documentation API Function PowerShell function implementing a Cloudstack API command Cmdlet Lightweight command used in the PowerShell environment Apache CloudStack: API Documentation can be found at http://cloudstack.apache.org/docs/api/ PowerShell Cmdlets: http://msdn.microsoft.com/en-us/library/ms714395(v=vs.85).aspx
  • 7. PSCLOUDSTACK INTERNALS BUILD THE POWERSHELLAPI FUNCTIONS Connect-CSManager uses the results from listApis command to generate the API functions using a ‘template’ Functions are ‘marked’ with the users API key. An API key mismatch will trigger the Connect-CSManager function. 2 types of API functions; synchronous and asynchronous. Asynch functions will wait for completion unless –NoWait or –Wait xxx is specified
  • 8. PSCLOUDSTACK INTERNALS INVOKE-CSAPICALL – THE ENGINE Logic is described in “The Little Cloudstack Clients and Tools Book” by Sebastien Goasquen Issues the web request and returns the result in JSON or XML format (default is XML) Errors are returned as an XML formatted object
  • 9. # ============================================================================================================= # The PSCLOUDSTACK ‘real’ psCloudstack internals # ============================================================================================================= INTERNALS param([parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$Command, [Parameter(Mandatory = $false)][string[]]$Parameters=$null, [Parameter(Mandatory = $false)][ValidateSet("XML","JSON")] [string]$Format="XML", # ============================================================================================================= # Build the query string using the provided command and parameters # ============================================================================================================= $Command = ([System.Web.HttpUtility]::UrlEncode($Command)).Replace("+","%20") $queryString = "response={0}" -f $Format.ToLower() $Parameters|%{ if ($_.Length -gt 0) { $prmName,$prmVal = $_ -Split "=",2 $prmVal = ([System.Web.HttpUtility]::UrlEncode($prmVal)).Replace("+","%20") $queryString += ("&{0}={1}" -f $prmName, $prmVal) } } Write-Verbose "Query String: $queryString" # ============================================================================================================= # Create the signature, add it to the query string and invoke the webrequest # ============================================================================================================= Write-Verbose "Secured web request for api call: $Command" $cryptString = (("apikey={0}&command={1}&{2}" -f $Connect.api, $Command,$queryString).split("&")|sort) -join "&" $crypt.key = [Text.Encoding]::ASCII.GetBytes($Connect.key) $cryptBytes = $crypt.ComputeHash([Text.Encoding]::ASCII.GetBytes($cryptString.ToLower())) $apiSignature = [System.Web.HttpUtility]::UrlEncode([System.Convert]::ToBase64String($cryptBytes)) Write-Verbose "Signature: $apiSignature" # ------------------------------------------------------------------------------------------------------------------ # The signature is ready, create the final url and invoke the web request # ------------------------------------------------------------------------------------------------------------------ $protocol = "http"; if ($Connect.UseSSL) { $protocol = "https" } $baseUrl = "{0}://{1}:{2}/client/api?" -f $protocol,$Connect.Server,$Connect.SecurePort $csUrl = "{0}command={1}&{2}&apikey={3}&signature={4}" -f $baseUrl, $Command,$queryString,$Connect.api,$apiSignature $prefProgress = $progressPreference; $progressPreference = 'silentlyContinue' $Response = Invoke-WebRequest "$csUrl" -ErrorVariable iwr
  • 11. PSCLOUDSTACK INTERNALS Q||C Questions……. or coffee……. 15:30 – Global Poster Session: Discover the ‘API Discovery’ plugin Software available from: https://github.com/schubergphilis/psCloudstack Contact: hvanveen@schubergphilis.com
  • 12. PSCLOUDSTACK INTERNALS FROM LISTAPIS TO PSCLOUDSTACK (1) What listApis in general returns: name : listApis description : lists all available apis on the server, provided by the Api Discovery plugin since : 4.1.0 isasync : false related : params : params response : {name, type, response, description...}
  • 13. PSCLOUDSTACK INTERNALS FROM LISTAPIS TO PSCLOUDSTACK (2) What listApis returns - a closer look on params; params => name : name description : API name type : string length : 255 required : false
  • 14. PSCLOUDSTACK INTERNALS FROM LISTAPIS TO PSCLOUDSTACK (3) What listApis returns - a closer look on response; name description type ---- ----------- ---- name the name of the api command string type response field type string response api response fields set description description of the api string since version of CloudStack the api was in... string params the list params the api accepts set related comma separated related apis string isasync true if api is asynchronous boolean
  • 15. PSCLOUDSTACK INTERNALS FROM LISTAPIS TO PSCLOUDSTACK (4) Which translates to Powershell function equivalents; name => Function name description => Function help synopsis & description since => - not used – isasync => Powershell code segments related => Function help links params => Function parameters response => Function output

Notes de l'éditeur

  1. First of all: Thank you to Rohit Yadav for his work on the listApis discovery API Whithout this API psCloudstack would never been created
  2. A small agenda with (hopefully) most time spend on the Demo The Q part of the Q||C can be moved to the poster session at 15:30
  3. Schuberg Philis provides outsourcing with a 100% guarantee on application availability. This can only be achieved by automating the work at hand. Well written (and documented!) scripts and tools like Chef, Jenkins, etc. are invaluable for this. Why do I love scripting? I do not like to do things twice I am curious – curious to figure out how to do things simpler/smarter
  4. As said before, I love scripting, but I do not like doing things twice No Perl, Python or Ruby required, keep my systems ‘clean’
  5. psCloudstack consists of 5 static functions; 3 to control the configuration, 1 to use the configuration to connect to the Cloudstack server and 1 to invoke commands and return results. By default the configuration files are stored in the C:\Users\’Username’\AppData\Local folder Set-CSConfig sets the CSCONFIGFILE environment variable to set the active configuration Get-CSConfig uses this variable to find the active configuration If the variable is not yet set the default C:\Users\’Username’\AppData\Local\psCloudstack.config is used
  6. PowerShell uses a strict naming convention for Cmdlets but not for functions API functions names are identical to the Cloudstack API command name
  7. The API key marking is meant to prevent usage of unauthorized API commands when switching configurations. I have some slides which explain how listApis output is transformed into a PowerShell API function. I’d rather spent my time on the demo, but for those interested look me up at the Global poster session later this afternoon.
  8. The required signature for the web request is created using the Secret and API key values from the active configuration file. JSON error format is ‘under investigation’
  9. If there is time -> Questions. No time left -> Questions at the Global Poster session