MAJOR=4
MINOR=66
DEVNAME=ttyS2
     ™ˆÒÑÖ542Ð¿Ô     ™‹      Å•]oÚ0†ïû+<_ì.9`ê¨“­#HC¥€h¦mš¦ÉÄ&q—Ä‘mFÙ¯ŸC˜`UØ‡FÅ•íã7ç¼Ï9RLž…ÓAôq6Do£Û1š½{3v Þw aÖ]·ÕN0Â©1e`½^»ëŽ+UÑR“g]ÐF‰Ø¸Ì0\�*\ ’rÊìŠˆ&ãÁ¨`üÉ%¹2Z0Þ…•V Sª8’ñ/¹d«Œkx}¯Køšgh¹R1ÏiéÄVÚ¨3Ú°+B’mªÚí“Ö±é¶ t±-WmU@LŠ¾ÑL$…��,q@Dž ­bƒˆe¡a‘Ñâ«›ˆ%F43>þ4L?[˜´ú: ¥Š/}üjàO®¦þ5&4çh³æ¶ÖŒ©6ÈšKÁÙQñ�‡8¸ß�'ë„!×±¥²ØKÁ"¢Æ2Ó%µ¬=K�ªCU-aê�iÆìz>œDáh^·„U)öîþkj8˜Y}aP(��T›W]äy±ÐåÕÏ#Ú¹V"IrP£òP—2c\ÂÃ4›Ò²à ^]>²åµ¼ŽÓzéx—¨Ýë·z=¡ÃÌ¡ûèCÔèþQßÝü^ã !ø{.Ïi·¯‹Ú—}¯u”«çz7çâZåÌmB«ã§ {qF:; ×ž'W]œ†¯{æé5#îïžžò/¦°{fl3õCúlB¿«    8   ›ˆl–Ðz¾”Šj"Tâ‚À½q¶”Å£�þ[ŽXÖq²‘¸Ý�Jð?ŸØ„-´ï×ÁÀÕ ?÷     ›# 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.
"""
Kamatera node driver
"""

import json
import time
import datetime

from libcloud.utils.py3 import basestring
from libcloud.common.base import JsonResponse, ConnectionUserAndKey
from libcloud.compute.base import Node, NodeSize, NodeImage, NodeState, NodeDriver, NodeLocation
from libcloud.compute.types import Provider


class KamateraResponse(JsonResponse):
    """
    Response class for KamateraDriver
    """

    def parse_error(self):
        data = self.parse_body()
        if "message" in data:
            return data["message"]
        else:
            return json.dumps(data)


class KamateraConnection(ConnectionUserAndKey):
    """
    Connection class for KamateraDriver
    """

    host = "cloudcli.cloudwm.com"
    responseCls = KamateraResponse

    def add_default_headers(self, headers):
        """Adds headers that are needed for all requests"""
        headers["AuthClientId"] = self.user_id
        headers["AuthSecret"] = self.key
        headers["Accept"] = "application/json"
        headers["Content-Type"] = "application/json"
        return headers


class KamateraNodeDriver(NodeDriver):
    """
    Kamatera node driver

    :keyword    key: API Client ID, required for authentication
    :type       key: ``str``

    :keyword    secret: API Secret, required for authentcaiont
    :type       secret: ``str``
    """

    type = Provider.KAMATERA
    name = "Kamatera"
    website = "https://www.kamatera.com/"
    connectionCls = KamateraConnection
    features = {"create_node": ["password", "generates_password", "ssh_key"]}

    EX_BILLINGCYCLE_HOURLY = "hourly"
    EX_BILLINGCYCLE_MONTHLY = "monthly"

    def list_locations(self):
        """
        List available locations for deployment

        :rtype: ``list`` of :class:`NodeLocation`
        """
        response = self.connection.request("service/server?datacenter=1")
        return [
            self.ex_get_location(datacenter["id"], datacenter["subCategory"], datacenter["name"])
            for datacenter in response.object
        ]

    def list_sizes(self, location):
        """
        List predefined sizes for the given location.

        :param location: Location of the deployment.
        :type location: :class:`.NodeLocation`

        @inherits: :class:`NodeDriver.list_sizes`
        """
        response = self.connection.request("service/server?sizes=1&datacenter=%s" % location.id)
        return [
            self.ex_get_size(
                size["ramMB"],
                size["diskSizeGB"],
                size["cpuType"],
                size["cpuCores"],
                extraDiskSizesGB=[],
           