SlideShare a Scribd company logo
1 of 34
Download to read offline
Enrico Zimuel
Zend Technologies

Manage Cloud
Infrastructures in PHP using
Zend Framework 2 (and ZF1)
About me
           • Software Engineer since 1996
             – Assembly x86, C/C++, Java, Perl, PHP
           • Enjoying PHP since 1999
           • PHP Engineer at Zend since 2008
           • ZF Core Team from April 2011
           • B.Sc. Computer Science and
               Economics from University of
               Pescara (Italy)
           • Email: enrico@zend.com
Summary
•   Cloud computing in PHP
•   ZendServiceRackspace
•   Examples
•   Simple Cloud API
•   ZendCloudInfrastructure for ZF2 and ZF1
•   Adapters: Amazon Ec2, Rackspace
•   Examples
Cloud computing

“Cloud computing is the delivery of computing as a
   service rather than a product, whereby shared
 resources, software, and information are provided
 to computers and other devices as a utility over a
             network (tipically internet)”
                      Wikipedia
Cloud computing


   What does it means?
  Actually, nothing useful.
Cloud computing


    Do not try to define it,
         just use it!
How to use it?
• API (Application Programming Interface), to
  interact with cloud services
• Typically use REST-based APIs
• Each vendors uses a property API:
   – Different API for each vendor
   – Use of specific PHP libraries (coming from
     community or vendors)
Some PHP libraries for Cloud
• Amazon Web Services
  – AWS SDK for PHP, http://aws.amazon.com/sdkforphp/
• Windows Azure
  – PHPAzure, http://phpazure.codeplex.com/
• Rackspace
  – php-cloudfiles, http://bit.ly/ptJa1Y
• GoGrid
  – GoGridClient, http://bit.ly/o7MeLA
ZF service classes for Cloud
•   ZendServiceAmazon
•   ZendServiceGoGrid (under development)
•   ZendServiceNirvanix
•   ZendServiceRackspace
•   ZendServiceWindowsAzure
ZendService
 Rackspace
ZendServiceRackspace

• Manage the following cloud services of
  Rackspace:
  – Servers
  – Files
• Provide a full OO interface for the API of
  Rackspace (ver 1.0)
• Release: ZF1 1.12+, ZF2 dev3+
Example: authentication
$user = 'username';
$key = 'secret key';

$rackspace = new ZendServiceRackspaceFiles($user,$key);

if ($rackspace->authenticate()) {
   echo "Authentication successfully";
} else {
   printf("ERROR: %s",$rackspace->getErrorMsg());
}
Example: store an image in a container
…
$container = $rackspace->createContainer('test');
if (!$rackspace->isSuccessful()) {
    die('ERROR: '.$rackspace->getErrorMsg());
}
$name = 'example.jpg';
$file = file_get_contents($name);
$metadata = array (
    'foo' => 'bar'
);
$rackspace->storeObject('test',$name,$file,$metadata);
if ($rackspace->isSuccessful()) {
    echo 'Object stored successfully';
} else {
    printf("ERROR: %s",$rackspace->getErrorMsg());
}
Example: create a new instance (server)
$user = 'username';
$key = 'secret key';

$rackspace = new ZendServiceRackspaceServers($user,$key);

$data = array (
    'name'     => 'test',
    'imageId' => '49',
    'flavorId' => '1',
);
$server = $rackspace->createServer($data);

if (!$rackspace->isSuccessful()) {
    die('ERROR: '.$rackspace->getErrorMsg());
}

printf("Server name    : %sn",$server->getName());
printf("Server Id      : %sn",$server->getId());
printf("Admin password : %sn",$server->getAdminPass());
Simple Cloud API
Simple Cloud API
• The Simple Cloud API is a common API for
  accessing cloud application services offered by
  multiple vendors
• Starting from November 2010 the Simple Cloud
  API is part of Zend Framework under the
  classname:
   – Zend_Cloud (ZF1)
   – ZendCloud (ZF2)
Why we need it?
• Vendor lock-in
  – In economics, vendor lock-in makes a
    customer dependent on a vendor for products
    and services, unable to use another vendor
    without substantial switching costs
• Portability
  – reuse the existing code instead of creating
    new code when moving software from an
    environment to another
The architecture




             ZendCloud


             ZendService
The architecture (2)



                ZendCloud
 Document   Queue       Storage   Infrastructure



               ZendService
ZendCloud as abstraction
• ZendCloud is an abstraction of the main
  features of some cloud vendors
• Vendor specific functions may not be included in
  ZendCloud (for portability reason)
  – For instance, Amazon S3 has a cleanBucket
    operation that is not implemented in ZendCloud
• You can access the concrete adapters to use
  specific functions (getAdapter)
ZendCloudDocumentService
• Abstracts the interfaces to all major document
  databases - both in the cloud and locally
  deployed
• Adapters:
   – Amazon SimpleDB
   – Windows Azure
ZendCloudQueueService
• The QueueService implements access to
  message queues available as local or remote
  services.
• Adapters:
   – Amazon Sqs
   – Windows Azure
   – ZendQueue
ZendCloudStorageService
• The storage service in the Simple Cloud API
  implements a basic interface for file storage on
  the cloud
• Adapters:
   – Amazon S3
   – Windows Azure
   – Nirvanix
   – Filesystem
   – Rackspace (under development)
ZendCloud
Infrastructure
ZendCloudInfrastructure
• Manage instances (servers) of a cloud
  computing infrastructure
• Release ZF1: 1.12+, ZF2: dev3+
• Adapters:
   – Amazon Ec2
   – Rackspace Cloud Servers
   – GoGrid (under development)
   – Windows Azure (under development)
Basic operations
•   Create a new instance
•   Delete an instance
•   Start/stop/reboot an instance
•   List available instances
•   Get the status of an instance (running, stop, etc)
•   Monitor an instance (CPU, RAM, Network, etc)
•   Deploy an instance
     – Execute remote shell command (using SSH2)
Image of an instance
• An image of an instance is the collection of the
  following information:
   – Operating system (OS)
   – Memory available (RAM)
   – CPU type
Example: Ec2 Adapter
use ZendCloudInfrastructureAdapterEc2 as Ec2Adapter,
    ZendCloudInfrastructureFactory;

$key    = 'key';
$secret = 'secret';
$region = 'region';

$infrastructure = Factory::getAdapter(array(
    Factory::INFRASTRUCTURE_ADAPTER_KEY =>
'ZendCloudInfrastructureAdapterEc2',
    Ec2Adapter::AWS_ACCESS_KEY => $key,
    Ec2Adapter::AWS_SECRET_KEY => $secret,
    Ec2Adapter::AWS_REGION     => $region,
));
Example: create an instance
$param= array (
    'imageId'      => 'your-image-id',
    'instanceType' => 'your-instance-type',
);

$instance= $infrastructure->createInstance('name', $param);

if ($instance===false) {
   die ('Error');
}

printf ("Name of the instance: %sn", $instance->getName());
printf ("ID of the instance : %sn", $instance->getId());
Example: reboot and wait for status

if (!$infrastructure->rebootInstance('instance-id')) {
    die ('Error in the execution of the reboot command');
}
echo 'Reboot command executed successfully';

if ($infrastructure->waitStatusInstance('instance-id',
Instance::STATUS_RUNNING)) {
    echo 'The instance is ready';
} else {
    echo 'The instance is not ready yet';
}
Wait for status change
waitStatusInstance (string $id, string $status,integer
$timeout=30)
• Wait the status change of an instance for a
  maximum time of n seconds (30 by default).
• Return true if the status changes as expected,
  false otherwise.
Example: monitor an instance
use ZendCloudInfrastructureInstance;

$cpuUsage= $infrastructure->monitorInstance(
            'instance-id',Instance::MONITOR_CPU);

var_dump($cpuUsage);


array(2) {                                   [2] => array(2) {
 ["series"] => array(3) {                      ["timestamp"] => int(1318348920)
   [0]=> array(2) {                            ["value"] => int(60)
     ["timestamp"] => int(1318348800)        }
     ["value"]=> int(80)                    }
   }                                        ["average"] => string(3) "70%"
   [1]=> array(2) {                     }
     ["timestamp"] => int(1318348860)
     ["value"] => int(70)
   }
Example: deploy an instance

$nodeId= 'id-instance';

$param= array (
    Instance::SSH_USERNAME => 'username',
    Instance::SSH_PASSWORD => 'password'
);

$cmd= 'ls -la /var/www';

$output= $infrastructure->deployInstance($nodeId,$param,$cmd);

echo "The files in the DocumentRoot of the $nodeId instance
are:n";
print_r ($output);


Note: require the SSH2 extension
Thank you!
• Vote this talk:
  – http://joind.in/3880

• Comments and feedbacks:
  – enrico@zend.com

More Related Content

What's hot

9 password security
9   password security9   password security
9 password security
drewz lin
 
Java Symmetric
Java SymmetricJava Symmetric
Java Symmetric
phanleson
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Howard Lewis Ship
 
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Marrow: A Meta-Framework for Python 2.6+ and 3.1+Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
ConFoo
 
One Step Ahead of Cheaters -- Instrumenting Android Emulators
One Step Ahead of Cheaters -- Instrumenting Android EmulatorsOne Step Ahead of Cheaters -- Instrumenting Android Emulators
One Step Ahead of Cheaters -- Instrumenting Android Emulators
Priyanka Aash
 
Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?
ConFoo
 

What's hot (20)

9 password security
9   password security9   password security
9 password security
 
Secure password - CYBER SECURITY
Secure password - CYBER SECURITYSecure password - CYBER SECURITY
Secure password - CYBER SECURITY
 
Passwords presentation
Passwords presentationPasswords presentation
Passwords presentation
 
Java Symmetric
Java SymmetricJava Symmetric
Java Symmetric
 
Bring your infrastructure under control with Infrastructor
Bring your infrastructure under control with InfrastructorBring your infrastructure under control with Infrastructor
Bring your infrastructure under control with Infrastructor
 
Strong cryptography in PHP
Strong cryptography in PHPStrong cryptography in PHP
Strong cryptography in PHP
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
 
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
 
Gr8conf EU 2018 - Bring you infrastructure under control with Infrastructor
Gr8conf EU 2018 - Bring you infrastructure under control with InfrastructorGr8conf EU 2018 - Bring you infrastructure under control with Infrastructor
Gr8conf EU 2018 - Bring you infrastructure under control with Infrastructor
 
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Marrow: A Meta-Framework for Python 2.6+ and 3.1+Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
 
One Step Ahead of Cheaters -- Instrumenting Android Emulators
One Step Ahead of Cheaters -- Instrumenting Android EmulatorsOne Step Ahead of Cheaters -- Instrumenting Android Emulators
One Step Ahead of Cheaters -- Instrumenting Android Emulators
 
Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009
 
NodeJS
NodeJSNodeJS
NodeJS
 
Effective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 DevelopersEffective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 Developers
 
Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing Nodejs
 
Testing NodeJS Security
Testing NodeJS SecurityTesting NodeJS Security
Testing NodeJS Security
 
Hacking NodeJS applications for fun and profit
Hacking NodeJS applications for fun and profitHacking NodeJS applications for fun and profit
Hacking NodeJS applications for fun and profit
 
Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012
 

Viewers also liked

Realtime Communication Techniques with PHP
Realtime Communication Techniques with PHPRealtime Communication Techniques with PHP
Realtime Communication Techniques with PHP
WaterSpout
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
Elizabeth Smith
 
Angular workflow with gulp.js
Angular workflow with gulp.jsAngular workflow with gulp.js
Angular workflow with gulp.js
Cihad Horuzoğlu
 

Viewers also liked (14)

Cryptography in PHP: use cases
Cryptography in PHP: use casesCryptography in PHP: use cases
Cryptography in PHP: use cases
 
Foundation vs Bootstrap - CC FE & UX
Foundation vs Bootstrap - CC FE & UXFoundation vs Bootstrap - CC FE & UX
Foundation vs Bootstrap - CC FE & UX
 
Follow the White Rabbit - Message Queues with PHP
Follow the White Rabbit - Message Queues with PHPFollow the White Rabbit - Message Queues with PHP
Follow the White Rabbit - Message Queues with PHP
 
Open a window, see the clouds - php|tek 2011
Open a window, see the clouds - php|tek 2011Open a window, see the clouds - php|tek 2011
Open a window, see the clouds - php|tek 2011
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
 
Realtime Communication Techniques with PHP
Realtime Communication Techniques with PHPRealtime Communication Techniques with PHP
Realtime Communication Techniques with PHP
 
Getting started with CSS frameworks using Zurb foundation
Getting started with CSS frameworks using Zurb foundationGetting started with CSS frameworks using Zurb foundation
Getting started with CSS frameworks using Zurb foundation
 
Web socket with php v2
Web socket with php v2Web socket with php v2
Web socket with php v2
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
 
Phone calls and sms from php
Phone calls and sms from phpPhone calls and sms from php
Phone calls and sms from php
 
Mobile Push Notifications
Mobile Push NotificationsMobile Push Notifications
Mobile Push Notifications
 
MOM - Message Oriented Middleware
MOM - Message Oriented MiddlewareMOM - Message Oriented Middleware
MOM - Message Oriented Middleware
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
 
Angular workflow with gulp.js
Angular workflow with gulp.jsAngular workflow with gulp.js
Angular workflow with gulp.js
 

Similar to Manage cloud infrastructures using Zend Framework 2 (and ZF1)

대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
Amazon Web Services Korea
 
Playing with php_on_azure
Playing with php_on_azurePlaying with php_on_azure
Playing with php_on_azure
CEDRIC DERUE
 
Puppetpreso
PuppetpresoPuppetpreso
Puppetpreso
ke4qqq
 
Puppet and CloudStack
Puppet and CloudStackPuppet and CloudStack
Puppet and CloudStack
ke4qqq
 
Infrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStackInfrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStack
ke4qqq
 

Similar to Manage cloud infrastructures using Zend Framework 2 (and ZF1) (20)

How to Manage Cloud Infrastructures using Zend Framework
How to Manage Cloud Infrastructures using Zend FrameworkHow to Manage Cloud Infrastructures using Zend Framework
How to Manage Cloud Infrastructures using Zend Framework
 
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
 
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...
Global Windows Azure Bootcamp : Cedric Derue playing with php on azure. (spon...
 
Playing with php_on_azure
Playing with php_on_azurePlaying with php_on_azure
Playing with php_on_azure
 
ILM - Pipeline in the cloud
ILM - Pipeline in the cloudILM - Pipeline in the cloud
ILM - Pipeline in the cloud
 
Reusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modulesReusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modules
 
Puppetpreso
PuppetpresoPuppetpreso
Puppetpreso
 
Automation with Packer and TerraForm
Automation with Packer and TerraFormAutomation with Packer and TerraForm
Automation with Packer and TerraForm
 
Managing Infrastructure as Code
Managing Infrastructure as CodeManaging Infrastructure as Code
Managing Infrastructure as Code
 
Amazon Web Services for PHP Developers
Amazon Web Services for PHP DevelopersAmazon Web Services for PHP Developers
Amazon Web Services for PHP Developers
 
Puppet and CloudStack
Puppet and CloudStackPuppet and CloudStack
Puppet and CloudStack
 
Building a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless frameworkBuilding a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless framework
 
Puppet and Apache CloudStack
Puppet and Apache CloudStackPuppet and Apache CloudStack
Puppet and Apache CloudStack
 
Infrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStackInfrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStack
 
How to build a Citrix infrastructure on AWS
How to build a Citrix infrastructure on AWSHow to build a Citrix infrastructure on AWS
How to build a Citrix infrastructure on AWS
 
AWS CloudFormation Intrinsic Functions and Mappings
AWS CloudFormation Intrinsic Functions and Mappings AWS CloudFormation Intrinsic Functions and Mappings
AWS CloudFormation Intrinsic Functions and Mappings
 
Migrating existing open source machine learning to azure
Migrating existing open source machine learning to azureMigrating existing open source machine learning to azure
Migrating existing open source machine learning to azure
 
Cloud Computing in PHP With the Amazon Web Services
Cloud Computing in PHP With the Amazon Web ServicesCloud Computing in PHP With the Amazon Web Services
Cloud Computing in PHP With the Amazon Web Services
 
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivSelf Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
 
데이터 마이그레이션 AWS와 같이하기 - 김일호 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
데이터 마이그레이션 AWS와 같이하기 - 김일호 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming데이터 마이그레이션 AWS와 같이하기 - 김일호 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
데이터 마이그레이션 AWS와 같이하기 - 김일호 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
 

More from Enrico Zimuel

More from Enrico Zimuel (20)

Password (in)security
Password (in)securityPassword (in)security
Password (in)security
 
Integrare Zend Framework in Wordpress
Integrare Zend Framework in WordpressIntegrare Zend Framework in Wordpress
Integrare Zend Framework in Wordpress
 
Quick start on Zend Framework 2
Quick start on Zend Framework 2Quick start on Zend Framework 2
Quick start on Zend Framework 2
 
Introduzione alla Posta Elettronica Certificata (PEC): le regole tecniche
Introduzione alla Posta Elettronica Certificata (PEC): le regole tecnicheIntroduzione alla Posta Elettronica Certificata (PEC): le regole tecniche
Introduzione alla Posta Elettronica Certificata (PEC): le regole tecniche
 
PHP goes mobile
PHP goes mobilePHP goes mobile
PHP goes mobile
 
Zend Framework 2
Zend Framework 2Zend Framework 2
Zend Framework 2
 
Framework software e Zend Framework
Framework software e Zend FrameworkFramework software e Zend Framework
Framework software e Zend Framework
 
How to scale PHP applications
How to scale PHP applicationsHow to scale PHP applications
How to scale PHP applications
 
Velocizzare Joomla! con Zend Server Community Edition
Velocizzare Joomla! con Zend Server Community EditionVelocizzare Joomla! con Zend Server Community Edition
Velocizzare Joomla! con Zend Server Community Edition
 
Zend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applicationsZend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applications
 
XCheck a benchmark checker for XML query processors
XCheck a benchmark checker for XML query processorsXCheck a benchmark checker for XML query processors
XCheck a benchmark checker for XML query processors
 
Introduzione alle tabelle hash
Introduzione alle tabelle hashIntroduzione alle tabelle hash
Introduzione alle tabelle hash
 
Crittografia quantistica: fantascienza o realtà?
Crittografia quantistica: fantascienza o realtà?Crittografia quantistica: fantascienza o realtà?
Crittografia quantistica: fantascienza o realtà?
 
Introduzione alla crittografia
Introduzione alla crittografiaIntroduzione alla crittografia
Introduzione alla crittografia
 
Crittografia è sinonimo di sicurezza?
Crittografia è sinonimo di sicurezza?Crittografia è sinonimo di sicurezza?
Crittografia è sinonimo di sicurezza?
 
Sviluppo di applicazioni sicure
Sviluppo di applicazioni sicureSviluppo di applicazioni sicure
Sviluppo di applicazioni sicure
 
Misure minime di sicurezza informatica
Misure minime di sicurezza informaticaMisure minime di sicurezza informatica
Misure minime di sicurezza informatica
 
PHP e crittografia
PHP e crittografiaPHP e crittografia
PHP e crittografia
 
La sicurezza delle applicazioni in PHP
La sicurezza delle applicazioni in PHPLa sicurezza delle applicazioni in PHP
La sicurezza delle applicazioni in PHP
 
Firma digitale
Firma digitaleFirma digitale
Firma digitale
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Manage cloud infrastructures using Zend Framework 2 (and ZF1)

  • 1. Enrico Zimuel Zend Technologies Manage Cloud Infrastructures in PHP using Zend Framework 2 (and ZF1)
  • 2. About me • Software Engineer since 1996 – Assembly x86, C/C++, Java, Perl, PHP • Enjoying PHP since 1999 • PHP Engineer at Zend since 2008 • ZF Core Team from April 2011 • B.Sc. Computer Science and Economics from University of Pescara (Italy) • Email: enrico@zend.com
  • 3. Summary • Cloud computing in PHP • ZendServiceRackspace • Examples • Simple Cloud API • ZendCloudInfrastructure for ZF2 and ZF1 • Adapters: Amazon Ec2, Rackspace • Examples
  • 4. Cloud computing “Cloud computing is the delivery of computing as a service rather than a product, whereby shared resources, software, and information are provided to computers and other devices as a utility over a network (tipically internet)” Wikipedia
  • 5. Cloud computing What does it means? Actually, nothing useful.
  • 6. Cloud computing Do not try to define it, just use it!
  • 7. How to use it? • API (Application Programming Interface), to interact with cloud services • Typically use REST-based APIs • Each vendors uses a property API: – Different API for each vendor – Use of specific PHP libraries (coming from community or vendors)
  • 8. Some PHP libraries for Cloud • Amazon Web Services – AWS SDK for PHP, http://aws.amazon.com/sdkforphp/ • Windows Azure – PHPAzure, http://phpazure.codeplex.com/ • Rackspace – php-cloudfiles, http://bit.ly/ptJa1Y • GoGrid – GoGridClient, http://bit.ly/o7MeLA
  • 9. ZF service classes for Cloud • ZendServiceAmazon • ZendServiceGoGrid (under development) • ZendServiceNirvanix • ZendServiceRackspace • ZendServiceWindowsAzure
  • 11. ZendServiceRackspace • Manage the following cloud services of Rackspace: – Servers – Files • Provide a full OO interface for the API of Rackspace (ver 1.0) • Release: ZF1 1.12+, ZF2 dev3+
  • 12. Example: authentication $user = 'username'; $key = 'secret key'; $rackspace = new ZendServiceRackspaceFiles($user,$key); if ($rackspace->authenticate()) { echo "Authentication successfully"; } else { printf("ERROR: %s",$rackspace->getErrorMsg()); }
  • 13. Example: store an image in a container … $container = $rackspace->createContainer('test'); if (!$rackspace->isSuccessful()) { die('ERROR: '.$rackspace->getErrorMsg()); } $name = 'example.jpg'; $file = file_get_contents($name); $metadata = array ( 'foo' => 'bar' ); $rackspace->storeObject('test',$name,$file,$metadata); if ($rackspace->isSuccessful()) { echo 'Object stored successfully'; } else { printf("ERROR: %s",$rackspace->getErrorMsg()); }
  • 14. Example: create a new instance (server) $user = 'username'; $key = 'secret key'; $rackspace = new ZendServiceRackspaceServers($user,$key); $data = array ( 'name' => 'test', 'imageId' => '49', 'flavorId' => '1', ); $server = $rackspace->createServer($data); if (!$rackspace->isSuccessful()) { die('ERROR: '.$rackspace->getErrorMsg()); } printf("Server name : %sn",$server->getName()); printf("Server Id : %sn",$server->getId()); printf("Admin password : %sn",$server->getAdminPass());
  • 16. Simple Cloud API • The Simple Cloud API is a common API for accessing cloud application services offered by multiple vendors • Starting from November 2010 the Simple Cloud API is part of Zend Framework under the classname: – Zend_Cloud (ZF1) – ZendCloud (ZF2)
  • 17. Why we need it? • Vendor lock-in – In economics, vendor lock-in makes a customer dependent on a vendor for products and services, unable to use another vendor without substantial switching costs • Portability – reuse the existing code instead of creating new code when moving software from an environment to another
  • 18. The architecture ZendCloud ZendService
  • 19. The architecture (2) ZendCloud Document Queue Storage Infrastructure ZendService
  • 20. ZendCloud as abstraction • ZendCloud is an abstraction of the main features of some cloud vendors • Vendor specific functions may not be included in ZendCloud (for portability reason) – For instance, Amazon S3 has a cleanBucket operation that is not implemented in ZendCloud • You can access the concrete adapters to use specific functions (getAdapter)
  • 21. ZendCloudDocumentService • Abstracts the interfaces to all major document databases - both in the cloud and locally deployed • Adapters: – Amazon SimpleDB – Windows Azure
  • 22. ZendCloudQueueService • The QueueService implements access to message queues available as local or remote services. • Adapters: – Amazon Sqs – Windows Azure – ZendQueue
  • 23. ZendCloudStorageService • The storage service in the Simple Cloud API implements a basic interface for file storage on the cloud • Adapters: – Amazon S3 – Windows Azure – Nirvanix – Filesystem – Rackspace (under development)
  • 25. ZendCloudInfrastructure • Manage instances (servers) of a cloud computing infrastructure • Release ZF1: 1.12+, ZF2: dev3+ • Adapters: – Amazon Ec2 – Rackspace Cloud Servers – GoGrid (under development) – Windows Azure (under development)
  • 26. Basic operations • Create a new instance • Delete an instance • Start/stop/reboot an instance • List available instances • Get the status of an instance (running, stop, etc) • Monitor an instance (CPU, RAM, Network, etc) • Deploy an instance – Execute remote shell command (using SSH2)
  • 27. Image of an instance • An image of an instance is the collection of the following information: – Operating system (OS) – Memory available (RAM) – CPU type
  • 28. Example: Ec2 Adapter use ZendCloudInfrastructureAdapterEc2 as Ec2Adapter, ZendCloudInfrastructureFactory; $key = 'key'; $secret = 'secret'; $region = 'region'; $infrastructure = Factory::getAdapter(array( Factory::INFRASTRUCTURE_ADAPTER_KEY => 'ZendCloudInfrastructureAdapterEc2', Ec2Adapter::AWS_ACCESS_KEY => $key, Ec2Adapter::AWS_SECRET_KEY => $secret, Ec2Adapter::AWS_REGION => $region, ));
  • 29. Example: create an instance $param= array ( 'imageId' => 'your-image-id', 'instanceType' => 'your-instance-type', ); $instance= $infrastructure->createInstance('name', $param); if ($instance===false) { die ('Error'); } printf ("Name of the instance: %sn", $instance->getName()); printf ("ID of the instance : %sn", $instance->getId());
  • 30. Example: reboot and wait for status if (!$infrastructure->rebootInstance('instance-id')) { die ('Error in the execution of the reboot command'); } echo 'Reboot command executed successfully'; if ($infrastructure->waitStatusInstance('instance-id', Instance::STATUS_RUNNING)) { echo 'The instance is ready'; } else { echo 'The instance is not ready yet'; }
  • 31. Wait for status change waitStatusInstance (string $id, string $status,integer $timeout=30) • Wait the status change of an instance for a maximum time of n seconds (30 by default). • Return true if the status changes as expected, false otherwise.
  • 32. Example: monitor an instance use ZendCloudInfrastructureInstance; $cpuUsage= $infrastructure->monitorInstance( 'instance-id',Instance::MONITOR_CPU); var_dump($cpuUsage); array(2) { [2] => array(2) { ["series"] => array(3) { ["timestamp"] => int(1318348920) [0]=> array(2) { ["value"] => int(60) ["timestamp"] => int(1318348800) } ["value"]=> int(80) } } ["average"] => string(3) "70%" [1]=> array(2) { } ["timestamp"] => int(1318348860) ["value"] => int(70) }
  • 33. Example: deploy an instance $nodeId= 'id-instance'; $param= array ( Instance::SSH_USERNAME => 'username', Instance::SSH_PASSWORD => 'password' ); $cmd= 'ls -la /var/www'; $output= $infrastructure->deployInstance($nodeId,$param,$cmd); echo "The files in the DocumentRoot of the $nodeId instance are:n"; print_r ($output); Note: require the SSH2 extension
  • 34. Thank you! • Vote this talk: – http://joind.in/3880 • Comments and feedbacks: – enrico@zend.com