php-opencloud / openstack

PHP SDK for OpenStack clouds
Apache License 2.0
221 stars 152 forks source link

OVH - 404 Not Found The resource could not be found #291

Open tuyenlaptrinh opened 4 years ago

tuyenlaptrinh commented 4 years ago

Hello Everyone. I am new in Openstack and I am using OVH Object Storage. I got this error when I try connect to OVH

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: 
Client error: `POST https://auth.cloud.ovh.net/auth/tokens` resulted in a `404 Not Found` response: {"error": {"message": "The resource could not be found.", "code": 404, "title": "Not Found"}} in D:\Xampp\htdocs\ovh\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113 Stack trace: #0 D:\Xampp\htdocs\ovh\vendor\guzzlehttp\guzzle\src\Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 D:\Xampp\htdocs\ovh\vendor\guzzlehttp\promises\src\Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 D:\Xampp\htdocs\ovh\vendor\guzzlehttp\promises\src\Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 D:\Xampp\htdocs\ovh\vendor\guzzlehttp\promises\src\TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #4 D:\Xampp\htdocs\ovh\vendor\guzzlehttp\promises\src\Promi in D:\Xampp\htdocs\ovh\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 113

I tried another auth URL like https://auth.cloud.ovh.net/v2.0/ or https://auth.cloud.ovh.net/v3. I got the error too

This is my code

$openstack = new OpenStack\OpenStack([
    'authUrl' => 'https://auth.cloud.ovh.net/',
    'region'  => 'SGP1',
    'user'    => [
        'id'       => 'xxxxxxxx',
        'password' => 'xxxxxxxx'
    ],
    'scope'   => ['project' => ['id' => 'xxxxxxxxx']]
]);
$account = $openstack->objectStoreV1()
                     ->getAccount();

Please help me solve this problem.

Kearsan commented 4 years ago

Hi,

I think the problem is the use of user id instead of user name. OVH provide the user name, not the id. So you have to replace 'id' by 'name'.

When you provide name instead of id you have to provide the domain too, which is "Default'.

Finally, auth url for OVH is https://auth.cloud.ovh.net/v3/

So you should come with something like :

$openstack = new OpenStack\OpenStack([
    'authUrl' => 'https://auth.cloud.ovh.net/v3/',
    'region'  => 'SGP1',
    'user'    => [
        'name'       => 'xxxxxxxx',
        'password' => 'xxxxxxxx',
        'domain'   => [
                  'name' => 'Default'
                       ]
    ],
    'scope'   => ['project' => ['id' => 'xxxxxxxxx']]
]);
tuyenlaptrinh commented 4 years ago

@Kearsan auth URL v3 is same. When I change id by name It is required ID error message

Kearsan commented 4 years ago

It's strange. I use OVH Object Storage too and this is the exact configuration I use and it works perfectly. Btw Openstack allows you to auth with id or name, so it shouldn't ask you for id if you set a name. And as I said OVH provides the name only (Horizon's name and password).

haphan commented 4 years ago

Hi @tuyenlaptrinh and @Kearsan

This could due to the fact that OVH use a wildcard * for their region see #288

Can you pull master branch and try it out.

Kearsan commented 4 years ago

Hi @haphan

I'm not using any wildcard for OVH and it works perfectly well. Actually OVH do use regions, we even get an email recently from OVH annoucing a recent change to regions in order to connect to Openstack (They are merging regions, so in our case we had to change GRA1 to GRA. Indeed both will still work during several months to prevent issues for live projects).

Regards,

mogyiman commented 4 years ago

Hello,

I've had similar problems, all kind of error messages using OVH object storage with Keystone v3. The actual config that helped follows:

$client = new OpenStack\OpenStack([
    'authUrl' => 'https://auth.cloud.ovh.net/v3',
    'region'  => 'GRA',   //the new region names
    'user'    => [
        'domain'    => ['id' => 'default'],
        'name'     => $username,
//      'id'       => $username,
        'password' => $password
    ],
    'scope'   => ['project' => [
                    'name' => $tenant,
                    'domain' => ['id' => 'default']]]
]);

$tenant is the deprecated v2 name for "project name".

Regards,

chadyred commented 4 years ago

Ovh doc may help you and me too, I search but I will find a way to go!

https://docs.ovh.com/gb/en/storage/pca/dev/

One of here sample is :

{
"user" : {
          "domain" : {
             "name" : "Default",
             "id" : "default"
          },
          "name" : "ktZeF8Uqluqm",
          "id" : "200ba261af11471db447526575dcb9fb"
       },
       "audit_ids" : [
          "BN_StzM0SFmGB5uYiIhA7Q"
       ],
       "project" : {
          "id" : "e80c212388cd4d509abc959643993b9f",
          "domain" : {
             "name" : "Default",
             "id" : "default"
          },
          "name" : "3635872342124167"
       }
 }