Comments (6)
For future readers: I ended up doing this
def exists_remote(host, path):
"""Test if a file exists at path on a host accessible with SSH."""
status = subprocess.call(["ssh", host, "test -f {}".format(pipes.quote(path))])
if status == 0:
return True
if status == 1:
return False
raise Exception("SSH failed")
while not exists_remote(f"root@{ip}", "/var/lib/cloud/instance/boot-finished"):
print(".")
time.sleep(5)
from hcloud-python.
i use this, although you probably rather want to test if you can actually already connect
or let the instance itself signal that itβs ready
for retries in range(10):
if instance.status == instance.STATUS_RUNNING:
break
time.sleep(10)
instance = instance.update()
assert instance.status == instance.STATUS_RUNNING
from hcloud-python.
There is no way how we can determine if the server is ready (boot finished), as we don't have access to the server itself. I would recommend looking for /var/lib/cloud/instance/boot-finished
on the server.
from hcloud-python.
Hi @mikebarkmin can you provide an example of how do you get the ip of the server after creating it? It seems you already done that and I cannot find this info on the docs...
from hcloud-python.
Hi. You can get the IP when you create a new server (see the response sample here https://docs.hetzner.cloud/#servers-create-a-server). Here is how I used it.
def up(server_type="cx11"):
client = Client(token=os.getenv("HCLOUD_API_TOKEN"))
with open("cloud-config.yml", "r") as user_data:
response: CreateServerResponse = client.servers.create(
name="load-testing",
server_type=ServerType(name=server_type),
image=Image(name="ubuntu-20.04"),
ssh_keys=client.ssh_keys.get_all(),
user_data=user_data.read()
)
server: BoundServer = response.server
return server.public_net.ipv4.ip
I describe it in a tutorial on how to use the hetzner sdk for setting up a load testing environment. https://dev.to/mikebarkmin/spin-up-real-infrastructure-for-load-testing-with-locust-on-hetznercloud-35oa
from hcloud-python.
Thanks a lot, did not find the tutorial before.
from hcloud-python.
Related Issues (20)
- doc: mention "python -m venv " because mkvirtualenv is not always installed
- Bug in hcloud-inventory: one server without public ip4v crashes the complete plugin HOT 1
- Transfer resources HOT 1
- Dependency Dashboard
- Move hcloud.hcloud module to hcloud._client HOT 2
- Ensure some keyword arguments are passed as such HOT 2
- Incompatible ISO8601 format returned by the API HOT 1
- Move package version from `hcloud.__version__.VERSION` to `hcloud.__version__` HOT 2
- Drop python 3.7 support
- Howto use wss link to open a console HOT 7
- Use timeouts on API requests HOT 2
- cannot import name 'Image' from 'hcloud.images' HOT 1
- Mirror the API responses in the returned values HOT 1
- Hang and failure when accessing attributes like Server and Images HOT 1
- Wrong filters combination in client.servers.get_all HOT 5
- Filter multiple machines with the similar name HOT 1
- Failed to update the labels for BoundImage HOT 1
- Client, APIException and HCloudException not properly exported
- v1.33.1 not uploaded to PyPI HOT 2
- Is there any way to link server_types with locations? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hcloud-python.