1 from fabric.state import env
2 from fabric.operations import run, put
3
4
6
9
10 - def __init__(self, host, username, key):
11 """
12 Created an instance of this object
13 @param host: IP address of host of server to connect
14 @type host: str
15 @param username: Username used to connect
16 @type username: str
17 @param key: Path to the ssh key used for authentication
18 @type key: str
19 """
20 super(SearchEngineLoader, self).__init__()
21 env.host_string = host
22 env.user = username
23 env.key_filename = key
24
25
26 def raise_error(msg):
27 raise self.OperationError(msg)
28
29 env.abort_exception = lambda msg: raise_error(msg)
30
32 """
33 Loads a xmlgen file to the server and starts a re-index of the search engine
34 @param xmlfile: XML text to load on the search engine
35 @type xmlfile: str
36 """
37 try:
38 env.shell_env = {"PROJECT_DIR": '/mnt/solr/indexer',
39 "DATA_DIR": "/mnt/solr/datafeed"}
40
41
42 logger.debug("Uploading file %s" % xmlfile)
43 put(xmlfile,
44 r"/mnt/solr/datafeed/MainSystem/ypse.ypca.140218.2252.0.xml")
45
46
47 logger.debug("Start re-index of search engine")
48 run('${PROJECT_DIR}/bin/execute_merchant.sh ${PROJECT_DIR} ${DATA_DIR}', shell=True)
49 except Exception as e:
50 logger.error("Error uploading xmlgen file:\\n%s" % e.message)
51 raise e
52