3 # Copyright 2016 RIFT.IO Inc
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 @file test_start_standby.py
19 @brief This test starts the launchpad on a remote VM
28 import multiprocessing
30 import rift
.auto
.session
33 def get_manifest_file():
34 artifacts_path
= os
.environ
["RIFT_ARTIFACTS"]
35 manifest_files
= glob
.glob(artifacts_path
+ "/manifest*xml")
36 manifest_files
.sort(key
=lambda x
: os
.stat(x
).st_mtime
)
37 return manifest_files
[0]
39 def copy_manifest_to_remote(remote_ip
, manifest_file
):
40 print ("Copying manifest file {} to remote".format(manifest_file
))
41 cmd
= "scp {0} {1}:/tmp/manifest.xml".format(manifest_file
, remote_ip
)
42 print ("Running command: {}".format(cmd
))
43 subprocess
.check_call(cmd
, shell
=True)
46 def test_start_lp_remote(remote_ip
):
47 rift_root
= os
.environ
.get('HOME_RIFT', os
.environ
.get('RIFT_ROOT'))
48 rift_install
= os
.environ
.get('RIFT_INSTALL')
50 copy_manifest_to_remote(remote_ip
, get_manifest_file())
52 cmd_template
= ("ssh_root {remote_ip} -q -o BatchMode=yes -o "
53 " UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -- "
54 " \"rm -rf /tmp/corosync; cd {rift_install}; {rift_root}/rift-shell -e -- {rift_install}/usr/bin/rwmain -m /tmp/manifest.xml\"").format(
57 rift_install
=rift_install
)
60 print ("Running cmd: {}".format(cmd
))
61 subprocess
.call(shlex
.split(cmd
))
63 print ("Starting launchpad on remote VM: {}".format(cmd_template
))
64 p
= multiprocessing
.Process(target
=start_lp
, args
=(cmd_template
,))
67 print ("Standby system started")
72 if __name__
== "__main__":
73 parser
= argparse
.ArgumentParser(description
='Start standby LP')
74 parser
.add_argument("--remote-ip", action
="store", dest
="remote_ip")
76 args
= parser
.parse_args()
78 test_start_lp_remote(args
.remote_ip
)