You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by qu...@apache.org on 2017/10/10 04:57:38 UTC
[1/2] libcloud git commit: ex_username parameter added and refactored
test to use common parameters
Repository: libcloud
Updated Branches:
refs/heads/trunk 2075b87f6 -> 12d8e9967
ex_username parameter added and refactored test to use common parameters
Closes #1125
Signed-off-by: Quentin Pradet <qu...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/5dcd472f
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/5dcd472f
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/5dcd472f
Branch: refs/heads/trunk
Commit: 5dcd472f1eea1204b71b812a9664b707f97441be
Parents: 2075b87
Author: Mika Lackman <mi...@upcloud.com>
Authored: Sat Oct 7 19:31:53 2017 +0300
Committer: Quentin Pradet <qu...@apache.org>
Committed: Tue Oct 10 08:43:24 2017 +0400
----------------------------------------------------------------------
libcloud/common/upcloud.py | 11 +++---
libcloud/compute/drivers/upcloud.py | 7 +++-
libcloud/test/common/test_upcloud.py | 61 +++++++++++++------------------
3 files changed, 37 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/5dcd472f/libcloud/common/upcloud.py
----------------------------------------------------------------------
diff --git a/libcloud/common/upcloud.py b/libcloud/common/upcloud.py
index 796fa58..05fb5c2 100644
--- a/libcloud/common/upcloud.py
+++ b/libcloud/common/upcloud.py
@@ -29,9 +29,6 @@ class UpcloudCreateNodeRequestBody(object):
Takes the create_node arguments (**kwargs) and constructs the request body
- :param user_id: required for authentication (required)
- :type user_id: ``str``
-
:param name: Name of the created server (required)
:type name: ``str``
@@ -52,17 +49,21 @@ class UpcloudCreateNodeRequestBody(object):
:param ex_hostname: Hostname. Default is 'localhost'. (optional)
:type ex_hostname: ``str``
+ :param ex_username: User's username, which is created.
+ Default is 'root'. (optional)
+ :type ex_username: ``str``
"""
- def __init__(self, user_id, name, size, image, location, auth=None,
+ def __init__(self, name, size, image, location, auth=None,
**kwargs):
+ username = kwargs.get('ex_username', 'root')
self.body = {
'server': {
'title': name,
'hostname': kwargs.get('ex_hostname', 'localhost'),
'plan': size.id,
'zone': location.id,
- 'login_user': _LoginUser(user_id, auth).to_dict(),
+ 'login_user': _LoginUser(username, auth).to_dict(),
'storage_devices': _StorageDevice(image, size).to_dict()
}
}
http://git-wip-us.apache.org/repos/asf/libcloud/blob/5dcd472f/libcloud/compute/drivers/upcloud.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/upcloud.py b/libcloud/compute/drivers/upcloud.py
index 5652a3d..3d98d2f 100644
--- a/libcloud/compute/drivers/upcloud.py
+++ b/libcloud/compute/drivers/upcloud.py
@@ -154,11 +154,14 @@ class UpcloudDriver(NodeDriver):
:param ex_hostname: Hostname. Default is 'localhost'. (optional)
:type ex_hostname: ``str``
+ :param ex_username: User's username, which is created.
+ Default is 'root'. (optional)
+ :type ex_username: ``str``
+
:return: The newly created node.
:rtype: :class:`.Node`
"""
- body = UpcloudCreateNodeRequestBody(user_id=self.connection.user_id,
- name=name, size=size, image=image,
+ body = UpcloudCreateNodeRequestBody(name=name, size=size, image=image,
location=location, auth=auth,
**kwargs)
response = self.connection.request('1.2/server',
http://git-wip-us.apache.org/repos/asf/libcloud/blob/5dcd472f/libcloud/test/common/test_upcloud.py
----------------------------------------------------------------------
diff --git a/libcloud/test/common/test_upcloud.py b/libcloud/test/common/test_upcloud.py
index 6d6ee0f..37bef0d 100644
--- a/libcloud/test/common/test_upcloud.py
+++ b/libcloud/test/common/test_upcloud.py
@@ -26,16 +26,17 @@ from libcloud.test import unittest
class TestUpcloudCreateNodeRequestBody(unittest.TestCase):
- def test_creating_node_from_template_image(self):
- image = NodeImage(id='01000000-0000-4000-8000-000030060200',
- name='Ubuntu Server 16.04 LTS (Xenial Xerus)',
- driver='',
- extra={'type': 'template'})
- location = NodeLocation(id='fi-hel1', name='Helsinki #1', country='FI', driver='')
- size = NodeSize(id='1xCPU-1GB', name='1xCPU-1GB', ram=1024, disk=30, bandwidth=2048,
- extra={'core_number': 1, 'storage_tier': 'maxiops'}, price=None, driver='')
+ def setUp(self):
+ self.image = NodeImage(id='01000000-0000-4000-8000-000030060200',
+ name='Ubuntu Server 16.04 LTS (Xenial Xerus)',
+ driver='',
+ extra={'type': 'template'})
+ self.location = NodeLocation(id='fi-hel1', name='Helsinki #1', country='FI', driver='')
+ self.size = NodeSize(id='1xCPU-1GB', name='1xCPU-1GB', ram=1024, disk=30, bandwidth=2048,
+ extra={'core_number': 1, 'storage_tier': 'maxiops'}, price=None, driver='')
- body = UpcloudCreateNodeRequestBody(user_id='somename', name='ts', image=image, location=location, size=size)
+ def test_creating_node_from_template_image(self):
+ body = UpcloudCreateNodeRequestBody(name='ts', image=self.image, location=self.location, size=self.size)
json_body = body.to_json()
dict_body = json.loads(json_body)
expected_body = {
@@ -44,7 +45,7 @@ class TestUpcloudCreateNodeRequestBody(unittest.TestCase):
'hostname': 'localhost',
'plan': '1xCPU-1GB',
'zone': 'fi-hel1',
- 'login_user': {'username': 'somename',
+ 'login_user': {'username': 'root',
'create_password': 'yes'},
'storage_devices': {
'storage_device': [{
@@ -64,11 +65,7 @@ class TestUpcloudCreateNodeRequestBody(unittest.TestCase):
name='Ubuntu Server 16.04 LTS (Xenial Xerus)',
driver='',
extra={'type': 'cdrom'})
- location = NodeLocation(id='fi-hel1', name='Helsinki #1', country='FI', driver='')
- size = NodeSize(id='1xCPU-1GB', name='1xCPU-1GB', ram=1024, disk=30, bandwidth=2048,
- extra={'core_number': 1, 'storage_tier': 'maxiops'}, price=None, driver='')
-
- body = UpcloudCreateNodeRequestBody(user_id='somename', name='ts', image=image, location=location, size=size)
+ body = UpcloudCreateNodeRequestBody(name='ts', image=image, location=self.location, size=self.size)
json_body = body.to_json()
dict_body = json.loads(json_body)
expected_body = {
@@ -77,7 +74,7 @@ class TestUpcloudCreateNodeRequestBody(unittest.TestCase):
'hostname': 'localhost',
'plan': '1xCPU-1GB',
'zone': 'fi-hel1',
- 'login_user': {'username': 'somename',
+ 'login_user': {'username': 'root',
'create_password': 'yes'},
'storage_devices': {
'storage_device': [
@@ -99,16 +96,9 @@ class TestUpcloudCreateNodeRequestBody(unittest.TestCase):
self.assertDictEqual(expected_body, dict_body)
def test_creating_node_using_ssh_keys(self):
- image = NodeImage(id='01000000-0000-4000-8000-000030060200',
- name='Ubuntu Server 16.04 LTS (Xenial Xerus)',
- driver='',
- extra={'type': 'template'})
- location = NodeLocation(id='fi-hel1', name='Helsinki #1', country='FI', driver='')
- size = NodeSize(id='1xCPU-1GB', name='1xCPU-1GB', ram=1024, disk=30, bandwidth=2048,
- extra={'core_number': 1, 'storage_tier': 'maxiops'}, price=None, driver='')
auth = NodeAuthSSHKey('sshkey')
- body = UpcloudCreateNodeRequestBody(user_id='somename', name='ts', image=image, location=location, size=size, auth=auth)
+ body = UpcloudCreateNodeRequestBody(name='ts', image=self.image, location=self.location, size=self.size, auth=auth)
json_body = body.to_json()
dict_body = json.loads(json_body)
expected_body = {
@@ -118,7 +108,7 @@ class TestUpcloudCreateNodeRequestBody(unittest.TestCase):
'plan': '1xCPU-1GB',
'zone': 'fi-hel1',
'login_user': {
- 'username': 'somename',
+ 'username': 'root',
'ssh_keys': {
'ssh_key': [
'sshkey'
@@ -139,15 +129,7 @@ class TestUpcloudCreateNodeRequestBody(unittest.TestCase):
self.assertDictEqual(expected_body, dict_body)
def test_creating_node_using_hostname(self):
- image = NodeImage(id='01000000-0000-4000-8000-000030060200',
- name='Ubuntu Server 16.04 LTS (Xenial Xerus)',
- driver='',
- extra={'type': 'template'})
- location = NodeLocation(id='fi-hel1', name='Helsinki #1', country='FI', driver='')
- size = NodeSize(id='1xCPU-1GB', name='1xCPU-1GB', ram=1024, disk=30, bandwidth=2048,
- extra={'core_number': 1, 'storage_tier': 'maxiops'}, price=None, driver='')
-
- body = UpcloudCreateNodeRequestBody(user_id='somename', name='ts', image=image, location=location, size=size,
+ body = UpcloudCreateNodeRequestBody(name='ts', image=self.image, location=self.location, size=self.size,
ex_hostname='myhost.upcloud.com')
json_body = body.to_json()
dict_body = json.loads(json_body)
@@ -157,7 +139,7 @@ class TestUpcloudCreateNodeRequestBody(unittest.TestCase):
'hostname': 'myhost.upcloud.com',
'plan': '1xCPU-1GB',
'zone': 'fi-hel1',
- 'login_user': {'username': 'somename',
+ 'login_user': {'username': 'root',
'create_password': 'yes'},
'storage_devices': {
'storage_device': [{
@@ -172,6 +154,15 @@ class TestUpcloudCreateNodeRequestBody(unittest.TestCase):
}
self.assertDictEqual(expected_body, dict_body)
+ def test_creating_node_with_non_default_username(self):
+ body = UpcloudCreateNodeRequestBody(name='ts', image=self.image, location=self.location, size=self.size,
+ ex_username='someone')
+ json_body = body.to_json()
+ dict_body = json.loads(json_body)
+
+ login_user = dict_body['server']['login_user']
+ self.assertDictEqual({'username': 'someone', 'create_password': 'yes'}, login_user)
+
class TestStorageDevice(unittest.TestCase):
[2/2] libcloud git commit: Add changes for #1125
Posted by qu...@apache.org.
Add changes for #1125
Also split UpCloud changes because they were taking too much space.
Putting tickets and PRs on a single line is allowed by the
generate_contributor_list.py script.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/12d8e996
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/12d8e996
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/12d8e996
Branch: refs/heads/trunk
Commit: 12d8e9967ab119b28e1a2a92817bf6c5479686e2
Parents: 5dcd472
Author: Quentin Pradet <qu...@apache.org>
Authored: Tue Oct 10 08:56:11 2017 +0400
Committer: Quentin Pradet <qu...@apache.org>
Committed: Tue Oct 10 08:56:11 2017 +0400
----------------------------------------------------------------------
CHANGES.rst | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/12d8e996/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 3d91b40..bb85271 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -13,7 +13,7 @@ Common
Compute
~~~~~~~
-- New driver for UpCloud (LIBCLOUD-938, LIBCLOUD-951, LIBCLOUD-952, GITHUB-1102, GITHUB-1123, GITHUB-1124)
+- [UpCloud] New driver for UpCloud (LIBCLOUD-938, GITHUB-1102)
[Mika Lackman, Ilari Mäkelä]
- [EC2] Add new x1.16xlarge and x1e.32xlarge instance type. (GITHUB-1101)
@@ -43,6 +43,15 @@ Compute
- [ARM] Fix API call on powerOff, understand PAUSED state (GITHUB-1003)
[Markos Gogoulos]
+- [UpCloud] Use disk size and storage tier also when creating node from template
+ (LIBCLOUD-952, GITHUB-1124)
+ [Mika Lackman]
+
+- [UpCloud] Allow to define hostname and username
+ (LIBCLOUD-951, LIBCLOUD-953, GITHUB-1123, GITHUB-1125)
+ [Mika Lackman]
+
+
Changes in Apache Libcloud 2.2.1
--------------------------------