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
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)
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)
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
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)
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)
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)
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