/usr/share/conjure-up/macumba/v2.py is in conjure-up 0.1.0.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | from .api import Base
from functools import partial
# https://github.com/juju/juju/blob/master/api/facadeversions.go
_FACADE_VERSIONS = {
"Action": 1,
"Addresser": 2,
"Agent": 2,
"AgentTools": 1,
"AllWatcher": 1,
"AllModelWatcher": 2,
"Annotations": 2,
"Backups": 1,
"Block": 2,
"Charms": 2,
"CharmRevisionUpdater": 1,
"Client": 1,
"Cleaner": 2,
"Controller": 2,
"Deployer": 1,
"DiskManager": 2,
"EntityWatcher": 2,
"FilesystemAttachmentsWatcher": 2,
"Firewaller": 2,
"HighAvailability": 2,
"ImageManager": 2,
"ImageMetadata": 2,
"InstancePoller": 2,
"KeyManager": 1,
"KeyUpdater": 1,
"LeadershipService": 2,
"Logger": 1,
"MachineManager": 2,
"Machiner": 1,
"MetricsManager": 1,
"MeterStatus": 1,
"MetricsAdder": 2,
"ModelManager": 2,
"Networker": 1,
"NotifyWatcher": 1,
"Pinger": 1,
"Provisioner": 2,
"ProxyUpdater": 1,
"Reboot": 2,
"RelationUnitsWatcher": 1,
"Resumer": 2,
"Service": 3,
"Storage": 2,
"Spaces": 2,
"Subnets": 2,
"StatusHistory": 2,
"StorageProvisioner": 2,
"StringsWatcher": 1,
"Upgrader": 1,
"UnitAssigner": 1,
"Uniter": 3,
"UserManager": 1,
"VolumeAttachmentsWatcher": 2,
"Undertaker": 1,
}
class JujuClient(Base):
""" Exposes Juju 2.0 facades
Example:
jujuc = JujuClient(
'wss://10.0.3.53:17070/model/e712da7b-6808-49ec-8c90-113b26d1650d/api',
'f2cbbb1f163f2ed8725e973e5eeaf51a')
jujuc.Client(request="FullStatus")
"""
API_VERSION = 2
def __init__(self, url, password, user='user-admin'):
for name, version in _FACADE_VERSIONS.items():
setattr(self, name, partial(self._request,
name_type=name,
version=version))
super().__init__(url, password, user)
def _request(self, name_type, version, request, params=None):
""" Performs a request
Params:
name_type: Facade type
version: Facade version
request: Name of Juju API call
params: Query options to pass to request
"""
if params is None:
params = {}
if not isinstance(params, dict):
raise Exception("Must be a dictionary of query parameters.")
return self.call({'Type': name_type,
'Version': version,
'Request': request,
'Params': params})
def call(self, params, timeout=None):
""" Get json data from juju api daemon.
Params:
params: Additional params to be passed into request
"""
with self.connlock:
req_id = self.conn.do_send(params)
return self.receive(req_id, timeout)
|