exploriment / hcloud-php Goto Github PK
View Code? Open in Web Editor NEWPHP library for the Hetzner Cloud API by Exploriment
License: MIT License
PHP library for the Hetzner Cloud API by Exploriment
License: MIT License
I tried to implement the reboot and shutdown method from HetznerCloud\Servers but I keep getting the error : exception 'Exploriment\HetznerCloud\Exceptions\ApiInvalidInput' with message 'invalid input: root must be an object' in /home/hvbeta/public_html/modules/addons/hv_hetzner/vendor/exploriment/hcloud-php/src/Http.php:123
I tried to check the input of the request method from Http class and it looks ok :
string(6) "597685" string(31) "servers/597685/actions/shutdown"
array(0) { }
array(0) { }
I also tried the API from Hetzner directly with curl and it works, so the problem must be somewhere at the method that sends the request, but I cannot figure out where.
I saw that the method changeDnsPtr from the Servers class is not implemented correctly, or the Hetzner API has changed from the time you implemented it. It should accept as body parameters ip and dns_ptr.
I have changed the method to :
/**
* Changes the hostname that will appear when getting the hostname belonging to the primary IPs (ipv4 and ipv6)
* of this server.
* Floating IPs assigned to the server are not affected by this.
* @see https://docs.hetzner.cloud/#resources-server-actions-post-15
*
* @param int $id
* @param string $ipv4
* @param null|string $dns_ptr
* @return Action
* @throws Exceptions\MalformedResponse
* @throws \Exception
* @throws \ReflectionException
*/
public static function changeDnsPtr($id, $ipv4, $dns_ptr = null)
{
return self::action($id, 'change_dns_ptr', [
'ip' => $ipv4,
'dns_ptr' => $dns_ptr
]);
}
and in that way it works.
I saw another useful server action available on Hetzner API name Request Console (https://docs.hetzner.cloud/#resources-server-actions-post-17), that I didn't find implemented in your code.
I added it on the Servers class like this :
/**
* Request console
*
* @param $id
* @return \Exploriment\HetznerCloud\ApiResponse
* @throws \Exploriment\HetznerCloud\Exceptions\MalformedResponse
* @throws \ReflectionException
*/
public static function requestConsole($id)
{
$response = self::request('POST', $id.'/actions/request_console');
return $response->getBody();
}
Maybe you can implement it or something like this. Thank you!
I use automatting scripts to create and setup Debian 10 server unattended. After creating a server, the script connect with SSH and the user is requested to set a new password. But my script needs to execute shell commands directly after the login - so the password change request is disturbing.
A workaround is to reset the server password, because when doing this manually, the password change prompt won't appear when logging in with the generated password, and it's possible to access the shell directly. But this seems to work manually with the Cloud API web interface only:
When I want to execute the Servers::resetPassword
method, I get an error for a new created up and running server:
Code: guest_agent_unavailable
Message: Cannot reset password because guest agent is unavailable
Now I don't know if this is a server image misconfiguration, or I need to wait until the guest agent is available, or how I can determine from a script (maybe using the Could API?) when/if the guest agent is available? Or is there a solution to change the initial password from a PHP script using ssh2 without the need to use Servers::resetPassword
? Fact is, I never logged in to the server and I never uninstalled the guest agent.
I use the server image 5924233, server type 9 and data center 4.
I have tested the Servers::rebuild method and the response of it is an Action object that has no root password and don't allow getRootPassword() method.
The public static function rebuild($id, $image) method from the final class Servers uses the trait Actionable action() method that returns only new Action($response->action), but the new root password is in $response->root_password.
Thank you!
Please add a the networks api call.
Hi there!
Thanks for making this awesome package!
I have a small problem with installing this package in my project.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- exploriment/hcloud-php v1.1.0 requires tightenco/collect v5.4.33 -> satisfiable by tightenco/collect[v5.4.33].
- exploriment/hcloud-php v1.1.1 requires tightenco/collect v5.4.33 -> satisfiable by tightenco/collect[v5.4.33].
- exploriment/hcloud-php v1.1.2 requires tightenco/collect v5.4.33 -> satisfiable by tightenco/collect[v5.4.33].
- Conclusion: don't install tightenco/collect v5.4.33
- Installation request for exploriment/hcloud-php ^1.1 -> satisfiable by exploriment/hcloud-php[v1.1.0, v1.1.1, v1.1.2].
Installation failed, reverting ./composer.json to its original content.
Composer spews error's all over the place for me at this moment. Is it a idea to pin tightenco/collect
on version 5.6.*
in composer.json
?
Or will this pose other issues?
Thanks in advance,
Ramon
hi
I use your library and don't work isos.
I recieve 404 not found when call isos part.
hi
please add volume to library.
the package need a upgrade to use latest versions of dependencies
I have tested the script and I found I little problem with it.
When I use the $creation = HetznerCloud\Servers::create($config);
it returns an object with null members like in the example bellow :
object(Exploriment\HetznerCloud\Objects\ServerCreation)#105 (3) {
["action"]=>
NULL
["server"]=>
NULL
["root_password"]=>
NULL
}
I saw that the response is returned after the command is given, and the action is still in progress. It should be modified to wait until the action is finished and send the response only after that. Otherwise I have to use after the creation the command to get the server details, but it`s not the best way in my opinion.
hi
which method should i use to Returns all existing server objects?
is possible to update the package to add volume actions ?
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.