Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
b4368e33
Commit
b4368e33
authored
Jan 15, 2013
by
Stavros Sachtouris
Browse files
Add all quotaholder files in kamaki
parent
d1304043
Changes
9
Hide whitespace changes
Inline
Side-by-side
kamaki/clients/commissioning/__init__.py
View file @
b4368e33
...
...
@@ -33,16 +33,33 @@
# Import general commission framework
from
.exception
import
(
CallError
,
CorruptedError
,
InvalidDataError
,
ReturnButFail
,
register_exception
,
register_exceptions
)
from
kamaki.clients.commissioning.exception
import
(
CallError
,
CorruptedError
,
InvalidDataError
,
ReturnButFail
,
register_exception
,
register_exceptions
)
from
.callpoint
import
Callpoint
,
mkcallargs
from
kamaki.clients.commissioning.callpoint
import
(
Callpoint
,
mkcallargs
)
from
.specificator
import
(
Specificator
,
SpecifyException
,
Canonifier
,
CanonifyException
,
Canonical
,
Null
,
Nothing
,
Integer
,
Serial
,
Text
,
Bytes
,
Tuple
,
ListOf
,
Dict
,
Args
)
from
kamaki.clients.commissioning.specificator
import
(
Specificator
,
SpecifyException
,
Canonifier
,
CanonifyException
,
Canonical
,
Null
,
Nothing
,
Integer
,
Serial
,
Text
,
Bytes
,
Tuple
,
ListOf
,
Dict
,
Args
)
# Import standard implementations?
kamaki/clients/commissioning/callpoint.py
View file @
b4368e33
...
...
@@ -32,12 +32,15 @@
# or implied, of GRNET S.A.
from
.specificator
import
CanonifyException
from
.exception
import
CorruptedError
,
InvalidDataError
,
ReturnButFail
from
.importing
import
imp_module
from
kamaki.clients.commissioning.specificator
import
CanonifyException
from
kamaki.clients.commissioning.exception
import
CorruptedError
from
kamaki.clients.commissioning.exception
import
InvalidDataError
from
kamaki.clients.commissioning.exception
import
ReturnButFail
from
kamaki.clients.commissioning.importing
import
imp_module
from
re
import
compile
as
re_compile
,
sub
as
re_sub
class
Callpoint
(
object
):
api_spec
=
None
...
...
kamaki/clients/commissioning/specificator.py
View file @
b4368e33
...
...
@@ -35,13 +35,16 @@
from
random
import
random
,
choice
,
randint
from
math
import
log
from
inspect
import
isclass
from
.utils.argmap
import
(
argmap_decode
,
argmap_check
,
argmap_unpack_dict
,
argmap_unpack_list
)
from
kamaki.clients.commissioning.utils.argmap
import
(
argmap_decode
,
argmap_check
,
argmap_unpack_dict
,
argmap_unpack_list
)
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
.utils.ordereddict
import
OrderedDict
from
kamaki.clients.commissioning
.utils.ordereddict
import
OrderedDict
def
shorts
(
s
):
if
not
isinstance
(
s
,
unicode
):
...
...
kamaki/clients/commissioning/utils/argmap.py
View file @
b4368e33
...
...
@@ -34,12 +34,13 @@
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
.ordereddict
import
OrderedDict
from
kamaki.clients.commissioning.utils
.ordereddict
import
OrderedDict
from
itertools
import
chain
from
cStringIO
import
StringIO
ARGMAP_MAGIC
=
'[=ARGMAP=]'
class
arguments
(
object
):
__slots__
=
(
'args'
,
'kw'
)
...
...
kamaki/clients/commissioning/utils/newname.py
View file @
b4368e33
# Copyright 2012 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from
time
import
time
_counter
=
0
...
...
kamaki/clients/commissioning/utils/ordereddict.py
View file @
b4368e33
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.
# Passes Python2.7's test suite and incorporates all the latest updates.
#!/usr/bin/env python
# Copyright 2012 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and
# pypy. Passes Python2.7's test suite and incorporates all the latest updates.
try
:
from
thread
import
get_ident
as
_get_ident
...
...
@@ -17,9 +52,11 @@ class OrderedDict(dict):
# An inherited dict maps keys to values.
# The inherited dict provides __getitem__, __len__, __contains__, and get.
# The remaining methods are order-aware.
# Big-O running times for all methods are the same as for regular dictionaries.
# Big-O running times for all methods are the same as for regular
# dictionaries.
# The internal self.__map dictionary maps keys to links in a doubly linked list.
# The internal self.__map dictionary maps keys to links in a doubly linked
# list.
# The circular doubly linked list starts and ends with a sentinel element.
# The sentinel element never gets deleted (this simplifies the algorithm).
# Each link is stored as a list of length three: [PREV, NEXT, KEY].
...
...
@@ -42,8 +79,10 @@ class OrderedDict(dict):
def
__setitem__
(
self
,
key
,
value
,
dict_setitem
=
dict
.
__setitem__
):
'od.__setitem__(i, y) <==> od[i]=y'
# Setting a new item creates a new link which goes at the end of the linked
# list, and the inherited dictionary is updated with the new key/value pair.
# Setting a new item creates a new link which goes at the end of the
# linked
# list, and the inherited dictionary is updated with the new key/value
# pair.
if
key
not
in
self
:
root
=
self
.
__root
last
=
root
[
0
]
...
...
@@ -53,7 +92,8 @@ class OrderedDict(dict):
def
__delitem__
(
self
,
key
,
dict_delitem
=
dict
.
__delitem__
):
'od.__delitem__(y) <==> del od[y]'
# Deleting an existing item uses self.__map to find the link which is
# then removed by updating the links in the predecessor and successor nodes.
# then removed by updating the links in the predecessor and successor
# nodes.
dict_delitem
(
self
,
key
)
link_prev
,
link_next
,
key
=
self
.
__map
.
pop
(
key
)
link_prev
[
1
]
=
link_next
...
...
@@ -142,9 +182,9 @@ class OrderedDict(dict):
'''od.update(E, **F) -> None. Update od from dict/iterable E and F.
If E is a dict instance, does: for k in E: od[k] = E[k]
If E has a .keys() method, does: for k in E.keys(): od[k]
=
E[k]
If E has a .keys() method, does: for k in E.keys(): od[k]
=
E[k]
Or if E is an iterable of items, does: for k, v in E: od[k] = v
In either case, this is followed by: for k, v in F.items(): od[k]
=
v
In either case, this is followed by: for k, v in F.items(): od[k]
=
v
'''
if
len
(
args
)
>
2
:
...
...
kamaki/clients/commissioning_client.py
View file @
b4368e33
...
...
@@ -31,12 +31,13 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from
synnefo.lib
.commissioning
import
Callpoint
,
CallError
from
synnefo.lib
.commissioning.utils.debug
import
debug
from
.
import
Client
from
kamaki.clients
.commissioning
import
Callpoint
,
CallError
from
kamaki.clients
.commissioning.utils.debug
import
debug
from
kamaki.clients
import
Client
from
json
import
loads
as
json_loads
,
dumps
as
json_dumps
class
CommissioningClient
(
Callpoint
):
def
__init__
(
self
,
base_url
,
token
):
...
...
@@ -46,7 +47,7 @@ class CommissioningClient(Callpoint):
def
do_make_call
(
self
,
api_call
,
data
):
_kc
=
self
.
_kc
gettable
=
[
'list'
,
'get'
,
'read'
]
method
=
(
_kc
.
get
if
any
(
api_call
.
startswith
(
x
)
for
x
in
gettable
)
else
_kc
.
post
)
...
...
@@ -54,10 +55,10 @@ class CommissioningClient(Callpoint):
path
=
api_call
json_data
=
json_dumps
(
data
)
debug
(
"%s %s
\n
%s
\n
<<<
\n
"
,
method
.
func_name
,
path
,
json_data
)
resp
=
method
(
path
,
data
=
json_data
,
success
=
(
200
,
450
,
500
))
resp
=
method
(
path
,
data
=
json_data
,
success
=
(
200
,
450
,
500
))
debug
(
">>>
\n
Status: %s"
,
resp
.
status_code
)
body
=
resp
.
text
debug
(
"
\n
%s
\n
<<<
\n
"
,
body
[:
128
]
if
body
else
None
)
...
...
kamaki/clients/quotaholder.py
deleted
100644 → 0
View file @
d1304043
# Copyright 2012 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from
synnefo.lib.quotaholder.api
import
QuotaholderAPI
,
QH_PRACTICALLY_INFINITE
from
.commissioning_client
import
CommissioningClient
class
QuotaholderClient
(
CommissioningClient
):
api_spec
=
QuotaholderAPI
()
appname
=
'quotaholder'
def
__init__
(
self
,
base_url
=
None
,
token
=
None
):
default_url
=
'http://127.0.0.1:8008/quotaholder/v'
base_url
=
base_url
if
base_url
else
default_url
super
(
self
.
__class__
,
self
).
__init__
(
base_url
,
token
)
kamaki/clients/quotaholder/api/__init__.py
View file @
b4368e33
...
...
@@ -31,9 +31,10 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from
kamaki.clients.quotaholder.api
import
QuotaholderAPI
from
kamaki.clients.quotaholder.api
import
QH_PRACTICALLY_INFINITE
from
kamaki.clients.quotaholder.exception
import
(
from
kamaki.clients.quotaholder.api.quotaholder
import
(
QuotaholderAPI
,
QH_PRACTICALLY_INFINITE
)
from
kamaki.clients.quotaholder.api.exception
import
(
InvalidKeyError
,
NoEntityError
,
NoQuantityError
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment