php-opencloud / openstack Goto Github PK
View Code? Open in Web Editor NEWPHP SDK for OpenStack clouds
License: Apache License 2.0
PHP SDK for OpenStack clouds
License: Apache License 2.0
I can connect and reboot server, but how can I stop it completely (shutdown) and then start it again ?
Hi !
I want to know how I can connected in vnc with php opencloud 'openstack'?
someone can help please ?
Currently i can't find a way to get the storage url from this php client. I know how to get it using swift cli, but i can't figure out how to get it here.
in swift cli i can do
swift --info --os-auth-url https://identity.open.softlayer.com/v3 --auth-version 3 --os-region 'dallas' --os-project-id kjdjkasdhkjh28h28hodasdasd --os-user-id kajsdfhkajhfkjaf2i7y9882dsaj --os-password 'jkhasdASKJH28-1d' stat -v
and that will return
StorageURL: https://dal.objectstorage.open.softlayer.com/v1/AUTH_kjdjkasdhkjh28h28hodasdasd
Auth Token: <my auth token>
Account: AUTH_kjdjkasdhkjh28h28hodasdasd
Containers: 1
Objects: 12
Bytes: 4301436
Containers in policy "standard": 1
Objects in policy "standard": 12
Bytes in policy "standard": 4301436
X-Trans-Id: <my trans id>
X-Account-Project-Domain-Id: <account project domain id>
X-Timestamp: 1447705889.39341
Content-Type: text/plain; charset=utf-8
Accept-Ranges: bytes
When calling $container->listObjects(['prefix' => $prefix]);
I would expect to cause a single http request, but it is taking two. The solution is to change the method shouldNotSendAnotherRequest
in Iterator to the following.
private function shouldNotSendAnotherRequest() {
return $this->totalReached() || ($this->count > 0);
}
But that probably has consequences for other calls. So I cannot create the PR for this. My knowledge of this library is too limited.
Furthermore, the resulting objects that are generated through listObjects
do no carry a containerName. Now, in this case I found a solution too. But again, I cannot see whether this is a valid solution.
In the listObjects method one should pass the container name to the model, like so.
return $this->model(Object::class, ['containerName' => $this->name])->enumerate($this->api->getContainer(), $options, $mapFn);
But, then with the enumerate
call, the container is lost again when newInstance
is called in enumerate
. I would propose to change the call to newInstance
to $resource = clone $this
;
When I retrieve the details of an instance I get an object like:
object(OpenStack\Compute\v2\Models\Server)#396 (22) {
["id"]=>
string(36) "f48420f1-0d2d-470b-807d-d4d75ae50118"
["ipv4"]=>
string(0) ""
["ipv6"]=>
string(0) ""
["addresses"]=>
array(1) {
["net1"]=>
array(1) {
[0]=>
array(4) {
["OS-EXT-IPS-MAC:mac_addr"]=>
string(17) "ff:ff:ff:ff:ff:ff"
["version"]=>
int(4)
["addr"]=>
string(12) "1.2.3.4"
["OS-EXT-IPS:type"]=>
string(5) "fixed"
}
}
}
["created"]=>
object(DateTimeImmutable)#387 (3) {
["date"]=>
string(26) "2017-02-09 16:07:18.000000"
["timezone_type"]=>
int(2)
["timezone"]=>
string(1) "Z"
}
["updated"]=>
object(DateTimeImmutable)#399 (3) {
["date"]=>
string(26) "2017-02-09 16:10:48.000000"
["timezone_type"]=>
int(2)
["timezone"]=>
string(1) "Z"
}
["flavor"]=>
object(OpenStack\Compute\v2\Models\Flavor)#403 (11) {
["disk"]=>
NULL
["id"]=>
string(36) "520cabc9-d1a0-4230-9733-b65d46effa75"
["name"]=>
NULL
["ram"]=>
NULL
["swap"]=>
NULL
["vcpus"]=>
NULL
["links"]=>
array(1) {
[0]=>
array(2) {
["href"]=>
string(112) "http://controller:8774/4767022a0711413ab071387adc19a0ee/flavors/520cabc9-d1a0-4230-9733-b65d46effa75"
["rel"]=>
string(8) "bookmark"
}
}
["resourceKey"]=>
string(6) "flavor"
["resourcesKey"]=>
string(7) "flavors"
["markerKey"]=>
NULL
["aliases"]=>
array(0) {
}
}
["hostId"]=>
string(56) "94f69c409699e4eb931fd628eaccf5515361d1e73d8332505c3a0059"
["image"]=>
object(OpenStack\Compute\v2\Models\Image)#397 (14) {
["id"]=>
string(36) "f377dc22-2782-45bb-b79e-3a808fffc420"
["links"]=>
array(1) {
[0]=>
array(2) {
["href"]=>
string(111) "http://controller:8774/4767022a0711413ab071387adc19a0ee/images/f377dc22-2782-45bb-b79e-3a808fffc420"
["rel"]=>
string(8) "bookmark"
}
}
["metadata"]=>
NULL
["minDisk"]=>
NULL
["minRam"]=>
NULL
["name"]=>
NULL
["progress"]=>
NULL
["status"]=>
NULL
["created"]=>
NULL
["updated"]=>
NULL
["resourceKey"]=>
string(5) "image"
["resourcesKey"]=>
string(6) "images"
["markerKey"]=>
NULL
["aliases"]=>
array(0) {
}
}
["links"]=>
array(2) {
[0]=>
array(2) {
["href"]=>
string(117) "http://controller:8774/v2.1/4767022a0711413ab071387adc19a0ee/servers/f48420f1-0d2d-470b-807d-d4d75ae50118"
["rel"]=>
string(4) "self"
}
[1]=>
array(2) {
["href"]=>
string(112) "http://controller:8774/4767022a0711413ab071387adc19a0ee/servers/f48420f1-0d2d-470b-807d-d4d75ae50118"
["rel"]=>
string(8) "bookmark"
}
}
["metadata"]=>
array(0) {
}
["name"]=>
string(9) "testserver"
["progress"]=>
int(0)
["status"]=>
string(6) "ACTIVE"
["tenantId"]=>
string(32) "4767022a0711413ab071387adc19a0ee"
["userId"]=>
string(32) "e471e539851042f1ab41fde0a18c50d3"
["adminPass"]=>
NULL
["taskState"]=>
NULL
["resourceKey"]=>
string(6) "server"
["resourcesKey"]=>
string(7) "servers"
["markerKey"]=>
string(2) "id"
["aliases"]=>
array(7) {
["block_device_mapping_v2"]=>
string(18) "blockDeviceMapping"
["accessIPv4"]=>
string(4) "ipv4"
["accessIPv6"]=>
string(4) "ipv6"
["tenant_id"]=>
string(8) "tenantId"
["user_id"]=>
string(6) "userId"
["security_groups"]=>
string(14) "securityGroups"
["OS-EXT-STS:task_state"]=>
string(9) "taskState"
}
}
Any pointers?
In our application we are currently getting "cURL error 1: Protocol %7Bhttps not supported or disabled in libcurl." We are having a difficult time debugging this issue as we know that https is supported in our environment. We saw that guzzlehttp has a 'debug' argument but could not find a way to use this feature with the current SDK. Is this already supported or are there any intentions of supporting it in the future?
I'm guessing that a lot of users will be thrown off by the one-off nature of generators, so document this and explain how they can re-use if necessary
maybe list services, rather than a list of arbitrary namespaces
When creating a new Port, the user should be able to specify the desired fixedIPs for the new Port, Other SDKs usually use an array like set-up. The parameter would be an array of arrays, each specifying the subnet id and the IP address. Example: array(array('subnetId' => '75906d20-6625-11e4-9803-0800200c9a66', 'ipAddress' => '192.168.199.17'))
At this point, the API does not do anything with a fixedIPs paramter although the Port class has a field for the fixedIPs.
As a follow-up to #27, the instructions and discussion there are a little out-of-date as the file structure has been refactored since that time. Also, it appears the method to retrieve the public URI is only present on the Object object - Object::getPublicUri()
.
But what if I want to get a base URI for, say, a container? Reading over the code it looks like the base_uri
setting of the Guzzle client set on the Container
resource would be the place to get this, but the client and the methods related to querying it are all protected. Any thoughts?
So far the only way I've determined how to do this is to retrieve a Token and then introspect it, basically copied out of the Identity service's authenticate()
code:
$token = $client->identityV3()->generateToken(['user' => $this->configuration['user']]);
$basePath = $token->catalog->getServiceUrl('swift', 'object-store', $this->configuration['region'], 'public');
Hello !
I don't know how to stop or start a server with PHP-opencloud, i didn't find any api call to these two functions.
someone can help please ?
Hi,
when using the computeV2()->getLimits() call to fetch the limits and quota informations for a given ProjectID, the data for volume usage is missing?
From the SDK call I get this:
OpenStack\Compute\v2\Models\Limit
Object
(
[rate] => Array
(
)
[absolute] => Array
(
[maxServerMeta] => 1024
[maxPersonality] => -1
[totalServerGroupsUsed] => 0
[maxImageMeta] => 1024
[maxPersonalitySize] => 102400
[maxTotalKeypairs] => -1
[maxSecurityGroupRules] => 20
[maxServerGroups] => 10
[totalCoresUsed] => 1
[totalRAMUsed] => 2048
[totalInstancesUsed] => 1
[maxSecurityGroups] => 10
[totalFloatingIpsUsed] => 0
[maxTotalCores] => 20
[maxServerGroupMembers] => 10
[maxTotalFloatingIps] => 100
[totalSecurityGroupsUsed] => 1
[maxTotalInstances] => -1
[maxTotalRAMSize] => 81920
)
[resourceKey:protected] => limits
[aliases:protected] => Array
(
)
)
And when using the Openstack commandclient, I get this:
+--------------------------+--------+
| Name | Value |
+--------------------------+--------+
| maxServerMeta | 1024 |
| maxTotalInstances | -1 |
| maxPersonality | -1 |
| totalServerGroupsUsed | 0 |
| maxImageMeta | 1024 |
| maxPersonalitySize | 102400 |
| maxTotalRAMSize | 81920 |
| maxServerGroups | 10 |
| maxSecurityGroupRules | 20 |
| maxTotalKeypairs | -1 |
| totalCoresUsed | 1 |
| totalRAMUsed | 2048 |
| maxSecurityGroups | 10 |
| totalFloatingIpsUsed | 0 |
| totalInstancesUsed | 1 |
| maxServerGroupMembers | 10 |
| maxTotalFloatingIps | 100 |
| totalSecurityGroupsUsed | 1 |
| maxTotalCores | 20 |
| totalSnapshotsUsed | 0 |
| maxTotalBackups | 10 |
| maxTotalVolumeGigabytes | 2000 |
| maxTotalSnapshots | -1 |
| maxTotalBackupGigabytes | 1000 |
| totalBackupGigabytesUsed | 0 |
| maxTotalVolumes | -1 |
| totalVolumesUsed | 0 |
| totalBackupsUsed | 0 |
| totalGigabytesUsed | 0 |
+--------------------------+--------+
Is there any chance to get the missing data (totalVolumesUsed, totalGigabytesUsed etc.) via the SDK call?
I am using openstack php V2 library to create security group rule.
tcp, icmp and udp working fine i am creating rules for them but i am having problem creating all other rules like all_icmp, all_tcp and all others.
Anyone can help me?
Thanks in advance.
Hello,
Why do you require such an old version (2 year old) of json-schema ?
https://github.com/justinrainbow/json-schema/releases
Thanks
Hello.
I'm trying to get the projects filtering them by domain_id. As a result i receive all the projects (no filtering) from Keystone.
In logs i see this:
2015-08-12 02:30:39.035 17756 INFO keystone.common.wsgi [-] GET /projects?domainId=a40e2b97749a41e58e23ad60e421559b
So the problem is that Keystone receives "domainId" and not "domain_id".
Here is the source code:
<?php
require 'openstack/vendor/autoload.php';
$openstack = new OpenStack\OpenStack([
'authUrl' => 'http://test.local:35357/v3',
'region' => 'REG1',
'user' => [
'name' => 'admin',
'password' => '......',
'domain' => [ 'name' => 'default' ]
],
'scope' => [
'domain' => [
'id' => 'default'
]
]
]);
$client = $openstack->identityV3();
foreach ($client->listProjects(['domainId' => 'a40e2b97749a41e58e23ad60e421559b']) as $project) {
print $project->name;
print "\n";
}
Hello,
excuse me for my not very good english :)
I think there is a mistake in the lines 191 of the file src/Compute/v2/Api.php.
The code is : $definition['path'] += '/detail';
maybe, to concatenate two chains it would be : $definition['path'] .= '/detail';
i hope i haven't made myself a mistake, and i want to say thank you for your great job!
for example, server IDs are provided by the service, not the user, so it doesn't need to be documented. an extra key in the Params.php should do the trick.
Is there any way to update password through keystone v3?
There is nothing on blockstorage documentation
@jamiehannaford Any reason why these params are set to false by default?
https://github.com/php-opencloud/openstack/blob/master/src/OpenStack.php#L134
Are you expecting user to set it manually like this?
$identity = $openstack->identityV3(
[
'region' => '{region}',
'catalogName' => 'keystone',
'catalogType' => 'identity',
]
);
Hey, is there any plan to implement a method to create flavours?
Thanks
I followed tutorial here https://developer.ibm.com/recipes/tutorials/use-php-to-leverage-object-storage-for-bluemix/
It should be OpenStack\OpenStack.. my bad
But I think you should show how to define $openstack in the documentation for the starter...
Fatal error: Uncaught Error: Class 'OpenStackOpenStack'
This is my code
require 'vendor/autoload.php';
//Set up OpenStack configuration
$openstack = new OpenStackOpenStack([
'authUrl' => $authUrl,
'region' => $region,
'user' => [
'id' => $userId,
'password' => $password
],
'scope' => [
'project' => ['id' => $projectId]
]
]);
//Get Token
$identity = $openstack->identityV3();
$token = $identity->generateToken([
'user' => [
'id' => $userId,
'password' => $password
]
]);
//access Keystone token Id
$tokenId = $token->getId();
$containerName = 'MyNewContainer';
//Uses the same OpenStack object created above
$service = $openstack->objectStoreV1();
$container = $service->createContainer([
'name' => $containerName
]);
Hi
How can I set the option verify of client in your lib ?
I need to precise a custom SSL certificate on disk.
Doc Guzzle : http://docs.guzzlephp.org/en/latest/request-options.html#verify
NB : I have to use the api V3.
Thanks
Karima
There's a bug in my PR #93 . There's a marker PHP type mismatch which I'm tracking down. Beyond that though I'm curious where the generator actually ends given that Iterator::totalReached requires the limit be set and by default it doesn't seem to be. Clearly I'm doing something wrong since it works everywhere else :). If anyone could provide insight on either issue it'd be appreciated.
Chris
Hello,
I have a problem with that authentification code:
require 'vendor/autoload.php';
$openstack = new OpenStack\OpenStack([
'authUrl' => '{authUrl}',
'region' => '{region}',
'user' => [
'id' => '{userId}',
'password' => '{password}'
],
'scope' => ['project' => ['id' => '{projectId}']]
]);
I change all these settings to my configuration.
Return to me that errror : When authenticating with a username, you must also provide either the domain name or domain ID to which the user belongs to. Alternatively, if you provide a user ID instead, you do not need to provide domain information.
So i changed to that one code adding domain information at the user array :
$openstack = new OpenStack\OpenStack([
'authUrl' => '{authUrl}',
'region' => '{region}',
'user' => [
'id' => '{userId}',
'domain' => ['id' => 'default'],
'password' => '{password}'
],
'scope' => ['project' => ['id' => '{projectId}']]
]);
But i got that error now : Endpoint URL could not be found in the catalog for this service. Name: swift Type: object-store Region: GRA1 URL type: public
The old API worked well with username password and tenantID. What can i do ?
Thanks in advance.
Merging with php-opencloud/common
will simplify development process and reduce dependencies.
Can you share what was the reason to separate sdk into 2 repositories @jamiehannaford?
Great work on this!
I was just wondering if it is at all possible to generate temporary URL's for objects in object store?
http://docs.openstack.org/juno/config-reference/content/object-storage-tempurl.html
this is my code.
$this->openstack->objectStoreV1()
->getContainer($containerName)
->getObject($fileNameInObjectStore)
->mergeMetadata(['mime-type' => mime_content_type($filePath)]);
When I try to get the metadata, the following data is shown after echoing:
Array ( [ime-Type] => application/pdf ) 1
I also find that metadata key first character will be capitalized
How to download file?
I understand the the one in the example will generate Guzzle streams? What to do with that?
I need to force download it as a file...
Thanks
I don't see an easy way to get it. The 'hostId' field returned from createServer is simply the hostname of the compute node (I assume). Additionally, there's no UUID available in the os-hypervisors list. Ideas?
Hello ! I create web site with php-opencloud/Openstack and because i didn't find the api console i just insert the URL with header function in PHP :
header ('Location: http://...:6080/vnc_auto.html?token='.$tokenId.'&title='.$serverName.'('.$serverID.')');
but when i want to connected its give to me failed to connect (code:1006)
someone can give me to help please !
I'm currently working on the Flysystem adapter for opencloud, or at least trying to. I can't seem to find any docs on how to configure the client. I've looking in closed issues in order to see which array keys were expected but am now stuck in a "try and read exception message" loop. Apart from this being rather annoying to me, if I didn't need to do this for open source, I wouldn't take nearly the effort I am doing now. It would be great if the basic "getting started" documentation could get some love. This will help boost adoption greatly. Especially since the rackspace docs say the API used there is soon to be deprecated. Also, all the refdoc URL's don't point anywhere, so all the reference there are dead ends. Many other links don't exist anymore either, so I'm constantly hitting 404's or even non-existant URLs.
Hi.
I've a simple test case:
$openstack = new OpenStack\OpenStack([
'authUrl' => 'http://controller:5000/v3',
'region' => 'One',
'user' => [
'tokenId' => $token,
'domain' => ['name' => 'default']
],
]);
$compute = $openstack->computeV2();
$token
is verified to be correct and not expired. It's been extracted from the openstack-client and so far the Identity class works as in It can re-create tokens
.
However, the Compute class raises this exception:
PHP Fatal error: Uncaught Exception: The key provided "tokenId" is not defined in ./vendor/php-opencloud/openstack/src/Common/Api/Parameter.php:255
Any pointers?
Please find the below code
<?php
require 'vendor/autoload.php';
use OpenCloud\Rackspace;
if (isset($_POST['submit'])) {
// userfile
$userfile = $_FILES['user_file']['tmp_name'];
try {
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
'username' => '********',
'apiKey' => '*******************************'
)
);
// Obtain an Object Store service object from the client.
$objectStoreService = $client->objectStoreService(null, 'DFW');
// Create a container for your objects (also referred to as files).
$container = $objectStoreService->getContainer('************');
// Upload an object to the container.
$remoteFileName = $_FILES['user_file']['name'];
$handle = fopen($userfile, 'r');
$object = $container->uploadObject($remoteFileName, $handle);
// get cloud file URL
$cloud_file = $object->getPublicUrl();
/** @var bool $exists */
if ($container->objectExists('{$cloud_file}')) {
// display physical file hosted URL
echo $object->getPublicUrl();
} else {
// display file not found
echo "File not found";
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
}
?>
Here I have uploaded the video file into my container, which returns the publicly accessible URl, not the HLS streaming URL. I have used videojs platform as my video player for media streaming from brightcove as well as I have used videojs HLS javascript as well. Somebody help.
Hey, https://github.com/rackspace/php-opencloud is overly popular but it is reaching its end-of-life.
Moving forward, new features will only be implementing in this repo. Shall we put a notice in README.md
so that new users will use the new SDK?
I want to list user but i have a error :
Fatal error: Uncaught OpenCloud\Common\Error\BadResponseError: HTTP Error ~~~~~~~~~~ The remote server returned a "403 Forbidden" error for the following transaction: Request ~~~~~~~ GET /v3/users HTTP/1.1 User-Agent: GuzzleHttp/6.2.1 curl/7.29.0 PHP/7.0.9 Host: 192.168.1.10:5000 Response ~~~~~~~~ HTTP/1.1 403 Forbidden Date: Thu, 11 Aug 2016 13:23:45 GMT Server: Apache/2.4.6 (CentOS) Vary: X-Auth-Token x-openstack-request-id: req-2a87260a-dc17-47ab-8b85-5e8a7a79cc58 Content-Length: 136 Connection: close Content-Type: application/json Further information ~~~~~~~~~~~~~~~~~~~ Visit http://docs.php-opencloud.com/en/latest/http-codes for more information about debugging HTTP status codes, or file a support issue on https://github.com/php-opencloud/openstack/issues. in /home/admin/Documents/html/vendor/php-opencloud/common/src/Common/Error/Builder.php:134 Stack trace: #0 /home/admin/Documents/html/vendor/php-opencloud/common/src/Common/Transport/Middleware.php(29): OpenCloud\Common\Error\Builder->httpError(Object(G in /home/admin/Documents/html/vendor/php-opencloud/common/src/Common/Error/Builder.php on line 134
I don't have error in authentication because i can list project and server .. juste Users i can't list him.
someone can help please ?
Docs lack description on how to create and add objects to object storage
I use php-opencloud/Openstack and i want to connect in the console, but i didn't find any apy?
someone can help please ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.