示例#1
0
 def _update_site_package(self):
     makedirs(properties.PRODUCTION_DIR)
     for module in BIN_MODULES:
         os.system('rm -f %s/%s.py*' % (properties.PRODUCTION_DIR, module))
         file = InstallFile(self.options, module + ".pyc")
         file.relocate(properties.PRODUCTION_DIR)
         file.chmod(0644)
示例#2
0
 def _update_site_package(self):
     makedirs(properties.PRODUCTION_DIR)
     for module in BIN_MODULES:
         os.system('rm -f %s/%s.py*' % (properties.PRODUCTION_DIR, module))
         file = InstallFile(self.options, module+".pyc")
         file.relocate(properties.PRODUCTION_DIR)
         file.chmod(0644)
 def _update_bin(self):
     # Ensure the target directory exists.
     makedirs(BIN_DIR)
     self.cwd.pushd('bin')
     blinky_bill = 'blinky_bill'
     wdt = 'wdt'
     bin_list = ('watchdog', )
     keywords = {}
     keywords.update(self.keywords)
     keywords[CommandKeywords.FATAL_KEY] = 1
     if os.path.exists(os.path.join(TARGET_ROOT, 'proc/mediator/sig')):
         # Only copy blinky_bill and wdt if /proc/mediator/pattern exists.
         bin_list += (blinky_bill, wdt)
     else:
         os.system(
             'rm -f %s' %
             os.path.join(BIN_DIR, os.path.basename(blinky_bill)),
             **keywords)
         os.system(
             'rm -f %s' % os.path.join(BIN_DIR, os.path.basename(wdt)),
             **keywords)
     for executable_source in bin_list:
         executable_target = os.path.join(
             BIN_DIR, os.path.basename(executable_source))
         # Copy the executable to the BIN_DIR.
         os.system('rm -f %s' % executable_target, **keywords)
         file = InstallFile(self.options, executable_source)  #!read_only
         file.relocate(BIN_DIR)
         file.chmod(0775)
     # Force a specific environment.
     keywords = {}
     keywords['ENV'] = properties.as_environment()
     # @fixme mpxconfig uses tools.lib, which should probably be cloned
     #        somewhere.
     keywords['ENV']['PYTHONPATH'] = '%s:%s' % (MPX_PYTHON_LIB, ROOT)
     create_pyscript(MPXCONFIG_SCRIPT, MPXCONFIG_PYC, **keywords)
     create_pyscript(MPXUPGRADE_SCRIPT, MPXUPGRADE_PYC, **keywords)
     create_pyscript(IPCHECK_SCRIPT, IPCHECK_PYC, **keywords)
     # @fixme This could be much cleaner.
     # Delete versions of old executables in incorrect places.
     correct_dir = os.path.realpath(BIN_DIR)
     for old_dir in (os.path.join(TARGET_ROOT,
                                  'bin'), os.path.join(TARGET_ROOT, 'sbin'),
                     os.path.join(TARGET_ROOT, 'usr/bin'),
                     os.path.join(TARGET_ROOT, 'usr/sbin')):
         old_dir = os.path.realpath(old_dir)
         if old_dir == correct_dir:
             # If old_dir == correct_dir, then old_dir 'taint so
             # old...
             continue
         for basename in ('watchdog', 'blinky_bill', 'mpxconfig',
                          'mpxupgrade', 'ipcheck'):
             old_file = os.path.join(old_dir, basename)
             if os.path.exists(old_file):
                 keywords = {}
                 keywords.update(self.keywords)
                 keywords[CommandKeywords.FATAL_KEY] = 1
                 os.system('rm -f %s' % old_file, **keywords)
     self.cwd.popd()
     return
示例#4
0
 def _update_mpx_python_lib(self):
     # Ensure the target directory exists.
     makedirs(MPX_PYTHON_LIB)
     keywords = {}
     keywords.update(self.keywords)
     keywords[CommandKeywords.FATAL_KEY] = 1
     #
     #
     # Install mpxconfig, mpxupgrade and associated libraries.
     # @fixme Consolodate /usr/lib/mpx/python, site-packages and the
     #        minimal moab...
     self.cwd.pushd("lib")
     for module in LIB_MODULES:
         os.system("rm -f %s/%s.py*" % (MPX_PYTHON_LIB, module), **keywords)
         file = InstallFile(self.options, module + ".pyc")  # !read_only (copy)
         file.relocate(MPX_PYTHON_LIB)
         file.chmod(0664)
         continue
     self.cwd.popd()
     self.cwd.pushd("bin")
     for module in BIN_MODULES:
         os.system("rm -f %s/%s.py*" % (MPX_PYTHON_LIB, module), **keywords)
         file = InstallFile(self.options, module + ".pyc")
         file.relocate(MPX_PYTHON_LIB)
         file.chmod(0664)
         continue
     self.cwd.popd()
     return
 def _update_mpx_python_lib(self):
     # Ensure the target directory exists.
     makedirs(MPX_PYTHON_LIB)
     keywords = {}
     keywords.update(self.keywords)
     keywords[CommandKeywords.FATAL_KEY] = 1
     #
     #
     # Install mpxconfig, mpxupgrade and associated libraries.
     # @fixme Consolodate /usr/lib/mpx/python, site-packages and the
     #        minimal moab...
     self.cwd.pushd('lib')
     for module in LIB_MODULES:
         os.system('rm -f %s/%s.py*' % (MPX_PYTHON_LIB, module), **keywords)
         file = InstallFile(self.options,
                            module + ".pyc")  # !read_only (copy)
         file.relocate(MPX_PYTHON_LIB)
         file.chmod(0664)
         continue
     self.cwd.popd()
     self.cwd.pushd('bin')
     for module in BIN_MODULES:
         os.system('rm -f %s/%s.py*' % (MPX_PYTHON_LIB, module), **keywords)
         file = InstallFile(self.options, module + ".pyc")
         file.relocate(MPX_PYTHON_LIB)
         file.chmod(0664)
         continue
     self.cwd.popd()
     return
 def _force_target_directory(self, directory):
     makedirs(directory)
     chown(directory, "root", "mpxadmin", ignore_errors=1)
     keywords = {}
     keywords.update(self.keywords)
     keywords[CommandKeywords.FATAL_KEY] = 0
     os.system("chmod 0770 %s" % (directory, ), **keywords)
     return
示例#7
0
 def _update_var(self):
     # Ensure that there is a proftpd in var
     PROFTPD_DIR = os.path.realpath(os.path.join(TARGET_ROOT, "var", "proftpd"))
     makedirs(PROFTPD_DIR)
     # Ensure that there is a lock in var
     VAR_LOCK = os.path.realpath(os.path.join(TARGET_ROOT, "var", "lock"))
     makedirs(VAR_LOCK, 0755)
     return
示例#8
0
 def _force_target_directory(self, directory):
     makedirs(directory)
     chown(directory, "root", "mpxadmin", ignore_errors=1)
     keywords = {}
     keywords.update(self.keywords)
     keywords[CommandKeywords.FATAL_KEY] = 0
     os.system("chmod 0770 %s" % (directory,), **keywords)
     return
 def _update_var(self):
     # Ensure that there is a proftpd in var
     PROFTPD_DIR = os.path.realpath(
         os.path.join(TARGET_ROOT, 'var', 'proftpd'))
     makedirs(PROFTPD_DIR)
     # Ensure that there is a lock in var
     VAR_LOCK = os.path.realpath(os.path.join(TARGET_ROOT, 'var', 'lock'))
     makedirs(VAR_LOCK, 0755)
     return
示例#10
0
 def _update_dhcpcd_exe(self):
     #
     # Upgrade /etc/dhcpc/dhcpcd.exe
     makedirs(ETCDHCPC_DIR, 0755)
     self.cwd.pushd("bin")
     file = InstallFile(self.options, "dhcpcd.exe")
     file.relocate(ETCDHCPC_DIR)
     file.chmod(0770)
     self.cwd.popd()
     return
示例#11
0
 def _update_bin(self):
     # Ensure the target directory exists.
     makedirs(BIN_DIR)
     self.cwd.pushd("bin")
     blinky_bill = "blinky_bill"
     wdt = "wdt"
     bin_list = ("watchdog",)
     keywords = {}
     keywords.update(self.keywords)
     keywords[CommandKeywords.FATAL_KEY] = 1
     if os.path.exists(os.path.join(TARGET_ROOT, "proc/mediator/sig")):
         # Only copy blinky_bill and wdt if /proc/mediator/pattern exists.
         bin_list += (blinky_bill, wdt)
     else:
         os.system("rm -f %s" % os.path.join(BIN_DIR, os.path.basename(blinky_bill)), **keywords)
         os.system("rm -f %s" % os.path.join(BIN_DIR, os.path.basename(wdt)), **keywords)
     for executable_source in bin_list:
         executable_target = os.path.join(BIN_DIR, os.path.basename(executable_source))
         # Copy the executable to the BIN_DIR.
         os.system("rm -f %s" % executable_target, **keywords)
         file = InstallFile(self.options, executable_source)  #!read_only
         file.relocate(BIN_DIR)
         file.chmod(0775)
     # Force a specific environment.
     keywords = {}
     keywords["ENV"] = properties.as_environment()
     # @fixme mpxconfig uses tools.lib, which should probably be cloned
     #        somewhere.
     keywords["ENV"]["PYTHONPATH"] = "%s:%s" % (MPX_PYTHON_LIB, ROOT)
     create_pyscript(MPXCONFIG_SCRIPT, MPXCONFIG_PYC, **keywords)
     create_pyscript(MPXUPGRADE_SCRIPT, MPXUPGRADE_PYC, **keywords)
     create_pyscript(IPCHECK_SCRIPT, IPCHECK_PYC, **keywords)
     # @fixme This could be much cleaner.
     # Delete versions of old executables in incorrect places.
     correct_dir = os.path.realpath(BIN_DIR)
     for old_dir in (
         os.path.join(TARGET_ROOT, "bin"),
         os.path.join(TARGET_ROOT, "sbin"),
         os.path.join(TARGET_ROOT, "usr/bin"),
         os.path.join(TARGET_ROOT, "usr/sbin"),
     ):
         old_dir = os.path.realpath(old_dir)
         if old_dir == correct_dir:
             # If old_dir == correct_dir, then old_dir 'taint so
             # old...
             continue
         for basename in ("watchdog", "blinky_bill", "mpxconfig", "mpxupgrade", "ipcheck"):
             old_file = os.path.join(old_dir, basename)
             if os.path.exists(old_file):
                 keywords = {}
                 keywords.update(self.keywords)
                 keywords[CommandKeywords.FATAL_KEY] = 1
                 os.system("rm -f %s" % old_file, **keywords)
     self.cwd.popd()
     return
    def _install_web_content_in_root(self,www_dir):
        self.cwd.pushd(HTML)	# Change to the HTML "source" directory.
        try:
            makedirs(www_dir)
            for f in ('energywise.html', 'events.html', 'index.html', 
                      'login.html', 'redirect.html', 'restore.html',
                      'schedules.html', 'security.html', 'system.html', 
                      'trends.html', 'troubleshoot.html', 'upgrade.html', 'fileUpload.html'):
                _copy_upgradeable_file(f, www_dir, self.options)

            for d in ('eventmanager', 'graphtool', 'mpx', 'msglog', 
                      'public', 'reference', 'stylesheets', 'templates',
                      'webapi', 'dojoroot'):
                src = os.path.abspath(d)
                # @note Using DST relative to the local directory did not
                #       work as expected in os.symlink(SRC, DST).  The
                #       relative DST was treated relative to SRC, not the
                #       CWD.
                dst = os.path.join(www_dir, d)
                #
                # Remove any existing link, file or directory:
                #
                if os.path.islink(dst):
                    # os.path.exists() of a link to a non-existant path
                    # returns False.
                    os.unlink(dst)
                elif os.path.isfile(dst):
                    os.unlink(dst)
                elif os.path.isdir(dst):
                    shutil.rmtree(dst)
                #
                # Create a LINK to the standard files:
                # @note DST is interpreted at runtime, NOT when the link is
                #       created.  This means that CWD is applied when the name
                #       is looked up.
                os.symlink(src, dst)
                
            # create sym links to cues libraries
            src = 'cues-0.2.1' 
            dst = 'cues'
            dst = os.path.join(www_dir, dst)
            src = os.path.join('/opt/cisco', src)
            if os.path.islink(dst) or os.path.isfile(dst):
                os.unlink(dst)
            elif os.path.isdir(dst):
                shutil.rmtree(dst)
            os.symlink(src, dst)
        finally:
            self.cwd.popd()
            pass
        return
 def install(self):
     #
     # Note:  Unfortunately the following two import statements have
     #        the side-effect of trying to create a directory under
     #        /var/mpx.  This isn't necessary when just trying to
     #        query this install script and in fact fails in some
     #        cases, so the imports were moved from the top of this
     #        script to here.
     #
     from moab.linux.lib.servicemgr import InittabManager
     from moab.linux.lib.servicemgr import InittabGroup
     
     chown(ROOT, MPX_UID, MPX_GID, recurse=1, ignore_errors=1)
     keywords = {}
     keywords.update(self.keywords)
     keywords.update({'ROOT':DUP_DIR})
     keywords[CommandKeywords.FATAL_KEY] = 1
     # Duplicate the config service so it will work after /usr/lib/broadway
     # is nuked.
     makedirs(DUP_DIR)
     os.system("cp *.pyc %s" % DUP_DIR, **keywords)
     chown(DUP_DIR, MPX_UID, MPX_GID, recurse=1, ignore_errors=1)
     os.system("chmod -R %o %s/*" % (0664, DUP_DIR), **keywords)
     # Create the config_service's custom launcher.
     create_pyscript(CONFIG_SCRIPT, CONFIG_PYC, **keywords)
     # Update inittab to include the new config service.
     inittab = InittabManager(**keywords)
     gname = 'MEDIATOR_CONFIGURATION_SERVICE'
     # Remove any existing mpx_igmp entry.
     for group in inittab.group_list:
         lines = group.text.split('\n')
         found = 0
         for i in range(0, len(lines)):
             line = lines[i]
             if line and line[0] != '#' and line.find('mpx_igmp') != -1:
                 lines[i] = "# %s # - %s" % (line, gname)
                 found = 1
         if found:
             text = lines.pop(0)
             for line in lines:
                 text = "%s\n%s" % (text, line)
             group.text = text
     # Add the Mediator Configuration Service.
     mcs = inittab.findgroup(gname)
     text = 'MCS:2345:respawn:%s' % CONFIG_SCRIPT
     if mcs is None:
         inittab.addgroup(InittabGroup(gname, text))
     else:
         mcs.text = text
     inittab.commit()
     return 0
 def _install_webapi_dir(self,root):
     webapi_path = os.path.join(root,'webapi')
     # Ensure that webapi is empty (by deleting it).
     os.system("rm -rf %s" % (webapi_path,), **self._fatal_keywords())
     # Ensure that the root directory exists.
     makedirs(root)
     # Copy over the latest webapi with all files as hard links
     # to avoid wasting space
     # - not that this makes the assumption that nothing in the
     # webapi directory is modified by the user - because if it
     # is this code will break the design goal of having the
     # install process restore every thing to a known state
     os.system("cp -r --link client %s" % (webapi_path,),**self.keywords)
     return
示例#15
0
 def _update_sbin(self):
     # Ensure the target directory exists.
     real_sbin_dir = os.path.join(TARGET_ROOT, "sbin")
     makedirs(real_sbin_dir)
     self.cwd.pushd("bin")
     keywords = {}
     keywords.update(self.keywords)
     keywords[CommandKeywords.FATAL_KEY] = 1
     for executable in ["hotplug"]:
         # Copy the executable to the real sbin directory.
         os.system("rm -f %s/%s" % (real_sbin_dir, executable), **keywords)
         file = InstallFile(self.options, executable)  #!read_only
         file.relocate(real_sbin_dir)
         file.chmod(0775)
     self.cwd.popd()
     return
 def _update_webdev_files(self):
     bin_dir = os.path.join(properties.WWW_ROOT,'bin')
     etc_dir = os.path.join(properties.WWW_ROOT,'etc')
     for dir in (bin_dir, etc_dir):
         makedirs(dir)
     self.cwd.pushd(bin_dir)
     for file in ('gzip','ls','tar'):
         source = os.path.join('/bin',file)
         target = os.path.join(bin_dir,file)
         os.system("rm -f %s && ln -s %s %s" % (target,source,target),
                   **self._fatal_keywords())
     self.cwd.popd()
     self.cwd.pushd(etc_dir)
     
     self.cwd.popd()
     return
 def _update_sbin(self):
     # Ensure the target directory exists.
     real_sbin_dir = os.path.join(TARGET_ROOT, 'sbin')
     makedirs(real_sbin_dir)
     self.cwd.pushd('bin')
     keywords = {}
     keywords.update(self.keywords)
     keywords[CommandKeywords.FATAL_KEY] = 1
     for executable in ['hotplug']:
         # Copy the executable to the real sbin directory.
         os.system('rm -f %s/%s' % (real_sbin_dir, executable), **keywords)
         file = InstallFile(self.options, executable)  #!read_only
         file.relocate(real_sbin_dir)
         file.chmod(0775)
     self.cwd.popd()
     return
    def _update_pppd_support(self):
        pppdir = os.path.join(properties.ETC_DIR, 'ppp')
        makedirs(pppdir)

        self.cwd.pushd('bin')
        file = InstallFile(self.options, 'ip-up.local')
        file.relocate(pppdir)
        file.chmod(0770)
        file = InstallFile(self.options, 'ip-down.local')
        file.relocate(pppdir)
        file.chmod(0770)
        self.cwd.popd()

        self.cwd.pushd('lib')
        file = InstallFile(self.options, 'routing.pyc', 1)
        file.relocate(pppdir)
        self.cwd.popd()
示例#19
0
    def _update_pppd_support(self):
        pppdir = os.path.join(properties.ETC_DIR, "ppp")
        makedirs(pppdir)

        self.cwd.pushd("bin")
        file = InstallFile(self.options, "ip-up.local")
        file.relocate(pppdir)
        file.chmod(0770)
        file = InstallFile(self.options, "ip-down.local")
        file.relocate(pppdir)
        file.chmod(0770)
        self.cwd.popd()

        self.cwd.pushd("lib")
        file = InstallFile(self.options, "routing.pyc", 1)
        file.relocate(pppdir)
        self.cwd.popd()
示例#20
0
 def _create_profile(self):
     self.options.normal_message("Creating profile for framework")
     if self.options.test:
         return
     profile_dir_name = os.path.join(ETC_DIR, "profile.d")
     profile_file_name = os.path.join(profile_dir_name, "broadway.sh")
     # Create the profile.
     makedirs(profile_dir_name)
     try:
         profile_file = open(profile_file_name, "w")
     except:
         self.options.error_message("FAILED TO OPEN %s" % profile_file_name)
         return
     # Add the tools directory to the search path.
     profile = """#!%s\n\nPATH="$PATH:%s"\nexport PATH""" % (profile_file_name, os.path.join(ROOT, "tools"))
     profile_file.write(profile)
     profile_file.close()
     os.chmod(profile_file_name, 0755)
示例#21
0
 def _update_devtools(self):
     DEVLIB_DIR = os.path.join(TARGET_ROOT, "opt/envenergy/devtools/2.0/x86")
     makedirs(DEVLIB_DIR)
     # Ensure executables will work with the current devtools.
     # @fixme Place holder.
     SLINK = os.path.join(DEVLIB_DIR, "lib")
     if os.path.ismount(SLINK):
         assert 0, "Existing %s can not be a mount point." % SLINK
     if os.path.islink(SLINK) or os.path.isfile(SLINK):
         self.options.normal_message("Removing old %s", SLINK)
         os.unlink(SLINK)
     elif os.path.isdir(SLINK):
         # assert 0, ("Existing %s can not be a directory." % SLINK)
         self.options.normal_message("Skipping linking of existing %s directory.", SLINK)
         return
     assert not os.path.exists(SLINK), "Failed to remove %s." % SLINK
     self.options.normal_message("Creating %s link to %s.", SLINK, os.path.join(TARGET_ROOT, "lib"))
     os.symlink(os.path.join(TARGET_ROOT, "lib"), SLINK)
     return
 def _create_profile(self):
     self.options.normal_message("Creating profile for framework")
     if self.options.test:
         return
     profile_dir_name = os.path.join(ETC_DIR, 'profile.d')
     profile_file_name = os.path.join(profile_dir_name, 'broadway.sh')
     # Create the profile.
     makedirs(profile_dir_name)
     try:
         profile_file = open(profile_file_name, 'w')
     except:
         self.options.error_message("FAILED TO OPEN %s" % profile_file_name)
         return
     # Add the tools directory to the search path.
     profile = """#!%s\n\nPATH="$PATH:%s"\nexport PATH""" % (
         profile_file_name, os.path.join(ROOT, 'tools'))
     profile_file.write(profile)
     profile_file.close()
     os.chmod(profile_file_name, 0755)
 def _update_devtools(self):
     DEVLIB_DIR = os.path.join(TARGET_ROOT,
                               "opt/envenergy/devtools/2.0/x86")
     makedirs(DEVLIB_DIR)
     # Ensure executables will work with the current devtools.
     # @fixme Place holder.
     SLINK = os.path.join(DEVLIB_DIR, 'lib')
     if os.path.ismount(SLINK):
         assert 0, ("Existing %s can not be a mount point." % SLINK)
     if os.path.islink(SLINK) or os.path.isfile(SLINK):
         self.options.normal_message("Removing old %s", SLINK)
         os.unlink(SLINK)
     elif os.path.isdir(SLINK):
         # assert 0, ("Existing %s can not be a directory." % SLINK)
         self.options.normal_message(
             "Skipping linking of existing %s directory.", SLINK)
         return
     assert not os.path.exists(SLINK), "Failed to remove %s." % SLINK
     self.options.normal_message("Creating %s link to %s.", SLINK,
                                 os.path.join(TARGET_ROOT, 'lib'))
     os.symlink(os.path.join(TARGET_ROOT, 'lib'), SLINK)
     return
 def install(self):
     self._update_devtools()
     makedirs(ETC_DIR)
     self._update_mpxadmin_user()
     makedirs(SBIN_DIR)
     makedirs(LIB_DIR)
     self._update_var()
     self._update_mpx_python_lib()
     self._update_bin()
     self._update_sbin()
     self._validate_var_run()
     self._update_rc_mfw()
     # In case this if the first time blinky_bill was installed, and now that
     # inittab has been updated, re-notify the led.
     self._notify_led()
     self._update_dhcpcd_exe()
     self._update_motd()
     self._create_profile()
     self._update_pppd_support()
     self._update_inittab()
     return 0
示例#25
0
 def install(self):
     self._update_devtools()
     makedirs(ETC_DIR)
     self._update_mpxadmin_user()
     makedirs(SBIN_DIR)
     makedirs(LIB_DIR)
     self._update_var()
     self._update_mpx_python_lib()
     self._update_bin()
     self._update_sbin()
     self._validate_var_run()
     self._update_rc_mfw()
     # In case this if the first time blinky_bill was installed, and now that
     # inittab has been updated, re-notify the led.
     self._notify_led()
     self._update_dhcpcd_exe()
     self._update_motd()
     self._create_profile()
     self._update_pppd_support()
     self._update_inittab()
     return 0
示例#26
0
 def _validate_var_run(self):
     makedirs(VAR_RUN, 0755)
     makedirs(VAR_RUN_BROADWAY, 0775)
     chown(VAR_RUN_BROADWAY, "root", "mpxadmin", recurse=1, ignore_errors=1)
     return