Zaktualizuj 'hetzner/create.py'
This commit is contained in:
parent
4752c000c4
commit
57a51bf6bc
@ -56,39 +56,22 @@ if not ssh_key:
|
||||
print(f"Klucz {ssh_key.data_model.name} został dodany")
|
||||
|
||||
loadbalancer_targets = []
|
||||
servers_num = 5
|
||||
|
||||
web_service1 = client.servers.create(
|
||||
name=f"{PREFIX}-webservice1",
|
||||
server_type=ServerType("cx11"),
|
||||
image=Image(name="ubuntu-20.04"),
|
||||
ssh_keys=[ssh_key],
|
||||
networks=[vnet],
|
||||
location=Location("hel1"),
|
||||
user_data=webservice_init
|
||||
)
|
||||
for i in range(servers_num):
|
||||
webservice_server = client.servers.create(
|
||||
name=f"{PREFIX}-webservice-{i+1}",
|
||||
server_type=ServerType("cx11"),
|
||||
image=Image(name="ubuntu-20.04"),
|
||||
ssh_keys=[ssh_key],
|
||||
networks=[vnet],
|
||||
location=Location("hel1"),
|
||||
user_data=webservice_init
|
||||
)
|
||||
|
||||
web_service1.action.wait_until_finished()
|
||||
print(f"Tworzenie serwera web service 1: {web_service1.action.complete}")
|
||||
loadbalancer_targets.append(LoadBalancerTarget(type="server", server=web_service1.server, use_private_ip=True))
|
||||
web_service1 = client.servers.get_by_name(f"{PREFIX}-webservice1")
|
||||
print(f"Serwer: {web_service1.data_model.name}\n\tpubliczne IP: {web_service1.data_model.public_net.ipv4.ip}\n\tprywatne IP: {web_service1.data_model.private_net[0].ip}")
|
||||
|
||||
|
||||
web_service2 = client.servers.create(
|
||||
name=f"{PREFIX}-webservice2",
|
||||
server_type=ServerType("cx11"),
|
||||
image=Image(name="ubuntu-20.04"),
|
||||
ssh_keys=[ssh_key],
|
||||
networks=[vnet],
|
||||
location=Location("hel1"),
|
||||
user_data=webservice_init
|
||||
)
|
||||
|
||||
web_service2.action.wait_until_finished()
|
||||
print(f"Tworzenie serwera web service 2: {web_service2.action.complete}")
|
||||
loadbalancer_targets.append(LoadBalancerTarget(type="server", server=web_service2.server, use_private_ip=True))
|
||||
web_service2 = client.servers.get_by_name(f"{PREFIX}-webservice2")
|
||||
print(f"Serwer: {web_service2.data_model.name}\n\tpubliczne IP: {web_service2.data_model.public_net.ipv4.ip}\n\tprywatne IP: {web_service2.data_model.private_net[0].ip}")
|
||||
webservice_server.action.wait_until_finished()
|
||||
print(f"Tworzenie serwera webservice {i+1}: {webservice_server.action.complete}")
|
||||
loadbalancer_targets.append(LoadBalancerTarget(type="server", server=webservice_server.server, use_private_ip=True))
|
||||
|
||||
|
||||
load_balancer = client.load_balancers.create(
|
||||
|
Loading…
Reference in New Issue
Block a user