Coder Social home page Coder Social logo

php-lxd's People

Contributors

ashleyhood avatar lcherone avatar max-github avatar renky avatar tonybogdanov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-lxd's Issues

PHP Catchable fatal error when file writing to container

When using the file write method there happens a PHP Catchable fatal error.
Has anybody already used file write and read successfully?

$lxd->containers->files->write($containernamename,'/etc/network/interfaces', 'test');
leads to:
PHP Catchable fatal error: Argument 1 passed to Opensaucesystems\Lxd\Endpoint\AbstructEndpoint::createJsonBody() must be of the type arra
y, string given, called in /..../vendor/opensaucesystems/lxd/src/Endpoint/AbstructEndpoint.php on line 51 and defined in /..../vendor/opensaucesystems/lxd/src/Endpoint/AbstructEndpoint.php on line 121

Cloud-init

Hello,

I searched the documentation but found no reference to using Cloud-init:

  user.user-data: |
    #cloud-config
    package_upgrade: true
    packages:
      - package1
      - package2

403 Forbidden - not authorized

Something is probably missing but I can't figure out where to set the password on PHP script side.

PHP Fatal error:  Uncaught GuzzleHttp\Exception\ClientException: Client error: `GET https://x.x.x.x:8443/1.0/containers` resulted in a `403 Forbidden` response:
{"error":"not authorized","error_code":403,"type":"error"}
t=2020-06-04T20:45:15+0200 lvl=warn msg="Rejecting request from untrusted client" ip=10.244.228.95:35874

Development

Hello,

I was wondering if there a roadmap for this project? or any planned milestones?

I want to add support for better handling of pushing and pulling files and folders, and execution of commands.

Do you have any preferences on how to run the project? Would you prefer I just work on my fork and add in pull requests?

Are there any established rules regarding dependencies and php version support?

Arguments parser error in execute function

In Endpoint/Containers.php the execute function parse incorrectly dotnet arguments command.

Example:

$cmd = 'dotnet test SomeCSharpSolution.sln --nologo --logger:"trx;LogFileName=result.trx"';

$r = $lxd->containers->execute('container-name', $cmd);

Expected parameters parsing result:

array(1) {
  ["command"]=>
  array(5) {
    [0]=>
    string(6) 'dotnet'
    [1]=>
    string(4) 'test'
    [2]=>
    string(25) 'SomeCSharpSolution.sln'
    [3]=>
    string(8) '--nologo'
    [4]=>
    string(36) '--logger:"trx;LogFileName=result.trx"'
  }

But the actual result is:

array(1) {
  ["command"]=>
  array(6) {
    [0]=>
    string(6) "dotnet"
    [1]=>
    string(4) "test"
    [2]=>
    string(25) "SomeCSharpSolution.sln"
    [3]=>
    string(8) "--nologo"
    [4]=>
    string(9) "--logger:"
    [5]=>
    string(39) "trx;LogFileName=result.trx"
  }

This incorrect parsing give this dotnet result

MSBUILD : error MSB1008: Only one project can be specified.
Switch: trx;LogFileName=result.trx

For switch syntax, type "MSBuild -help"

I think the problem is in the split function, in the regex (line 691 in Containers.php) but i don't know how to fix this.

Perhaps it is not this php-lxd library that should solve this problem?

But, in this case, how can I pass the arguments?

Thank you for your work.

Best Regards.

PiF

Undefined Index "empty"

When creating a new container with option 'alias" there is an PHP Notice about undefined index. That's not so good for environments where error-reporting is set to E_ALL.

PHP Notice: Undefined index: empty in /var/www/clients/client1/web2/subwebs/test.profi-webspace.eu/vendor/opensaucesystems/lxd/src/Endpoint/Containers.php on line 257

should be added an "isset"-check before check for empty-Value...

Containers write don't work properly

Hi,

There is a mistake in arguments between Endpoint/Containers/Files/write() (line55) and Endpoint/AbstructEndpoint/post() (line 49).

In the first method (write) when you make a call to post (line 55) you give 3 arguments :

->post(the container name?with_get_params, follow by data, and headers)

but you must add an parameter between data and headers because in the post method the 3rd parameters is used to buildPath and actually you buildPath with requestHeaders array.

I corrected it like that at

return $this->post($this->getEndpoint().$name.'/files?path='.$filepath, $data, /****** USLESS ********/ []  /****** ARRAY ******/, $headers);

but i think you can find a more elegant way.

Best regards

PS: sorry for my poor english

PHP 8.0 compatibility

Based on a very quick test it looks like the project runs fine on PHP 8.0.

Would it be possible to mark it as such in composer?

- opensaucesystems/lxd v0.10.0 requires php ~7.2 -> your PHP version (8.0.0) does not satisfy that requirement.

Docs: unfreeze container description

Small bug in containers documentation:
unfreeze is missing (start instead of unfreeze):
$lxd->containers->start('container-name');

should be
$lxd->containers->unfreeze('container-name');

Create fails

Hi,

I am creating 3 containers: test-nginx, test-php and test-mysql so that I might create a containerized LEMP stack using php-lxd. I first executed: lxc launch from the terminal to verify LXD is working. Then I endeavored to create the second container, test-php, using php-lxd. For some reason, LXD responds that "No matching image found" Below are my code snippets:

test-nginx

lxc launch images:ubuntu/18.04 test-nginx

test-php

$ ./artisan lxd:client

   Http\Client\Exception\HttpException  : Client error: `POST https://127.0.0.1:8443/1.0/containers` resulted in a `400 Bad Request` response:
{"error":"No matching image could be found","error_code":400,"type":"error"}

  at /media/michael/Data/LaunchSoftwareSite/vendor/php-http/guzzle6-adapter/src/Promise.php:127
    123| 
    124|         if ($exception instanceof GuzzleExceptions\RequestException) {
    125|             // Make sure we have a response for the HttpException
    126|             if ($exception->hasResponse()) {
  > 127|                 return new HttplugException\HttpException(
    128|                     $exception->getMessage(),
    129|                     $exception->getRequest(),
    130|                     $exception->getResponse(),
    131|                     $exception

  Exception trace:

  1   Http\Adapter\Guzzle6\Promise::handleException(Object(GuzzleHttp\Exception\ClientException), Object(GuzzleHttp\Psr7\Request))
      /media/michael/Data/LaunchSoftwareSite/vendor/php-http/guzzle6-adapter/src/Promise.php:63

  2   GuzzleHttp\Exception\ClientException::("Client error: `POST https://127.0.0.1:8443/1.0/containers` resulted in a `400 Bad Request` response:
{"error":"No matching image could be found","error_code":400,"type":"error"}


")
      /media/michael/Data/LaunchSoftwareSite/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113

This is my first attempt using both LXD and php-lxd. Am I using the correct API call? Is there something I a missing about images? Maybe remote? What is the corresponding API call for lxc launch?

Thanks @ashleyhood

:-)

Logs endpoint error

Hi,

In Containers.php (line 504) and Containers/Logs.php (line 26) you have two time the same error:

        foreach ($this->get($this->getEndpoint().$name.'/logs/') as $log) {
            $logs[] = str_replace(
                '/'.$this->client->getApiVersion().'/containers/'.$name.'/logs/',
                '',
                $log
            );
        }

You must replace /containers/ by /instances/

Best Regards

PiF

php-http/guzzle7-adapter

Guzzle 7 is there and the first frameworks are already using it (e.g. Laravel 8)
unfortunatelly php-http/guzzle6-adapter doesn't work with Guzzle 7 and the solution of php-http was to create a complete new package php-http/guzzle7-adapter.
php-http/guzzle7-adapter on the other side needs php-http/httplug 2 and php-lxd requires httplug 1

so how to go on? my suggestion is also switching to Guzzle 7 here and raise the version-number to 0.10- if anybody wants to use guzzle6 he has to stick with 0.9...

what do you think?

Guzzle adapter dependency

Get this error when installing.

Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Installation request for opensaucesystems/lxd ^0.2.0 -> satisfiable by opensaucesystems/lxd[v0.2.0].
    - opensaucesystems/lxd v0.2.0 requires php-http/client-implementation ^1.0 -> no matching package found.

Move the require-dev dependency php-http/guzzle6-adapter: ^1.1 into require...

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.