Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
OpenStack and PHP
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Glen Campbell
March 15, 2014
Programming
330
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
OpenStack and PHP
An introduction to OpenStack and how to access it using PHP.
Glen Campbell
March 15, 2014
More Decks by Glen Campbell
See All by Glen Campbell
Cache Strategies for Web Apps
gecampbell
0
420
Succeeding at Open Source
gecampbell
0
130
Cache strategies for microservice-based web apps
gecampbell
1
4.6k
OpenStack: the good, the bad, and the ugly
gecampbell
0
250
Open-Source in the Real World
gecampbell
1
240
The Future of PHP is in the Clouds
gecampbell
0
50
Other Decks in Programming
See All in Programming
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
190
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
310
T3DD26: From RAGs to Riches
martinhelmich
0
130
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
870
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
3
260
Go 1.27からのGODEBUG / Go 1.27 リリースパーティ #go127party
mazrean
0
280
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
750
AIの中の人になってみる
htkym
0
150
高専キャリア LT 発表内容
crysta1221
6
5.4k
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
270
私のClaude Code活用法 (個人開発編) - PHPerKaigi mini #4(2026/08/24)
panda_program
1
200
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
250
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
First, design no harm
axbom
PRO
2
1.3k
The browser strikes back
jonoalderson
0
1.6k
Designing for Timeless Needs
cassininazir
1
460
Faster Mobile Websites
deanohume
310
32k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
390
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
680
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
320
How to Ace a Technical Interview
jacobian
281
24k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
The SEO identity crisis: Don't let AI make you average
varn
0
550
Transcript
March 2014 OpenStack and PHP Glen Campbell • Midwest PHP
2014
None
http://rack.to/mwphp14
01
01
None
OpenStack concepts ✤ virtual infrastructure services ✤ accessed via HTTP
(RESTful) API ✤ developed by an open-source community ✤ highly configurable
OpenStack governance ✤ Independent foundation ✤ Board of Directors: some
directors appointed by funding companies, others elected at-large ✤ Technical Committee: elected by active members ✤ Biannual releases and summit/workshops ✤ Project Technical Leaders
OpenStack APIs ✤ Native REST ✤ EC2-compatible ✤ Internal (python)
Compute ✤ Project “Nova” ✤ Supports multiple hypervisors including KVM,
Xen ✤ Massively-scalable architecture ✤ Working towards interoperable workloads
Storage ✤ Project “Swift” ✤ Elastic “blob” storage ✤ Can
scale to regional or even global deployments ✤ Eventually consistent
Networking ✤ Project “Neutron” (formerly “Quantum”) ✤ Dynamically create and
manage L2/L3 networks ✤ Works with plugins for virtual network devices (OpenVSwitch, others)
Dashboard ✤ Project “Horizon” ✤ Clean, simple user interface ✤
Uses native API to communicate to services
Shared Services ✤ Identity—“Keystone” ✤ Image—“Glance” ✤ Telemetry—“Ceilometer” ✤ Orchestration—“Heat”
Other Projects ✤ OpenStack-SDKs ✤ Savanna—Hadoop provisioning ✤ Trove—Database ✤
Bare metal—Ironic ✤ Queue—Marconi
How to interact with OpenStack ✤ Control panel ✤ Command
line client ✤ cURL ✤ SDK
First Q&A
Resources ✤ http://github.com/rackspace/php-opencloud ✤ http://developer.rackspace.com/ ✤ http://docs.openstack.org/
Installing php-opencloud # Install Composer curl -sS https://getcomposer.org/installer | php
# Require php-opencloud as a dependency php composer.phar require rackspace/php- opencloud:dev-master
Example 1. Create a server
1.1 Authentication <?php require 'vendor/autoload.php'; use OpenCloud\Rackspace; print "Creating client...\n";
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array( 'username' => getenv('OS_USERNAME'), 'apiKey' => getenv('NOVA_API_KEY'), 'tenantName' => getenv('OS_TENANT_NAME') ));
1.2 Attach print "Attaching to compute...\n"; try { $compute =
$client->computeService( 'cloudServersOpenStack', 'IAD'); } catch (\Guzzle\Http\Exception\BadResponseException $e) { echo $e->getResponse(); die("OOPS\n"); }
1.3 Image print "Getting an image...\n"; $centos = $compute->image('85019bd8-fb5d-4230-b3bc-63b192800f28');
1.4 Flavor print "Getting a flavor...\n"; $flavor = $compute->flavor('performance1-1');
1.5 Create print "Creating a server...\n"; use OpenCloud\Compute\Constants\Network; $server =
$compute->server(); try { $response = $server->create(array( 'name' => 'My lovely server', 'image' => $centos, 'flavor' => $flavor, 'networks' => array( $compute->network(Network::RAX_PUBLIC), $compute->network(Network::RAX_PRIVATE) ) ));
1.6 Exception Handling } catch (\Guzzle\Http\Exception\BadResponseException $e) { // No!
Something failed. Let's find out: $responseBody = (string) $e->getResponse()->getBody(); $statusCode = $e->getResponse()->getStatusCode(); $headers = $e->getResponse()->getHeaderLines(); echo sprintf("Status: %s\nBody: %s\nHeaders: %s", $statusCode, $responseBody, implode(', ', $headers)); }
1.7 Poll use OpenCloud\Compute\Constants\ServerState; $callback = function($server) { if (!empty($server->error))
{ var_dump($server->error); exit; } else { echo sprintf( "\rWaiting on %s/%-12s %4s%%", $server->name(), $server->status(), isset($server->progress) ? $server->progress : 0 ); } }; $server->waitFor(ServerState::ACTIVE, 600, $callback);
1.8 Let's try it out LIVE DEMO
Example 2. Listing flavors print "Attaching to compute...\n"; try {
$compute = $client->computeService( 'cloudServersOpenStack', getenv('OS_REGION_NAME')); } catch (\Guzzle\Http\Exception\BadResponseException $e) { echo $e->getResponse(); } $list = $compute->flavorList(true); foreach($list as $flavor) { printf("%20s %-20s\n", $flavor->id(), $flavor->name()); }
Example 3. File upload print "Attaching to object storage...\n"; try
{ $storage = $client->objectStoreService( 'cloudFiles', getenv('OS_REGION_NAME')); } catch (\Guzzle\Http\Exception\BadResponseException $e) { echo $e->getResponse(); die("OOPS\n"); }
3.1 create a container // create a container $container =
$storage->createContainer('MidWestPHP'); if ($container === false) $container = $storage-
3.2 upload a file // create an object (empty) print
"Creating an object...\n"; use OpenCloud\ObjectStore\Resource\DataObject; $container->uploadObject('myfile', fopen('upload_file.php', 'r+'));
3.3 list objects // list objects print "Listing objects:\n"; $files
= $container->objectList(); while ($file = $files->next()) { printf("* %s (%d)\n.", $file->getName(), $file->getContentLength()); }
Final Q&A
https://github.com/gecampbell/mwphp14
Let's keep in touch ✤
[email protected]
✤ Twitter: @glenc ✤
http://developer.rackspace.com