Мне нужно использовать Fabric для выполнения некоторых операций на веб-сайте, где один компьютер используется для файловой системы, а другой - для сервера базы данных.Мне нужно обработать два хоста.Как я могу это сделать?
У меня есть код, но я не могу заставить работать определение среды.
Идея состоит в том, чтобы подключиться к удаленному серверу файловой системы, получить файлы и затем подключиться кудаленный сервер базы данных и получить схему базы данных.
Код, который у меня есть сейчас, выглядит примерно так:
from __future__ import with_statement
from fabric.api import *
from fabric.contrib.console import confirm
'''
Here I define where is my "aid"s file structure
'''
local_root = '/home/andre/test' # This is the root folder for the audits
code_location = '/remote_code' # This is the root folder dor the customer code inside each audit
#
# ENVIRONMENTS CONFIGURATIONS
#
'''
Here I configure where is the remote file server
'''
def file_server():
env.user = 'andre'
env.hosts = ['localhost']
'''
Here I configure where is the database server
'''
def database_server():
env.user = 'andre'
env.hosts = ['192.168.5.1']
#
# START SCRIPT
#
def get_install(remote_location, aid):
### I will get the files
'''
Here I need to load the file_server() definitions
'''
working_folder = local_root + '/%s' % aid # I will define the working folder
local('mkdir ' + working_folder) # I will create the working folder for this audit
local('mkdir ' + working_folder + code_location) # I will create the folder to receive the code
get(remote_location, working_folder + code_location) # I will download the code to my machine
### I will get the database
'''
Here I need to load the database_server() definitions
'''
local('dir') # Just to test
Как я могу внутри get_install () определить среды file_server ()и database_server ()?
С наилучшими пожеланиями,