From notifications-return-16584-archive-asf-public=cust-asf.ponee.io@libcloud.apache.org Tue Dec 24 19:08:33 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 50C1E18065E for ; Tue, 24 Dec 2019 20:08:33 +0100 (CET) Received: (qmail 31889 invoked by uid 500); 24 Dec 2019 19:08:32 -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 31880 invoked by uid 99); 24 Dec 2019 19:08:32 -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; Tue, 24 Dec 2019 19:08:32 +0000 From: GitBox To: notifications@libcloud.apache.org Subject: [GitHub] [libcloud] Kami commented on a change in pull request #1395: Add LXD driver & tests Message-ID: <157721451257.23065.9070417785346835220.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Tue, 24 Dec 2019 19:08:32 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Kami commented on a change in pull request #1395: Add LXD driver & tests URL: https://github.com/apache/libcloud/pull/1395#discussion_r361214804 ########## File path: libcloud/container/drivers/lxd.py ########## @@ -0,0 +1,1269 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import base64 +import re +import os + + +try: + import simplejson as json +except Exception: + import json + +from libcloud.utils.py3 import httplib +from libcloud.utils.py3 import b + +from libcloud.common.base import JsonResponse, ConnectionUserAndKey +from libcloud.common.base import KeyCertificateConnection +from libcloud.common.types import InvalidCredsError + +from libcloud.container.base import (Container, ContainerDriver, + ContainerImage) +from libcloud.common.exceptions import BaseHTTPError + +from libcloud.compute.base import StorageVolume + +from libcloud.container.providers import Provider +from libcloud.container.types import ContainerState + +# Acceptable success strings comping from LXD API +LXD_API_SUCCESS_STATUS = ['Success'] +LXD_API_STATE_ACTIONS = ['stop', 'start', 'restart', 'freeze', 'unfreeze'] +LXD_API_IMAGE_SOURCE_TYPE = ["image", "migration", "copy", "none"] + +# the wording used by LXD to indicate that an error +# occurred for a request +LXD_ERROR_STATUS_RESP = 'error' + + +# helpers +def strip_http_prefix(host): + # strip the prefix + prefixes = ['http://', 'https://'] + for prefix in prefixes: + if host.startswith(prefix): + host = host.strip(prefix) + return host + + +def check_certificates(key_file, cert_file, **kwargs): Review comment: It appears that some of that logic is similar to the one in #1394 so once those PRs are merged, both of the drivers could perhaps be refactored to use those common utility functions. ---------------------------------------------------------------- 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