Commit 4deda110 authored by Christos KK Loverdos's avatar Christos KK Loverdos
Browse files

Merge branch 'master' into testing

parents 03d14f3f 79b52e25
# Import general commission framework
from .exception import (CallError,
CommissionException,
CorruptedError,
InvalidDataError,
InvalidKeyError,
NoEntityError,
NoQuantityError,
NoCapacityError,
ExportLimitError,
ImportLimitError)
from .exception import CallError, CorruptedError, InvalidDataError
from .callpoint import Callpoint, get_callpoint, mkcallargs
......
......@@ -47,31 +47,8 @@ class CallError(Exception):
self = cls(*args, call_error=call_error)
return self
class CommissionException(CallError):
pass
class CorruptedError(CommissionException):
pass
class InvalidDataError(CommissionException):
pass
class InvalidKeyError(CommissionException):
pass
class NoEntityError(CommissionException):
pass
class NoQuantityError(CommissionException):
pass
class NoCapacityError(CommissionException):
pass
class ExportLimitError(CommissionException):
class CorruptedError(CallError):
pass
class ImportLimitError(CommissionException):
class InvalidDataError(CallError):
pass
from .cli import cli_generator
from .client import Kamaki_plugin
from .cli import kamaki_cli
from .client import kamaki_client
......@@ -5,18 +5,18 @@ from kamaki.cli import command
from kamaki.cli.command_tree import CommandTree
from kamaki.cli.errors import CLIError
class cli_generator(object):
class kamaki_cli(object):
api_spec = None
appname = None
plugin = None
client = None
add_context = False
ctree = None
description = None
def __init__(self):
self.api_spec = self.plugin.api_spec
self.appname = self.plugin.appname
self.api_spec = self.client.api_spec
self.appname = self.client.appname
self.ctree = CommandTree(self.appname, self.description)
def generate_all(self):
......@@ -34,7 +34,7 @@ class cli_generator(object):
this.config.get('global', 'token'))
this.base_url = (this.config.get(self.appname, 'url') or
this.config.get('global', 'url'))
this.client = self.plugin(this.base_url, this.token)
this.client = self.client(this.base_url, this.token)
def call(this, method, args):
ctx = '=null ' if self.add_context else ''
......
......@@ -6,10 +6,10 @@ from kamaki.clients import Client
from json import loads as json_loads, dumps as json_dumps
class Kamaki_plugin(Callpoint):
class kamaki_client(Callpoint):
def __init__(self, base_url, token):
super(Kamaki_plugin, self).__init__()
super(kamaki_client, self).__init__()
self._kc = Client(base_url, token)
def do_make_call(self, api_call, data):
......@@ -24,7 +24,7 @@ class Kamaki_plugin(Callpoint):
json_data = json_dumps(data)
debug("%s %s\n%s\n<<<\n", method.func_name, path, json_data)
resp = method(path, data=json_data)
resp = method(path, data=json_data, success=(200,450,500))
debug(">>>\nStatus: %s", resp.status_code)
body = resp.text
......
from .quotaholder import QuotaholderAPI
from .exception import ( InvalidKeyError, NoEntityError,
NoQuantityError, NoCapacityError,
ExportLimitError, ImportLimitError)
API_Spec = QuotaholderAPI
from commissioning import CallError
class CommissionException(CallError):
pass
class InvalidKeyError(CommissionException):
pass
class NoEntityError(CommissionException):
pass
class NoQuantityError(CommissionException):
pass
class NoCapacityError(CommissionException):
pass
class ExportLimitError(CommissionException):
pass
class ImportLimitError(CommissionException):
pass
from .client import quotaholder_plugin
from .client import quotaholder_client
from .cli import quotaholder_cli
#!/usr/bin/env python
from commissioning.lib.kamaki import cli_generator
from . import quotaholder_plugin
from commissioning.lib.kamaki import kamaki_cli
from . import quotaholder_client
class quotaholder_cli(cli_generator):
class quotaholder_cli(kamaki_cli):
def __init__(self):
self.plugin = quotaholder_plugin
self.client = quotaholder_client
self.add_context = True
self.description = 'Quotaholder description'
super(self.__class__, self).__init__()
#!/usr/bin/env python
from quotaholder.api import QuotaholderAPI
from commissioning.lib.kamaki import Kamaki_plugin
from commissioning.lib.kamaki import kamaki_client
class quotaholder_plugin(Kamaki_plugin):
class quotaholder_client(kamaki_client):
api_spec = QuotaholderAPI()
appname = 'quotaholder'
......
from quotaholder.api import QuotaholderAPI
from commissioning import ( Callpoint, CommissionException,
CorruptedError, InvalidDataError,
from quotaholder.api import (
InvalidKeyError, NoEntityError,
NoQuantityError, NoCapacityError,
ExportLimitError, ImportLimitError)
from commissioning import Callpoint, CorruptedError, InvalidDataError
from commissioning.utils.newname import newname
from django.db.models import Model, BigIntegerField, CharField, ForeignKey, Q
from django.db.models import Q
from django.db import transaction, IntegrityError
from .models import (Holder, Entity, Policy, Holding,
Commission, Provision, ProvisionLog, now)
......
from commissioning import ( Callpoint,
CommissionException,
CorruptedError, InvalidDataError,
InvalidKeyError, NoEntityError,
NoQuantityError, NoCapacityError )
from commissioning import CorruptedError
from django.db.models import Model, BigIntegerField, CharField, ForeignKey
from django.db import transaction
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment