Added dummy ClusterChangesHandler

This commit is contained in:
Mike Scherbakov 2012-09-07 17:44:08 +04:00 committed by default
parent 5e2b61ddfa
commit 3bab582b71
3 changed files with 41 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import netaddr
from models import Release, Cluster, Node, Role, Network, Vlan
from settings import settings
import rpc
def check_client_content_type(handler):
@ -215,6 +216,28 @@ class ClusterCollectionHandler(JSONHandler):
))
class ClusterChangesHandler(JSONHandler):
fields = (
"id",
"name",
)
def PUT(self, cluster_id):
web.header('Content-Type', 'application/json')
q = web.ctx.orm.query(Cluster).filter(Cluster.id == cluster_id)
cluster = q.first()
if not cluster:
return web.notfound()
message = {"method": "deploy", "args": {"var1": "Hello from nailgun"}}
rpc.cast('mcollective', message)
return json.dumps(
self.render(cluster),
indent=4
)
class ReleaseHandler(JSONHandler):
fields = (
"id",

View File

@ -3,6 +3,7 @@
import web
from api.handlers import ClusterHandler, ClusterCollectionHandler
from api.handlers import ClusterChangesHandler
from api.handlers import ReleaseHandler, ReleaseCollectionHandler
from api.handlers import NodeHandler, NodeCollectionHandler
from api.handlers import RoleHandler, RoleCollectionHandler
@ -13,6 +14,7 @@ urls = (
r'/releases/(?P<release_id>\d+)/?$', 'ReleaseHandler',
r'/clusters/?$', 'ClusterCollectionHandler',
r'/clusters/(?P<cluster_id>\d+)/?$', 'ClusterHandler',
r'/clusters/(?P<cluster_id>\d+)/changes/?$', 'ClusterChangesHandler',
r'/nodes/?$', 'NodeCollectionHandler',
r'/nodes/(?P<node_id>\d+)/?$', 'NodeHandler',
r'/roles/?$', 'RoleCollectionHandler',

View File

@ -0,0 +1,16 @@
import json
from base import BaseHandlers
from base import reverse
class TestClusterChangesHandler(BaseHandlers):
def test_cluster_starts_deploy(self):
cluster = self.create_default_cluster()
resp = self.app.put(
reverse(
'ClusterChangesHandler',
kwargs={'cluster_id': cluster.id}),
headers=self.default_headers
)
self.assertEquals(200, resp.status)