root / snfOCCI / registry.py @ f25a4623
History | View | Annotate | Download (2.3 kB)
1 | f25a4623 | nasia | # Copyright 2012-2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | f25a4623 | nasia | #
|
3 | f25a4623 | nasia | # Redistribution and use in source and binary forms, with or
|
4 | f25a4623 | nasia | # without modification, are permitted provided that the following
|
5 | f25a4623 | nasia | # conditions are met:
|
6 | f25a4623 | nasia | #
|
7 | f25a4623 | nasia | # 1. Redistributions of source code must retain the above
|
8 | f25a4623 | nasia | # copyright notice, this list of conditions and the following
|
9 | f25a4623 | nasia | # disclaimer.
|
10 | f25a4623 | nasia | #
|
11 | f25a4623 | nasia | # 2. Redistributions in binary form must reproduce the above
|
12 | f25a4623 | nasia | # copyright notice, this list of conditions and the following
|
13 | f25a4623 | nasia | # disclaimer in the documentation and/or other materials
|
14 | f25a4623 | nasia | # provided with the distribution.
|
15 | f25a4623 | nasia | #
|
16 | f25a4623 | nasia | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | f25a4623 | nasia | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | f25a4623 | nasia | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | f25a4623 | nasia | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | f25a4623 | nasia | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | f25a4623 | nasia | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | f25a4623 | nasia | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | f25a4623 | nasia | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | f25a4623 | nasia | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | f25a4623 | nasia | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | f25a4623 | nasia | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | f25a4623 | nasia | # POSSIBILITY OF SUCH DAMAGE.
|
28 | f25a4623 | nasia | #
|
29 | f25a4623 | nasia | # The views and conclusions contained in the software and
|
30 | f25a4623 | nasia | # documentation are those of the authors and should not be
|
31 | f25a4623 | nasia | # interpreted as representing official policies, either expressed
|
32 | f25a4623 | nasia | # or implied, of GRNET S.A.
|
33 | f25a4623 | nasia | |
34 | f25a4623 | nasia | |
35 | b7fca2d2 | John Giannelos | from kamaki.clients.compute import ComputeClient |
36 | b7fca2d2 | John Giannelos | from kamaki.clients.cyclades import CycladesClient |
37 | 4ab8bfab | nasia | from kamaki.cli.config import Config |
38 | b7fca2d2 | John Giannelos | |
39 | fe35958e | nasia | from snfOCCI.config import SERVER_CONFIG |
40 | fe35958e | nasia | |
41 | b46572ab | John Giannelos | from occi import registry |
42 | b7fca2d2 | John Giannelos | from occi.core_model import Mixin |
43 | b7fca2d2 | John Giannelos | from occi.backend import MixinBackend |
44 | b7fca2d2 | John Giannelos | from occi.extensions.infrastructure import RESOURCE_TEMPLATE, OS_TEMPLATE |
45 | b46572ab | John Giannelos | |
46 | b46572ab | John Giannelos | class snfRegistry(registry.NonePersistentRegistry): |
47 | b46572ab | John Giannelos | |
48 | b46572ab | John Giannelos | def add_resource(self, key, resource, extras): |
49 | b46572ab | John Giannelos | |
50 | b46572ab | John Giannelos | key = resource.kind.location + resource.attributes['occi.core.id']
|
51 | b46572ab | John Giannelos | resource.identifier = key |
52 | b46572ab | John Giannelos | |
53 | b46572ab | John Giannelos | super(snfRegistry, self).add_resource(key, resource, extras) |
54 | fe35958e | nasia | |
55 | fe35958e | nasia | def set_hostname(self, hostname): |
56 | fe35958e | nasia | hostname = "https://" + SERVER_CONFIG['hostname'] + ":" + str(SERVER_CONFIG['port']) |
57 | fe35958e | nasia | super(snfRegistry, self).set_hostname(hostname) |