def rio_name_setup(stack, sname): fullName = (f"{stack}/{sname}") cmd = (f"rio run --name {fullName} nginx") util.runwait(cmd, fullName) return sname
def run_memlimit(stack, size, unit): name = "tsrv" + str(randint(1000, 5000)) fullName = (f"{stack}/{name}") cmd = (f'rio run -n {fullName} --memory-limit {size}{unit} nginx') util.runwait(cmd, fullName) return name
def riorun(stack, vname): sname = "tsrv" + str(randint(1000, 5000)) fullName = "%s/%s" % (stack, sname) cmd = (f'rio run -n {fullName} -v {vname} nginx') util.runwait(cmd, fullName) return sname
def run_network_setup(stack, value): name = "tsrv" + str(randint(1000, 5000)) fullName = (f"{stack}/{name}") cmd = (f'rio run -n {fullName} --network {value} nginx') util.runwait(cmd, fullName) return name
def rio_bind_workload(stack, vname): name = "tsrv" + str(randint(1000, 5000)) fullName = (f"{stack}/{name}") cmd = (f'rio run -n {fullName} -v {vname}:/data nginx') util.runwait(cmd, fullName) util.run(f"rio exec {fullName} touch /data/helloworld") output = util.run(f"rio exec {fullName} ls /data") return output
def riorun(stack): name = "tsrv" + str(randint(1000, 5000)) fullName = "%s/%s" % (stack, name) cmd = (f'rio run -p 80/http -n {fullName} nginx:latest') util.runwait(cmd, fullName) # util.run(f"rio wait {fullName}") return name
def stage_service(stack, name, version, second_config): fullName = "%s/%s" % (stack, name) path = "/usr/share/nginx/html/index.html" command = "rio stage --image=nginx --config %s:%s %s:%s" % ( second_config, path, fullName, version) print(command) util.runwait(command, fullName) stackJson = util.runToJson("rio export -o json %s" % stack) got = stackJson['services'][name]['revisions']['v2']['scale'] return got
def run_healthcmd_setup(stack, cmd, interval='', retries='', start='', timeout=''): name = "tsrv" + str(randint(1000, 5000)) fullName = (f"{stack}/{name}") options = (f'{interval}{retries}{start}{timeout}') rcmd = (f'rio run -n {fullName} --health-cmd {cmd} {options}nginx') util.runwait(rcmd, fullName) return name
def create_service(stack, config): name = "tsrv" + str(randint(1000, 5000)) fullName = "%s/%s" % (stack, name) path = "/usr/share/nginx/html/index.html" print(fullName) print(config) run_command = "rio run -n %s -p 80/http --config %s:%s nginx" % ( fullName, config, path) print(run_command) util.runwait(run_command, fullName) return name
def run_image_pull(stack, img): name = "tsrv" + str(randint(1000, 5000)) fullName = "%s/%s" % (stack, name) command = (f'rio run -n {fullName}') command += " --image-pull-policy " + img command += " nginx" util.runwait(command, fullName) print(command) return name
def run_metadata(stack, *mdata): name = "tsrv" + str(randint(1000, 5000)) fullName = "%s/%s" % (stack, name) command = (f'rio run -n {fullName}') for d in mdata: command += " --metadata " + d command += " nginx" util.runwait(command, fullName) return name
def rio_bind_workload(stack, vname, wrklname): fullVolName = (f"{stack}/{vname}") fullWklName = (f"{stack}/{wrklname}") util.wait_for_state(fullVolName, "active") util.run(f"rio exec {fullVolName} touch /persistentvolumes/helloworld") cmd = (f"rio run -n {fullWklName} -v data-{vname}-0:/data nginx") util.runwait(cmd, fullWklName) output = util.run(f"rio exec {fullWklName} ls /data") print(f'OUTPUT = {output}') return output
def rio_permission_setup(stack, *rpermission): name = "tsrv" + str(randint(1000, 5000)) fullName = "%s/%s" % (stack, name) cmd = (f'rio run -n {fullName}') for p in rpermission: cmd += " --permission " + p cmd += " nginx" util.runwait(cmd, fullName) return name
def run_environment_var(stack, *envs): name = "tsrv" + str(randint(1000, 5000)) fullName = "%s/%s" % (stack, name) command = (f'rio run -n {fullName}') for c in envs: command += " -e " + c command += " nginx" print(command) util.runwait(command, fullName) return name
def run_dns(stack, *dns_options): name = "tsrv" + str(randint(1000, 5000)) fullName = (f"{stack}/{name}") cmd = (f'rio run -n {fullName}') for c in dns_options: cmd += " --dns-option " + c cmd += " nginx" print(cmd) util.runwait(cmd, fullName) print(name) return name
def run_entrypoint(stack, *entrypoint): name = "tsrv" + str(randint(1000, 5000)) fullName = (f"{stack}/{name}") cmd = (f'rio run -n {fullName}') for c in entrypoint: cmd += " -t -i --entrypoint " + c cmd += " nginx" print(cmd) util.runwait(cmd, fullName) print(name) return name
def run_expose(stack, *prt): name = "tsrv" + str(randint(1000, 5000)) fullName = "%s/%s" % (stack, name) command = (f'rio run -n {fullName}') for c in prt: command += " --expose " + c command += " nginx" util.runwait(command, fullName) print(command) return name
def lbl_file_setup(stack, *lbl): fp = tempfile.NamedTemporaryFile(delete=False) for c in lbl: fp.write(bytes(c + "\n", 'utf8')) fp.close() name = "tsrv" + str(randint(1000, 5000)) fullName = (f"{stack}/{name}") cmd = (f'rio run -n {fullName}') cmd += " --label-file " + fp.name + " nginx" util.runwait(cmd, fullName) unlink(fp.name) return name
def set_scale(stack, service, scale): fullName = "%s/%s" % (stack, service) cmd = (f"rio scale {fullName}={scale}") util.runwait(cmd, fullName)