def drakmon_vm(): logging.info("Running end to end test") debs = download_debs(MINIO_DEBS) [drakvuf_bundle] = download_debs([BUNDLE_DEB]) vm_runner.set_snapshot(VM_SNAPSHOT_BASE) vm_runner.rebuild_vm() while not server_alive(VM_HOST, 22): time.sleep(0.5) with Connection("testvm", config=FABRIC_CONFIG) as c: # Upload debs for d in map(str, [drakvuf_bundle, *debs]): logging.info("Uploading %s", d) c.put(d) c.run("apt-get update") apt_install(c, DRAKVUF_DEPS) # Install DRAKVUF dpkg_install(c, drakvuf_bundle.name) # Reboot into Xen c.run("systemctl reboot", disown=True) # Wait until VM reboots while server_alive(VM_HOST, 22): time.sleep(0.5) logging.info("VM went down") while not server_alive(VM_HOST, 22): time.sleep(0.5) logging.info("VM back up") with Connection("testvm", config=FABRIC_CONFIG) as c: apt_install(c, ["redis-server"]) apt_install(c, DRAKMON_DEPS) # add ISO image to make xen happy c.run( "genisoimage -o /root/SW_DVD5_Win_Pro_7w_SP1_64BIT_Polish_-2_MLF_X17-59386.ISO /dev/null" ) for d in debs: dpkg_install(c, d.name) # add xen bridge c.run("brctl addbr drak0") c.run("systemctl enable drakrun@1") c.run("systemctl start drakrun@1") return Connection("testvm", config=FABRIC_CONFIG)
contexts.NatsRelation, contexts.LoggregatorRelation, contexts.EtcdRelation]}, ] }, 'dea-v1': { 'summary': 'DEA runs CF apps in containers', 'description': '', 'jobs': [ { 'job_name': 'dea_next', 'mapping': {}, 'install': [ utils.install_linux_image_extra, utils.apt_install(['quota']), utils.modprobe(['quota_v1', 'quota_v2']) ], 'required_data': [ contexts.NatsRelation, contexts.LTCRelation, contexts.DEARelation.remote_view, ], 'data_ready': [ # Apply our workaround till we # have a real fix tasks.patch_dea ] }, { 'job_name': 'dea_logging_agent',
def drakmon_setup(): key = RSAKey.generate(bits=2048) with open("/root/.ssh/id_rsa", "w") as f: key.write_private_key(f) logging.info("Running end to end test") debs = download_debs(MINIO_DEBS) [drakvuf_bundle] = download_debs([BUNDLE_DEB]) response = rebuild_vm(VM_RUNNER_HOST, ssh_key="ssh-rsa " + key.get_base64(), api_key=RUNNER_KEY ) VM_HOST = response["ip"] ssh_config = paramiko.config.SSHConfig.from_text( f""" Host testvm User root HostName {VM_HOST} """ ) FABRIC_CONFIG = Config(ssh_config=ssh_config) while not server_alive(VM_HOST, 22): time.sleep(0.5) with Connection("testvm", config=FABRIC_CONFIG) as c: # Upload debs for d in map(str, [drakvuf_bundle, *debs]): logging.info("Uploading %s", d) c.put(d) c.run("apt-get --allow-releaseinfo-change update") apt_install(c, DRAKVUF_DEPS) # Install DRAKVUF dpkg_install(c, drakvuf_bundle.name) # Reboot into Xen c.run("systemctl reboot", disown=True) # Wait until VM reboots while server_alive(VM_HOST, 22): time.sleep(0.5) logging.info("VM went down") while not server_alive(VM_HOST, 22): time.sleep(0.5) logging.info("VM back up") with Connection("testvm", config=FABRIC_CONFIG) as c: apt_install(c, ["redis-server"]) apt_install(c, DRAKMON_DEPS) for d in debs: dpkg_install(c, d.name) # Save default config c.run("cp /etc/drakrun/config.ini /etc/drakrun/config.ini.bak") c.run(f""" cat > /etc/drakrun/config.ini <<EOF [minio] address={MINIO_HOST} secure=0 access_key={MINIO_ACCESS_KEY} secret_key={MINIO_SECRET_KEY} EOF""") # Import snapshot assert SNAPSHOT_VERSION is not None c.run(f"draksetup snapshot import --bucket snapshots --name {SNAPSHOT_VERSION} --full") # Restore original config c.run("cp /etc/drakrun/config.ini.bak /etc/drakrun/config.ini") # Shut up QEMU c.run("ln -s /dev/null /root/SW_DVD5_Win_Pro_7w_SP1_64BIT_Polish_-2_MLF_X17-59386.ISO") c.run("systemctl start drakrun@1") return Connection("testvm", config=FABRIC_CONFIG), VM_HOST