istic-openstack/server/create_serv.php
2016-03-21 06:47:01 +01:00

55 lines
1.2 KiB
PHP
Executable file

<?php
ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris");
require 'vendor/autoload.php';
$options = Array();
$options["user"] = Array("name"=>"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]);
$options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"]));
$options["authUrl"] = "http://148.60.11.31:5000/v3";
$openstack = new OpenStack\OpenStack($options);
$compute=$openstack->computeV2(["region" => "RegionOne"]);
$servers = $compute->listServers(true);
foreach($servers as $server)
{
$monserv = $server;
echo $server->name."<br>";
}
echo "<br><br>";
$images = $compute->ListImages();
$monim = "";
foreach($images as $image)
{
$monim = $image;
echo $image->name."<br>";
break;
}
$flavors = $compute->ListFlavors();
echo "<br><br>";
$monflav = "";
foreach($flavors as $flavor)
{
$monflav=$flavor;
echo $flavor->name."<br>";
break;
}
$response= $compute->createServer(array('name' => "TestOthmane2",'imageId' => $monim->id , 'flavorId'=>$monflav->id , "networks" => array
( array("uuid"=> "251b4641-20ff-4a72-8549-1758788b51ce"))));