Пример #1
0
 def generateHorizonOperations(self, hznattrLists, containers: [int], logger: Logger) -> []:
     from scale.operation import Operation
     operations = []
     for container in containers:
         callList = [hzncmd] + hznattrLists.pop(0)
         operation = Operation(operation=callList, logger=logger)
         operation.updateEnvironment(environment=os.environ.copy(), containerNumber=container)
         operations.append(operation)
     return operations
Пример #2
0
 def generateSendCommand(self, sourceDirectory: str,
                         destinationHostname: str,
                         destinationDirectory: str,
                         logger: Logger) -> Operation:
     command = [
         "scp", "-r", sourceDirectory,
         "root@" + destinationHostname + ":" + destinationDirectory
     ]
     return Operation(operation=command, logger=logger)
Пример #3
0
 def generateReceiveCommand(self, sourceHostname: str, sourceDirectory: str,
                            destinationDirectory: str,
                            logger: Logger) -> Operation:
     hostnameDestination = os.path.join(destinationDirectory,
                                        sourceHostname)
     os.makedirs(hostnameDestination, exist_ok=True)
     command = [
         "scp", "-r", "root@" + sourceHostname + ":" + sourceDirectory,
         hostnameDestination
     ]
     return Operation(operation=command, logger=logger)
Пример #4
0
def generateReceiveSyslogCmds(hostnames: [str], logdir: str, logger: Logger):
    p = os.path.join(logdir, syslogs_capturedir)
    os.makedirs(p, exist_ok=True)

    operations = []
    for hostname in hostnames:
        hsyslog = os.path.join(p, hostname + "_syslog.log")
        command = ["scp", "-r", "root@" + hostname + ":" + syslog, hsyslog]
        operation = Operation(operation=command, logger=logger)
        operations.append(operation)
    return operations
Пример #5
0
def dockerexecworker(ctx, commandargument):
    count = ctx.obj[cflag]
    containers = dhelper.getRunningContainerList(count)

    operations = []
    for container in containers:
        command = [dockerOp, execOp, "-i", hznprefix + str(container)
                   ] + list(commandargument)
        operation = Operation(operation=command, logger=logger)
        operations.append(operation)

    logger.info("Performing Docker Exec", timestamp=False)
    manager.run(runmode=mode_parallel, operations=operations)
Пример #6
0
def dockercpworker(ctx, source, destination):
    count = ctx.obj[cflag]
    containers = dhelper.getRunningContainerList(count)

    operations = []
    for container in containers:
        command = [
            dockerOp, cpOp, source,
            hznprefix + str(container) + ":" + destination
        ]
        operation = Operation(operation=command, logger=logger)
        operations.append(operation)

    logger.info("Performing Docker CP", timestamp=False)
    manager.run(runmode=mode_parallel, operations=operations)
Пример #7
0
    def generateSshCommand(self, env: {}, host: str, operation: str,
                           workerPseudoDelay: float,
                           logger: Logger) -> Operation:
        assemble = ""
        for key in env:
            assemble = assemble + "export " + key + "=" + env[key] + "; "

        if (workerPseudoDelay > 0):
            assemble = assemble + "export " + env_scaler_workerpseudodelay + "=" + str(
                workerPseudoDelay) + "; "

        assemble = assemble + operation

        login = self.generateSshLogin(host)
        sshop = login + [assemble]
        return Operation(operation=sshop, logger=logger)
Пример #8
0
 def generateHorizonCommand(self, environment: {}, containerIndex: int, operation: [str], logger: Logger) -> Operation:
     operation = Operation(operation=operation, logger=logger)
     operation.updateEnvironment(environment=environment, containerNumber=containerIndex)
     return operation