liusheng 01c02f8f7b Add node aggregate commands support
Partially Implements: bp node-aggregate

Change-Id: I37a3da4e4f35aba5efda66a62777e70476b07676
2017-08-15 15:49:06 +08:00

48 lines
1.4 KiB
Python

# Copyright 2017 Huawei, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from moganclient.common import base
class Aggregate(base.Resource):
pass
class AggregateManager(base.ManagerWithFind):
resource_class = Aggregate
def create(self, name, metadata=None):
url = '/aggregates'
data = {'name': name}
if metadata:
data['metadata'] = metadata
return self._create(url, data=data)
def delete(self, aggregate):
url = '/aggregates/%s' % base.getid(aggregate)
return self._delete(url)
def get(self, aggregate):
url = '/aggregates/%s' % base.getid(aggregate)
return self._get(url)
def list(self):
url = '/aggregates'
return self._list(url, response_key='aggregates')
def update(self, aggregate, updates):
url = '/aggregates/%s' % base.getid(aggregate)
return self._update(url, data=updates)