From 9d56efeb391ebf26889b32d1b450cb59b7b01308 Mon Sep 17 00:00:00 2001 From: "Yuanbin.Chen" Date: Mon, 7 May 2018 14:29:25 +0800 Subject: [PATCH] Change clustering example test create parameter This patch fix profile and policy create parameter error, fix cluster test return to_dict error. Change-Id: I3ba61df97588a35d11149ed5c2edcc69023b2f53 Signed-off-by: Yuanbin.Chen --- examples/clustering/cluster.py | 20 ++++++++++---------- examples/clustering/node.py | 4 ++-- examples/clustering/policy.py | 18 ++++++++++-------- examples/clustering/profile.py | 3 ++- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/examples/clustering/cluster.py b/examples/clustering/cluster.py index a4d46ce08..7710f5f7b 100644 --- a/examples/clustering/cluster.py +++ b/examples/clustering/cluster.py @@ -91,7 +91,7 @@ def cluster_add_nodes(conn): node_ids = [NODE_ID] res = conn.clustering.cluster_add_nodes(CLUSTER_ID, node_ids) - print(res.to_dict()) + print(res) def cluster_del_nodes(conn): @@ -99,7 +99,7 @@ def cluster_del_nodes(conn): node_ids = [NODE_ID] res = conn.clustering.cluster_del_nodes(CLUSTER_ID, node_ids) - print(res.to_dict()) + print(res) def cluster_replace_nodes(conn): @@ -111,21 +111,21 @@ def cluster_replace_nodes(conn): old_node: new_node } res = conn.clustering.cluster_replace_nodes(CLUSTER_ID, **spec) - print(res.to_dict()) + print(res) def cluster_scale_out(conn): print("Inflate the size of a cluster:") res = conn.clustering.cluster_scale_out(CLUSTER_ID, 1) - print(res.to_dict()) + print(res) def cluster_scale_in(conn): print("Shrink the size of a cluster:") res = conn.clustering.cluster_scale_in(CLUSTER_ID, 1) - print(res.to_dict()) + print(res) def cluster_resize(conn): @@ -138,7 +138,7 @@ def cluster_resize(conn): 'number': 2 } res = conn.clustering.cluster_resize(CLUSTER_ID, **spec) - print(res.to_dict()) + print(res) def cluster_attach_policy(conn): @@ -147,21 +147,21 @@ def cluster_attach_policy(conn): spec = {'enabled': True} res = conn.clustering.cluster_attach_policy(CLUSTER_ID, POLICY_ID, **spec) - print(res.to_dict()) + print(res) def cluster_detach_policy(conn): print("Detach a policy from a cluster:") res = conn.clustering.cluster_detach_policy(CLUSTER_ID, POLICY_ID) - print(res.to_dict()) + print(res) def check_cluster(conn): print("Check cluster:") res = conn.clustering.check_cluster(CLUSTER_ID) - print(res.to_dict()) + print(res) def recover_cluster(conn): @@ -169,4 +169,4 @@ def recover_cluster(conn): spec = {'check': True} res = conn.clustering.recover_cluster(CLUSTER_ID, **spec) - print(res.to_dict()) + print(res) diff --git a/examples/clustering/node.py b/examples/clustering/node.py index 40910b452..2ce8a0d99 100644 --- a/examples/clustering/node.py +++ b/examples/clustering/node.py @@ -82,7 +82,7 @@ def check_node(conn): print("Check Node:") node = conn.clustering.check_node(NODE_ID) - print(node.to_dict()) + print(node) def recover_node(conn): @@ -90,4 +90,4 @@ def recover_node(conn): spec = {'check': True} node = conn.clustering.recover_node(NODE_ID, **spec) - print(node.to_dict()) + print(node) diff --git a/examples/clustering/policy.py b/examples/clustering/policy.py index dca4aca5d..2f4c3361b 100644 --- a/examples/clustering/policy.py +++ b/examples/clustering/policy.py @@ -30,17 +30,19 @@ def list_policies(conn): def create_policy(conn): print("Create Policy:") - - spec = { - 'policy': 'senlin.policy.deletion', - 'version': 1.0, - 'properties': { - 'criteria': 'oldest_first', - 'destroy_after_deletion': True, + attrs = { + 'name': 'dp01', + 'spec': { + 'policy': 'senlin.policy.deletion', + 'version': 1.0, + 'properties': { + 'criteria': 'oldest_first', + 'destroy_after_deletion': True, + } } } - policy = conn.clustering.create_policy('dp01', spec) + policy = conn.clustering.create_policy(attrs) print(policy.to_dict()) diff --git a/examples/clustering/profile.py b/examples/clustering/profile.py index 1c3ae6bcc..ffaf3a6d2 100644 --- a/examples/clustering/profile.py +++ b/examples/clustering/profile.py @@ -39,6 +39,7 @@ def create_profile(conn): spec = { 'profile': 'os.nova.server', 'version': 1.0, + 'name': 'os_server', 'properties': { 'name': SERVER_NAME, 'flavor': FLAVOR_NAME, @@ -49,7 +50,7 @@ def create_profile(conn): } } - profile = conn.clustering.create_profile('os_server', spec) + profile = conn.clustering.create_profile(spec) print(profile.to_dict())