Skip to content

Instantly share code, notes, and snippets.

@nvgoldin
Created May 7, 2017 14:19
Show Gist options
  • Save nvgoldin/f89b2bac5c61a2f352dbd5e1734e25a4 to your computer and use it in GitHub Desktop.
Save nvgoldin/f89b2bac5c61a2f352dbd5e1734e25a4 to your computer and use it in GitHub Desktop.
import pytest
import textwrap
import tempfile
from lago import sdk
def generate_config():
conf = """
domains:
vm-el73:
nics:
- net: lago
disks:
- template_name: el7.3-base
type: template
name: root
dev: sda
format: qcow2
nets:
lago:
type: nat
dhcp:
start: 100
end: 254
management: true
dns_domain_name: lago.local
"""
with tempfile.NamedTemporaryFile(delete=False) as f:
f.write(textwrap.dedent(conf))
return f.name
@pytest.fixture(scope='module')
def env():
env = sdk.init(config=generate_config(), workdir='/tmp/pytest-lago')
env.start()
yield env
env.destroy()
@pytest.fixture(scope='module')
def vm(env):
vm = env.get_vms()['vm-el73']
return vm
def test_ls(vm):
res = vm.ssh(['ls', '-lsah'])
assert res.code == 0
def test_hostname(vm):
res = vm.ssh(['hostname -f'])
assert res.code == 0
assert str.strip(res.out) == 'vm-el73.lago.local'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment