-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ticket3492 update upgrade script #32
base: master
Are you sure you want to change the base?
Changes from 6 commits
263e60d
04615e0
9dc17b1
e105730
a60488b
478f8d3
d1b3142
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
import socket | ||
import subprocess | ||
from datetime import date, datetime | ||
from os.path import isfile, join | ||
|
||
import psutil | ||
import git | ||
|
||
|
@@ -43,6 +45,9 @@ | |
SOURCE_MACHINE_SETTINGS_CONFIG_PATH = os.path.join(SOURCE_FOLDER, SETTINGS_CONFIG_FOLDER, "NDXOTHER") | ||
SOURCE_MACHINE_SETTINGS_COMMON_PATH = os.path.join(SOURCE_FOLDER, SETTINGS_CONFIG_FOLDER, "common") | ||
|
||
THIRD_PARTY_INSTALLERS_REL_DIR = "..\\..\\third_party_installers" | ||
THIRD_PARTY_LATEST = os.path.join(THIRD_PARTY_INSTALLERS_REL_DIR, "latest_versions") | ||
|
||
VAR_DIR = os.path.join(INSTRUMENT_BASE_DIR, "var") | ||
MYSQL_FILES_DIR = os.path.join(VAR_DIR, "mysql") | ||
PV_BACKUPS_DIR = os.path.join(VAR_DIR, "deployment_pv_backups") | ||
|
@@ -60,6 +65,9 @@ | |
STAGE_DELETED = os.path.join(r"\\isis", "inst$", "backups$", "stage-deleted") | ||
SMALLEST_PERMISSIBLE_MYSQL_DUMP_FILE_IN_BYTES = 100 | ||
|
||
GIT_INSTALL_ARGS = ["/SILENT", "/CLOSEAPPLICATIONS"] | ||
JRE_INSTALL_ARGS = ["/s"] | ||
|
||
RAM_MIN = 8e+9 | ||
FREE_DISK_MIN = 3e+10 | ||
|
||
|
@@ -137,7 +145,6 @@ def run_instrument_install(self): | |
|
||
self._upgrade_tasks.check_resources() | ||
|
||
self._upgrade_tasks.check_java_installation() | ||
self._upgrade_tasks.install_mysql() | ||
self._upgrade_tasks.remove_seci_shortcuts() | ||
self._upgrade_tasks.remove_seci_one() | ||
|
@@ -158,7 +165,6 @@ def run_instrument_install(self): | |
self._upgrade_tasks.configure_motion() | ||
self._upgrade_tasks.add_nagios_checks() | ||
self._upgrade_tasks.update_instlist() | ||
self._upgrade_tasks.update_web_dashboard() | ||
self._upgrade_tasks.put_autostart_script_in_startup_area() | ||
|
||
def run_instrument_deploy(self): | ||
|
@@ -194,7 +200,8 @@ def run_instrument_deploy_main(self): | |
|
||
Current the server can not be started or stopped in this python script. | ||
""" | ||
self._upgrade_tasks.check_java_installation() | ||
self._upgrade_tasks.copy_third_party_installs() | ||
self._upgrade_tasks.configure_git() | ||
self._upgrade_tasks.backup_old_directories() | ||
self._upgrade_tasks.backup_database() | ||
self._upgrade_tasks.truncate_database() | ||
|
@@ -453,15 +460,7 @@ def setup_config_repository(self): | |
|
||
""" | ||
inst_name = self._machine_name | ||
|
||
subprocess.call("git config --global core.autocrlf true") | ||
subprocess.call("git config --global credential.helper wincred") | ||
subprocess.call("git config --global user.name spudulike") | ||
set_user_email = "git config --global user.email spudulike@{}.isis.cclrc.ac.uk" | ||
subprocess.call(set_user_email.format(inst_name.lower())) | ||
|
||
if not os.path.exists(SETTINGS_CONFIG_PATH): | ||
os.makedirs(SETTINGS_CONFIG_PATH) | ||
self.git_configs(inst_name) | ||
|
||
subprocess.call( | ||
"git clone http://[email protected]/gitroot/instconfigs/inst.git {}".format( | ||
|
@@ -577,25 +576,47 @@ def update_calibrations_repository(self): | |
self.prompt.prompt_and_raise_if_not_yes("There was an error pulling the calibrations repo.\n" | ||
"Manually pull it. Path='{}'".format(CALIBRATION_PATH)) | ||
|
||
@task("Install java") | ||
def check_java_installation(self): | ||
""" | ||
Checks Java installation | ||
""" | ||
java_url = "/<Public Share>/third_party_installers/" | ||
try: | ||
subprocess.call(["java", "-version"]) | ||
self.prompt.prompt_and_raise_if_not_yes( | ||
"Confirm that the java version above is the desired version or that you have " | ||
"upgraded to the desired 64-bit version from {}".format(java_url)) | ||
except (subprocess.CalledProcessError, WindowsError): | ||
self.prompt.prompt_and_raise_if_not_yes( | ||
"No installation of Java found on this machine. You can find an installer for the java" | ||
"version used in the current release in {}.".format(java_url)) | ||
@task("Copy third party installs") | ||
def copy_third_party_installs(self): | ||
""" | ||
Reminds the user to copy the third party installs from the share | ||
""" | ||
print("This is a new feature. If you find problems, add them to #3492, or open a new one and reference #3492") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this line is needed (if bugs are found, we'll find the appropriate ticket anyway) |
||
# enumerate files in directory | ||
installers = [f for f in os.listdir(THIRD_PARTY_LATEST) if isfile(join(THIRD_PARTY_LATEST, f))] | ||
# for each file | ||
for installer in installers: | ||
if "Git" in installer: | ||
RunProcess(working_dir=THIRD_PARTY_LATEST, executable_file=installer, prog_args=GIT_INSTALL_ARGS).run() | ||
# TODO update git config | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surely this is just a call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I forgot to remove the TODO comment |
||
elif "jre" in installer: | ||
# TODO uninstall old java and install latest version | ||
RunProcess(working_dir=THIRD_PARTY_LATEST, executable_file=installer, prog_args=JRE_INSTALL_ARGS).run(shell_option=True) | ||
elif "Npadm" in installer: | ||
if os.path.isdir("C:\\Program Files\\NPortAdminSuite"): | ||
print("NPort already installed") | ||
else: | ||
# Note that there is apparently no way to do a quiet install of NPort | ||
RunProcess(working_dir=THIRD_PARTY_LATEST, executable_file=installer).run(shell_option=True) | ||
|
||
def git_configs(self, machine_name): | ||
inst_name = machine_name | ||
|
||
subprocess.call("git config --global core.autocrlf true") | ||
subprocess.call("git config --global credential.helper wincred") | ||
subprocess.call("git config --global core.autocrlf input") | ||
subprocess.call("git config --global push.recurseSubmodules check") | ||
subprocess.call("git config --global user.name spudulike") | ||
set_user_email = "git config --global user.email spudulike@{}.isis.cclrc.ac.uk" | ||
subprocess.call(set_user_email.format(inst_name.lower())) | ||
|
||
if not os.path.exists(SETTINGS_CONFIG_PATH): | ||
os.makedirs(SETTINGS_CONFIG_PATH) | ||
|
||
@task("Configure git") | ||
def configure_git(self): | ||
self.git_configs(self._machine_name) | ||
|
||
self.prompt.prompt_and_raise_if_not_yes( | ||
"Is auto-update turned off? This can be checked from the Java control panel in " | ||
"C:\\Program Files\\Java\\jre\\bin\\javacpl.exe") | ||
|
||
@task("Configure COM ports") | ||
def configure_com_ports(self): | ||
|
@@ -834,7 +855,7 @@ def perform_server_tests(self): | |
repo.git.fetch() | ||
status = repo.git.status() | ||
print("Current repository status is: {}".format(status)) | ||
if "up-to-date with 'origin/{}".format(self._get_machine_name()) in status: | ||
if "up to date with 'origin/{}".format(self._get_machine_name()) in status: | ||
print("Configurations updating correctly") | ||
else: | ||
self.prompt.prompt_and_raise_if_not_yes( | ||
|
@@ -854,22 +875,6 @@ def update_instlist(self): | |
self.prompt.prompt_and_raise_if_not_yes( | ||
"Add the host name of the instrument to the list saved in the CS:INSTLIST PV") | ||
|
||
@task("Update web dashboard") | ||
def update_web_dashboard(self): | ||
""" | ||
Prompt user to add the instrument to the web dashboard | ||
""" | ||
redirect_page = os.path.join("C:", "inetpub", "wwwroot", "DataWeb", "Dashboards", "redirect.html") | ||
self.prompt.prompt_and_raise_if_not_yes( | ||
"Add the host name of the instrument to NDX_INSTS or ALL_INSTS in webserver.py in the JSON_bourne " | ||
"repository.") | ||
self.prompt.prompt_and_raise_if_not_yes( | ||
"On NDAEXTWEB1, pull the updated code and add a link to the instrument dashboard on the main " | ||
"dataweb page under {}".format(redirect_page)) | ||
self.prompt.prompt_and_raise_if_not_yes( | ||
"Restart JSON_bourne on NDAEXTWEB1 when appropriate. " | ||
"(WARNING: This will kill all existing sessions!)") | ||
|
||
@task("Install wiring tables") | ||
def install_wiring_tables(self): | ||
""" | ||
|
@@ -1039,7 +1044,7 @@ def put_autostart_script_in_startup_area(self): | |
autostart_script_name = "ibex_system_boot.bat" | ||
|
||
from_path = os.path.join(EPICS_PATH, autostart_script_name) | ||
to_path = os.path.join(PC_START_MENU, "Programs", "Startup", autostart_script_name) | ||
to_path = os.path.join(USER_START_MENU, "Programs", "Startup", autostart_script_name) | ||
|
||
# Remove old version if exists | ||
if os.path.exists(to_path): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
os.path.join