From notifications-return-16236-archive-asf-public=cust-asf.ponee.io@libcloud.apache.org Wed Oct 30 11:59:48 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 474D0180654 for ; Wed, 30 Oct 2019 12:59:48 +0100 (CET) Received: (qmail 74190 invoked by uid 500); 30 Oct 2019 11:59:47 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 74180 invoked by uid 99); 30 Oct 2019 11:59:47 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Oct 2019 11:59:47 +0000 From: GitBox To: notifications@libcloud.apache.org Subject: [GitHub] [libcloud] vdloo opened a new pull request #1362: openstack driver can create node from bootable vol Message-ID: <157243678760.1377.15868758358211464627.gitbox@gitbox.apache.org> Date: Wed, 30 Oct 2019 11:59:47 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit vdloo opened a new pull request #1362: openstack driver can create node from bootable vol URL: https://github.com/apache/libcloud/pull/1362 Currently it is not possible to use the create_node method without specifying an image. This is because in the OpenStack_1_1_NodeDriver create_node converts the server_params like: ``` server_params = self._create_args_to_params(None, **kwargs) ``` but in case when there is no image to boot from like when you are booting from an already existing bootable volume (which could have been created from an image earlier), then _create_args_to_params will try to access node.extra in order to get the imageRef, and node is None: ``` if 'image' in kwargs: server_params['imageRef'] = kwargs.get('image').id else: server_params['imageRef'] = node.extra.get('imageId') ``` Booting an instance from a previously existing bootable volume like this would fail: ``` In [36]: conn.create_node(ex_availability_zone='R123', port='8487d948-0840-4205-8b31-7f705a19e7f4', name='r123apitestnode', ex_keyname ...: ='rick', size='e55a2688-ef74-44cf-b302-9a6f960c3d74', ex_blockdevicemappings=[{'boot_index': 0, 'uuid': 'be7ee330-b454-4414-8 ...: e9f-c70c558dd3af', 'source_type': 'volume', 'destination_type': 'volume', 'delete_on_termination': False}]) ``` with: ``` /usr/local/venv/hypernode-control/src/apache-libcloud/libcloud/compute/drivers/openstack.pyc in _create_args_to_params(self, node, **kwargs) 1495 server_params['imageRef'] = kwargs.get('image').id 1496 else: -> 1497 server_params['imageRef'] = node.extra.get('imageId') 1498 1499 if 'size' in kwargs: AttributeError: 'NoneType' object has no attribute 'extra' ``` This could be circumvented by specifying `image=''`: ``` In [39]: conn.create_node(ex_availability_zone='R123', port='8487d948-0840-4205-8b31-7f705a19e7f4', image='', name='r123apitestnode', ...: ex_keyname='rick', size='e55a2688-ef74-44cf-b302-9a6f960c3d74', ex_blockdevicemappings=[{'boot_index': 0, 'uuid': 'be7ee330-b ...: 454-4414-8e9f-c70c558dd3af', 'source_type': 'volume', 'destination_type': 'volume', 'delete_on_termination': False}]) ``` This PR also changes the default imageRef to empty string '' instead of None to prevent the API from responding with an error like this when the .get would default to None so that `image=''` will now no longer have to be specified. ``` BaseHTTPError: 400 Bad Request Invalid input for field/attribute imageRef. Value: None. u'None' is not valid under any of the given schemas ``` For more information see https://docs.openstack.org/api-ref/compute/?expanded=create-server-detail#create-server > imageRef (Optional) | body | string | The UUID of the image to use for your server instance. This is not required in case of boot from volume. In all other cases it is required and must be a valid UUID otherwise API will return 400. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services