1
# Copyright 2014 Hewlett-Packard Development Company, L.P.
3
# Author: Endre Karlson <endre.karlson@hp.com>
5
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
# not use this file except in compliance with the License. You may obtain
7
# a copy of the License at
9
# http://www.apache.org/licenses/LICENSE-2.0
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
# License for the specific language governing permissions and limitations
16
from cueclient import controller
17
from cueclient import utils
18
from cueclient import warlock
20
Cluster = warlock.model_factory(utils.load_schema('v1', 'cluster'))
23
class ClusterController(controller.Controller):
24
"""Cluster Controller to manages operations."""
25
def create(self, name, nic, flavor, size, volume_size, auth_type, username,
28
auth = {'type': auth_type,
29
'token': {'username': username,
30
'password': password}}
33
"network_id": nic.split(","),
37
"volume_size": volume_size,
38
"authentication": auth,
40
url = self.build_url("/clusters")
42
return Cluster(self._post(url, json=data))
44
def list(self, marker=None, limit=None, params=None):
46
url = self.build_url("/clusters", marker, limit, params)
48
response = self._get(url, "clusters")
49
return [Cluster(i) for i in response]
51
def get(self, cluster_id):
53
url = self.build_url("/clusters/%s" % cluster_id)
55
return Cluster(self._get(url))
57
def update(self, cluster_id, values):
62
url = self.build_url("/clusters/%s" % cluster_id)
64
return self._patch(url, data=data)
66
def delete(self, cluster_id):
68
url = self.build_url("/clusters/%s" % cluster_id)
70
return self._delete(url)