3 # Copyright (c) 2016 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 """This script provides copy and installation of VPP build deb packages.
17 As destinations are used all DUT nodes from the topology file."""
23 from resources.libraries.python.ssh import SSH
26 """Copy and installation of VPP packages."""
28 parser = argparse.ArgumentParser()
29 parser.add_argument("-t", "--topo", required=True,
31 parser.add_argument("-d", "--directory", required=True,
32 help="Installation directory")
33 parser.add_argument("-p", "--packages", required=False, nargs='+',
34 help="Packages paths to copy")
35 parser.add_argument("-c", "--cancel", help="Cancel installation",
37 args = parser.parse_args()
38 topology_file = args.topo
39 packages = args.packages
40 install_dir = args.directory
41 cancel_installation = args.cancel
43 work_file = open(topology_file)
44 topology = load(work_file.read())['nodes']
47 if topology[node]['type'] == "DUT":
49 ssh.connect(topology[node])
51 if cancel_installation:
52 ret, _, err = ssh.exec_command("rm -r {}".format(install_dir))
54 print "Cancel unsuccessful:\n{}".format(err)
57 ret, _, err = ssh.exec_command("mkdir {}".format(install_dir))
59 print "Mkdir unsuccessful:\n{}".format(err)
62 # Copy packages from local path to installation dir
64 ssh.scp(local_path=deb, remote_path=install_dir)
66 # Installation of VPP deb packages
67 ret, _, err = ssh.exec_command_sudo(
68 "dpkg -i {}/*.deb".format(install_dir))
70 print "Installation unsuccessful:\n{}".format(err)
73 if __name__ == "__main__":