Example #1
0
    def install(self, cleanup=True):
        self._verify()
        if self.is_installed():
            return
        src = self.location()
        collision = get_bundle(self.name())

        if collision is None:
            dst = make_bundle_install_path(self._rawname)
            if cleanup:
                comm.moveItem(src, dst)
            else:
                comm.mkdirItem(dst)
                comm.mergeDirs(src, dst)
        else:
            default_path = os.path.join(collision.location(), self._DEFAULT)
            if os.path.exists(default_path):
                default_path_bkup = "%s.old.%s" % (
                    default_path,
                    time.strftime("%Y%m%d-%H%M%S", time.localtime()))
                comm.moveItem(default_path, default_path_bkup)
                comm.mkdirItem(default_path)
            self._rearrange_conf_files(self._DEFAULT)
            comm.mergeDirs(src, collision.location())

            if cleanup:
                self.delete()
def mergeApp(appName):
    appPath = _getAppPath(appName, True)
    if not appPath:
        return None
    tmpPath = os.path.join(PACKAGE_PATH, 'DELETEME_' + appName)
    
    # this should copy app dir to tmp dir
    bundle_paths.maybe_makedirs(tmpPath)
    comm.mergeDirs(appPath, tmpPath)

    localPath = os.path.join(tmpPath, 'local')
    defaultPath = os.path.join(tmpPath, 'default')
    
    # check if the app is allowed to be merged

    if os.path.exists(localPath) and os.path.exists(defaultPath):
        # merge local and default dirs in tmp, result in local
        b = bundle_paths.Bundle('dummy', 'bundle')
        comm.mergeDirs(defaultPath, localPath, False, b._merger)

        # remove default
        bundle_paths.safe_remove(defaultPath)

        # move local to default
        comm.moveItem(localPath, defaultPath)
    
    return tmpPath
Example #3
0
 def migrate(self, dryRun=False):
     self._verify()
     if not self.is_legacy():
         return
     name = self.name()
     src = self.location()
     cleanup = True
     if (name == self._DEFAULT) or (name == "README"):
         logger.notice(lit("INFO_MIGRATE_OMIT__S") % name)
     elif name == self._LOCAL:
         if not dryRun:
             self._rearrange_conf_files(self._LOCAL)
         comm.mergeDirs(src, get_system_bundle_path(), dryRun, self._merger)
     else:
         if not dryRun:
             self._rearrange_conf_files(self._DEFAULT)
         collision = get_bundle(name)
         if collision is None:
             comm.moveItem(src, make_bundle_install_path(name), dryRun)
             cleanup = False
         else:
             logger.notice(
                 lit("INFO_MIGRATE_COLLISION__S_S") %
                 (collision.name(), collision.location()))
             logger.notice(lit("INFO_MIGRATE_OMIT__S") % name)
     if cleanup and not dryRun:
         logger.info(lit("INFO_MIGRATE_CLEANUP__S") % src)
         self.delete()
Example #4
0
def mergeApp(appName):
    appPath = _getAppPath(appName, True)
    if not appPath:
        return None
    tmpPath = os.path.join(PACKAGE_PATH, 'DELETEME_' + appName)

    # this should copy app dir to tmp dir
    bundle_paths.maybe_makedirs(tmpPath)
    comm.mergeDirs(appPath, tmpPath)

    localPath = os.path.join(tmpPath, 'local')
    defaultPath = os.path.join(tmpPath, 'default')

    # check if the app is allowed to be merged

    if os.path.exists(localPath) and os.path.exists(defaultPath):
        # merge local and default dirs in tmp, result in local
        b = bundle_paths.Bundle('dummy', 'bundle')
        comm.mergeDirs(defaultPath, localPath, False, b._merger)

        # remove default
        bundle_paths.safe_remove(defaultPath)

        # move local to default
        comm.moveItem(localPath, defaultPath)

    return tmpPath
Example #5
0
    def install(self, cleanup=True):
        self._verify()
        if self.is_installed():
            return
        src = self.location()
        collision = get_bundle(self.name())            
        
        if collision is None:
            dst = make_bundle_install_path(self._rawname)
            if cleanup:
                comm.moveItem(src, dst)
            else:
                comm.mkdirItem(dst)
                comm.mergeDirs(src, dst)
        else:
            default_path = os.path.join(collision.location(), self._DEFAULT)
            default_path_bkup = "%s.old.%s" % (default_path, time.strftime("%Y%m%d-%H%M%S", time.localtime()))
            comm.moveItem(default_path, default_path_bkup)
            comm.mkdirItem(default_path)
            
            self._rearrange_conf_files(self._DEFAULT)
        
            comm.mergeDirs(src, collision.location())

            if cleanup:
                self.delete()
Example #6
0
 def migrate(self, dryRun=False):
     self._verify()
     if not self.is_legacy():
         return
     name = self.name()
     src = self.location()
     cleanup = True
     if (name == self._DEFAULT) or (name == "README"):
         logger.notice(lit("INFO_MIGRATE_OMIT__S") % name)
     elif name == self._LOCAL:
         if not dryRun:
             self._rearrange_conf_files(self._LOCAL)
         comm.mergeDirs(src, get_system_bundle_path(), dryRun, self._merger)
     else:
         if not dryRun:
             self._rearrange_conf_files(self._DEFAULT)
         collision = get_bundle(name)
         if collision is None:
             comm.moveItem(src, make_bundle_install_path(name), dryRun)
             cleanup = False
         else:
             logger.notice(lit("INFO_MIGRATE_COLLISION__S_S") %
                           (collision.name(), collision.location()))
             logger.notice(lit("INFO_MIGRATE_OMIT__S") % name)
     if cleanup and not dryRun:
         logger.info(lit("INFO_MIGRATE_CLEANUP__S") % src)
         self.delete()
def addUploadAssets(appName):
    appPath = _getAppPath(appName, True)
    if not appPath:
        raise admin.ArgValidationException(_("App '%s' does not exist") % appName)

    tempPath = make_splunkhome_path(['var', 'run', 'splunk', 'apptemp'])
    # if does not exist then it means no assets exist for moving
    if not os.path.exists(tempPath):
        return

    dstPath = os.path.join(appPath, 'appserver', 'static')
    bundle_paths.maybe_makedirs(dstPath)
    comm.mergeDirs(tempPath, dstPath)

    # clean up
    bundle_paths.safe_remove(tempPath)
Example #8
0
def addUploadAssets(appName):
    appPath = _getAppPath(appName, True)
    if not appPath:
        raise admin.ArgValidationException(
            _("App '%s' does not exist") % appName)

    tempPath = make_splunkhome_path(['var', 'run', 'splunk', 'apptemp'])
    # if does not exist then it means no assets exist for moving
    if not os.path.exists(tempPath):
        return

    dstPath = os.path.join(appPath, 'appserver', 'static')
    bundle_paths.maybe_makedirs(dstPath)
    comm.mergeDirs(tempPath, dstPath)

    # clean up
    bundle_paths.safe_remove(tempPath)