@@ -0,0 +1,2373 @@
+# -*- coding: utf-8 -*-%0A%0A#    Copyright 2013 Mirantis, Inc.%0A#%0A#    Licensed under the Apache License, Version 2.0 (the %22License%22); you may%0A#    not use this file except in compliance with the License. You may obtain%0A#    a copy of the License at%0A#%0A#         http://www.apache.org/licenses/LICENSE-2.0%0A#%0A#    Unless required by applicable law or agreed to in writing, software%0A#    distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A#    License for the specific language governing permissions and limitations%0A#    under the License.%0A%0Aimport web%0A%0Afrom nailgun.db import db%0Afrom nailgun.api.models import Node%0Afrom nailgun.api.validators.node import NodeAttributesValidator%0Afrom nailgun.volumes.manager import VolumeManager%0Afrom nailgun.api.models import Node, NodeAttributes%0Afrom nailgun.api.handlers.base import JSONHandler, content_json%0A%0A%0Aclass NodeDisksHandler(JSONHandler):%0A    fields = ('node_id', 'volumes')%0A%0A    validator = NodeAttributesValidator%0A%0A    @classmethod%0A    def render(cls, instance, fields=None):%0A        return JSONHandler.render(instance, fields=cls.fields)%5B'volumes'%5D%0A%0A    @content_json%0A    def GET(self, node_id):%0A        node = self.get_object_or_404(Node, node_id)%0A        node_attrs = node.attributes%0A        if not node_attrs:%0A            return web.notfound()%0A%0A        return self.render(node_attrs)%0A%0A    @content_json%0A    def PUT(self, node_id):%0A        node = self.get_object_or_404(Node, node_id)%0A        data = self.validator.validate_json(web.data())%0A        if node.cluster:%0A            node.cluster.add_pending_changes('disks', node_id=node.id)%0A%0A        if not node.attributes:%0A            return web.notfound()%0A%0A        node.attributes.volumes = data%0A        db().commit()%0A        return self.render(node.attributes)%0A%0A%0Aclass NodeDefaultsDisksHandler(JSONHandler):%0A    fields = ('node_id', 'volumes')%0A%0A    @content_json%0A    def GET(self, node_id):%0A        node = self.get_object_or_404(Node, node_id)%0A        if not node.attributes:%0A            return web.notfound()%0A%0A        node_attrs = NodeDisksHandler.render(%0A            NodeAttributes(%0A                node_id=node.id,%0A                volumes=node.volume_manager.gen_volumes_info()))%0A%0A        return filter(%0A            lambda attr: attr%5B'type'%5D == 'disk',%0A            node_attrs)%0A

Add disks handlers