Revision bbf0c7f1
b/snf-occi-server.py | ||
---|---|---|
68 | 68 |
def retrieve(self, entity, extras): |
69 | 69 |
|
70 | 70 |
# triggering cyclades to retrieve up to date information |
71 |
|
|
72 | 71 |
snf = ComputeClient(Config()) |
73 | 72 |
|
74 | 73 |
vm_id = int(entity.attributes['occi.core.id']) |
... | ... | |
93 | 92 |
|
94 | 93 |
|
95 | 94 |
def delete(self, entity, extras): |
95 |
|
|
96 | 96 |
# delete vm with vm_id = entity.attributes['occi.core.id'] |
97 | 97 |
snf = ComputeClient(Config()) |
98 | 98 |
vm_id = int(entity.attributes['occi.core.id']) |
... | ... | |
108 | 108 |
raise AttributeError("This action is currently no applicable.") |
109 | 109 |
|
110 | 110 |
elif action == START: |
111 |
|
|
112 | 111 |
print "Starting VM" |
113 | 112 |
client.start_server(vm_id) |
114 | 113 |
|
115 | 114 |
|
116 | 115 |
elif action == STOP: |
117 |
|
|
118 | 116 |
print "Stopping VM" |
119 | 117 |
client.shutdown_server(vm_id) |
120 | 118 |
|
121 | 119 |
elif action == RESTART: |
120 |
print "Restarting VM" |
|
122 | 121 |
snf.reboot_server(vm_id) |
123 | 122 |
|
124 | 123 |
|
125 | 124 |
elif action == SUSPEND: |
126 |
|
|
127 | 125 |
#TODO VM suspending |
128 |
|
|
129 |
entity.attributes['occi.compute.state'] = 'suspended' |
|
130 |
entity.actions = [START] |
|
126 |
print "Suspending VM" |
|
131 | 127 |
|
132 | 128 |
|
133 | 129 |
class MyAPP(Application): |
... | ... | |
137 | 133 |
|
138 | 134 |
def __call__(self, environ, response): |
139 | 135 |
|
140 |
return self._call_occi(environ, response) |
|
136 |
token = environ['HTTP_AUTH_TOKEN'] |
|
137 |
|
|
138 |
# token will be represented in self.extras |
|
139 |
|
|
140 |
return self._call_occi(environ, response, token) |
|
141 | 141 |
|
142 | 142 |
if __name__ == '__main__': |
143 | 143 |
|
144 | 144 |
APP = MyAPP() |
145 |
|
|
146 | 145 |
COMPUTE_BACKEND = ComputeBackend() |
147 | 146 |
|
148 | 147 |
APP.register_backend(COMPUTE, COMPUTE_BACKEND) |
... | ... | |
154 | 153 |
APP.register_backend(OS_TEMPLATE, MixinBackend()) |
155 | 154 |
|
156 | 155 |
snf = ComputeClient(Config()) |
157 |
|
|
158 | 156 |
images = snf.list_images() |
159 | 157 |
for image in images: |
160 | 158 |
IMAGE_ATTRIBUTES = {'occi.core.id': str(image['id'])} |
Also available in: Unified diff