Skip to content

Instantly share code, notes, and snippets.

@elyezer
Created August 15, 2014 19:20
Show Gist options
  • Save elyezer/0656d2ddb75c712440f3 to your computer and use it in GitHub Desktop.
Save elyezer/0656d2ddb75c712440f3 to your computer and use it in GitHub Desktop.
Example of VM Provisioning API for Robottelo
# Test body
with VirtualMachine(ram=512, cpu=1, os='rhel7') as vm:
stdout, stderr = vm.command('echo "hellow world"')
vm.ip_addr
vm.hostname
# one vm for a test case
class ClientTestCase(UnitTest):
def setUp(self):
self.vm = VirtualMachine(...)
def tearDown(self):
self.vm.shutdown()
# properties
provisioning_host = machine.domain.com
@Ichimonji10
Copy link

This?

# properties
provisioning_host = 'machine.example.com'

@Ichimonji10
Copy link

Is something like this in mind?

# one vm for a test case
class ClientTestCase(UnitTest):
    def setUp(self):
        self.vm = VirtualMachine(...)
        self.conf_properties = conf.properties.copy()
        conf.properties['main.server.hostname'] = vm.hostname

    def tearDown(self):
        self.vm.shutdown()
        conf.properties = self.conf_properties

@omaciel
Copy link

omaciel commented Aug 19, 2014

Yes! The rule will be that you have to provide a tearDown in order to use this new functionality with your tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment