Skip to content

Commit 7d50127

Browse files
author
Antti Myyrä
committed
Servers: do not create password when SSH keys are provided
1 parent 96a1d7f commit 7d50127

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

test/test_server_creation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_server_prepare_post_body_optional_attributes(self):
124124
assert body['server']['password_delivery'] == 'email'
125125
assert body['server']['login_user'] == {
126126
'username': 'upclouduser',
127-
'create_password': 'yes',
127+
'create_password': 'no',
128128
'ssh_keys': {'ssh_key': ['this-is-a-SSH-key']},
129129
}
130130
assert body['server']['avoid_host'] == '12345678'

upcloud_api/cloud_manager/server_mixin.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def create_server(self, server: Server) -> Server:
9191
hostname = "my.example.1",
9292
zone = "uk-lon1",
9393
storage_devices = [
94-
Storage(os = "01000000-0000-4000-8000-000030060200", size=10, tier=maxiops, title='The OS drive'),
94+
Storage(os = "01000000-0000-4000-8000-000030200200", size=10, tier=maxiops, title='Example OS disk'),
9595
Storage(size=10),
9696
Storage()
9797
title = "My Example Server"
@@ -103,10 +103,11 @@ def create_server(self, server: Server) -> Server:
103103
- title defaults to hostname + " OS disk" and hostname + " storage disk id"
104104
(id is a running starting from 1)
105105
- tier defaults to maxiops
106-
- valid operating systems are:
107-
"CentOS 6.10", "CentOS 7.6"
108-
"Ubuntu 12.04", "01000000-0000-4000-8000-000030060200"
109-
"Windows 2012", "Windows 2016"
106+
- valid operating systems are for example:
107+
* CentOS 8: 01000000-0000-4000-8000-000050010400
108+
* Debian 10: 01000000-0000-4000-8000-000020050100
109+
* Ubuntu 20.04: 01000000-0000-4000-8000-000030200200
110+
* Windows 2019: 01000000-0000-4000-8000-000010070300
110111
"""
111112
if isinstance(server, Server):
112113
body = server.prepare_post_body()

upcloud_api/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
from upcloud_api import CloudManager
1111

1212

13-
def login_user_block(username, ssh_keys, create_password=True):
13+
def login_user_block(username, ssh_keys, create_password=False):
1414
"""
1515
Helper function for creating Server.login_user blocks.
1616
1717
(see: https://www.upcloud.com/api/8-servers/#create-server)
1818
"""
1919
block = {
20-
'create_password': 'yes' if create_password is True else 'no',
20+
'create_password': 'yes' if create_password else 'no',
2121
'ssh_keys': {'ssh_key': ssh_keys},
2222
}
2323

0 commit comments

Comments
 (0)