This repository has been archived by the owner on May 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathperfsonar_install.py
81 lines (62 loc) · 2.63 KB
/
perfsonar_install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python3
import os
import subprocess
import sys
def add_dependencies():
print("Adding dependencies")
# Get the source to download perfsonar if one not present already
if not os.path.isfile('/etc/apt/sources.list.d/perfsonar-jessie-release.list'):
try:
subprocess.check_output(['wget', '-P', '/etc/apt/sources.list.d/',
'http://downloads.perfsonar.net/debian/perfsonar-jessie-release.list'])
except subprocess.CalledProcessError as err:
print("[Error] Error adding source. Cannot continue with perfsonar installation please install it manually")
print(err)
else:
print("Source already present..skipping this step..")
# Add key
try:
subprocess.check_call(
['wget -qO - http://downloads.perfsonar.net/debian/perfsonar-debian-official.gpg.key | apt-key add -'],
shell=True)
except subprocess.CalledProcessError as err:
print("[Error] Cannot add key. Aborting perfsonar installation. Please install it manually")
print(err)
sys.exit()
print("Updating apt")
# Updating apt
try:
subprocess.check_call(['apt-get', '-y', 'update'])
except subprocess.CalledProcessError as err:
print("[Error] apt update failed. Aborting installation. Please install perfsonar manually")
print(err)
sys.exit()
def install_perfsonar_testpoint():
print("installing perfsonar testpoint")
try:
# Install from source added above
subprocess.call('sudo apt-get install --no-install-recommends perfsonar-testpoint -y', shell=True)
except subprocess.CalledProcessError as err:
print("[Error] Installation failed. Please install it manually")
print(err)
sys.exit()
def install_additional_packages():
packages = ['perfsonar-toolkit-ntp',
'perfsonar-toolkit-security',
'perfsonar-toolkit-servicewatcher',
'perfsonar-toolkit-sysctl',
'perfsonar-toolkit-systemenv-testpoint']
print('Installing the following packages {}'.format(", ".join(packages)))
try:
subprocess.check_call(['sudo', 'DEBIAN_FRONTEND=noninteractive', 'apt-get', '-y', 'install'] + packages)
except subprocess.CalledProcessError as err:
print("[Error] Cannot install additional packages. Please install them manually")
print(err)
sys.exit()
def setup_perfsonar():
# Call all the required functions
add_dependencies()
install_perfsonar_testpoint()
install_additional_packages()
if __name__ == '__main__':
setup_perfsonar()