def create_and_copy_service_token(): service_token = get_service_token() or run("openssl rand -hex 10") for host_string in env.roledefs['openstack']: with settings(host_string=host_string): if (files.exists('/etc/contrail/service.token') and env.roledefs['openstack'].index(host_string) == 0): service_token = run("cat /etc/contrail/service.token") else: run("echo '%s' > /etc/contrail/service.token" % service_token)
def create_and_copy_service_token(): service_token = get_service_token() or sudo("openssl rand -hex 10") for host_string in env.roledefs["openstack"]: with settings(host_string=host_string): if ( files.exists("/etc/contrail/service.token", use_sudo=True) and env.roledefs["openstack"].index(host_string) == 0 ): service_token = sudo("cat /etc/contrail/service.token") else: sudo("echo '%s' > /etc/contrail/service.token" % service_token)