You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by GitBox <gi...@apache.org> on 2019/12/24 19:08:32 UTC

[GitHub] [libcloud] Kami commented on a change in pull request #1395: Add LXD driver & tests

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