Skip to content

Commit

Permalink
cant call a function within fab decored tasks
Browse files Browse the repository at this point in the history
Change-Id: I610693b10f09d0be9969bd97522061980cd8c72e
Closes-Bug: 1500746
  • Loading branch information
npchandran committed Sep 29, 2015
1 parent 013e07f commit 7d9a1f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
6 changes: 3 additions & 3 deletions fabfile/tasks/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
provision_vcenter_features
from fabfile.utils.cluster import get_vgw_details, get_orchestrator,\
get_vmware_details, get_tsn_nodes, get_toragent_nodes,\
get_esxi_vms_and_hosts, get_contrail_nodes
get_esxi_vms_and_hosts, is_contrail_node
from fabfile.tasks.esxi_defaults import apply_esxi_defaults

FAB_UTILS_DIR = '/opt/contrail/utils/fabfile/utils/'
Expand Down Expand Up @@ -1695,11 +1695,11 @@ def prov_encap_type_node(host_string, oper = 'add'):
#end prov_encap_type

@task
@hosts(get_contrail_nodes())
@hosts(env.roledefs['all'])
def setup_remote_syslog():
"""Provisions all the configs needed to bring up rsyslog as per the options mentioned
in the testbed file. USAGE: fab setup_remote_syslog."""
if env.roledefs['all']:
if is_contrail_node(env.host_string):
execute("setup_remote_syslog_node", env.host_string)

@task
Expand Down
18 changes: 7 additions & 11 deletions fabfile/utils/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,11 @@ def get_metadata_secret():
print "WARNING get_metadata_secret: Orchestrator(%s) is not supported" % orch
return metadata_secret

def get_contrail_nodes():
'''retrieve contrail nodes. Assuming that all contrail nodes are installed with
package - contrail-setup, retrieves nodes that has contrail-setup installed in it
def is_contrail_node(node):
'''Assuming that all contrail nodes are installed with
package - contrail-setup, returns True if the package is installed in the node
'''
all_nodes = env.roledefs['all']
contrail_nodes = []
for node in all_nodes:
with settings(host_string=node, warn_only=True):
package_info = get_build('contrail-setup')
if package_info:
contrail_nodes.append(node)
return contrail_nodes
package_info = ''
with settings(host_string=node, warn_only=True):
package_info = get_build('contrail-setup')
return True if package_info else False

0 comments on commit 7d9a1f2

Please sign in to comment.