GithubHelp home page GithubHelp logo

Comments (16)

jamiehannaford avatar jamiehannaford commented on July 20, 2024 1

php-opencloud/common:v1.0.4 is now released

from openstack.

jamiehannaford avatar jamiehannaford commented on July 20, 2024

Right now, this is not possible to do. We should definitely add this ability though, since it's a fairly standard use case. I imagine you'd pass in options as a new constructor key to the OpenStack builder. What do you think @haphan?

from openstack.

haphan avatar haphan commented on July 20, 2024

@jamiehannaford 👍 for having a new constructor key in OpenCloud\Common\Service\Builder.

Propose PR: php-opencloud/common#3

from openstack.

BorderCloud avatar BorderCloud commented on July 20, 2024

Hello

How to insert the option verify in this example ?

require 'vendor/autoload.php';

$openstack = new OpenStack\OpenStack([
    'authUrl' => '{authUrl}',
    'region'  => '{region}',
    'user'    => [
        'id'       => '{userId}',
        'password' => '{password}'
    ],
    'scope'   => ['project' => ['id' => '{projectId}']]
]);

$images = $openstack->imagesV2()
                    ->listImages();

foreach ($images as $image) {
}

Thanks

from openstack.

haphan avatar haphan commented on July 20, 2024

@BorderCloud Updated

$requestOptions = [
    'verify'  => '/path/to/custom/ca.cert',
    'headers' => ['User-Agent' => 'PHP-OPENCLOUD/SDKv1.0'],
];

$params = [
    'authUrl'          => 'http://172.16.113.139:5000/v3',
    'region'           => 'RegionOne',
    'user'             => [
        'name'     => 'admin',
        'password' => '034cdbdb0fd84c5f',
        'domain'   => ['id' => 'default'],
    ],
    'requestOptions'   => $requestOptions,
];


$openstack = new OpenStack\OpenStack($params);

foreach ($openstack->computeV2()->listImages() as $image) {
}

Until @jamiehannaford is going tag php-opencloud/common, you will have to manually specify php-opencloud/common: dev-master in your composer.json

Update: correct sample code

from openstack.

haphan avatar haphan commented on July 20, 2024

@jamiehannaford btw can you also tag php-opencloud/openstack?

from openstack.

BorderCloud avatar BorderCloud commented on July 20, 2024

Thanks, I suppose Builder waits a list of parameters in the array because I have now messages like:

  • "authUrl" is a required option
  • and after, "identityService" must be specified and implement OpenCloud\Common\Auth\IdentityService

Can you give a example with builder ? I am a newbie on openstack...

use OpenCloud\Common\Service\Builder;

// see list of built-in Guzzle request options at GuzzleHttp\RequestOptions
$requestOptions = [
    'verify' => '/path/to/custom/ca.cert',
    'timeout' => '60'
];

$builder = new Builder([], 'OpenCloud', $requestOptions);
$openstack = new OpenStack\OpenStack([
    'authUrl' => '{authUrl}',
    'region'  => '{region}',
    'user'    => [
        'id'       => '{userId}',
        'password' => '{password}'
    ],
    'scope'   => ['project' => ['id' => '{projectId}']]
], $builder);

$images = $openstack->imagesV2()
                    ->listImages();

foreach ($images as $image) {
}

Thanks
Karima

from openstack.

jamiehannaford avatar jamiehannaford commented on July 20, 2024

@haphan @BorderCloud I think we should add requestOptions to the OpenStack class. That could be fed into the service builder.

from openstack.

haphan avatar haphan commented on July 20, 2024

@jamiehannaford
I agree that requestOptions need to pass to OpenStack since a HTTP client is also created here.

Regarding requestOption, I think it'd better to directly use array $options['requestOptions'] to OpenStack class. This options will also be fed into Builder.

from openstack.

haphan avatar haphan commented on July 20, 2024

what do you think @jamiehannaford
#63
php-opencloud/common#4

from openstack.

haphan avatar haphan commented on July 20, 2024

@BorderCloud See my updated sample code above. You may need to run composer update php-opencloud/openstack to fetch latest version.

from openstack.

BorderCloud avatar BorderCloud commented on July 20, 2024

Ok I have the version Installing php-opencloud/common (v1.0.5)
But I always the message cURL error 7: Permission denied

If I test with a bad file, the message is always the same... Strange...

$requestOptions = [
     'verify' => '/var/www/html/demo/NotExistFile.pem', // or 'NotExistFile.pem'
    'headers' => ['User-Agent' => 'PHP-OPENCLOUD/SDKv1.0']
];

An idea ?

from openstack.

haphan avatar haphan commented on July 20, 2024

@BorderCloud Looks like environment issue for me. Are you running Centos with SELINUX enabled? Reference: guzzle/guzzle#1001

When an invalid pem file is supplied, this is what I got:
Fatal error: Uncaught InvalidArgumentException: SSL CA bundle not found: /not/valid/ca.pem in /app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:331

from openstack.

BorderCloud avatar BorderCloud commented on July 20, 2024

Ok without SELinux I have now the message

 Client error: `POST https://keystone.....:5000/v3/auth/tokens` resulted in a `401 Unauthorized` response:
{"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}

A problem in the lib or in the config ?

from openstack.

haphan avatar haphan commented on July 20, 2024

Check your openstack crendential.

On Thursday, 23 June 2016, Karima Rafes [email protected] wrote:

Ok without SELinux I have now the message

Client error: POST https://keystone.....:5000/v3/auth/tokens resulted in a 401 Unauthorized response:
{"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}

A problem in the lib or in the config ?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#62 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAwIsnoxSS0oW6CPVC4PKDXNdopSVDYBks5qOmTvgaJpZM4I5Iuv
.

from openstack.

haphan avatar haphan commented on July 20, 2024

Issued resolved.

from openstack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.