Skip to content

Commit

Permalink
Merge b08b516 into aa7f1ad
Browse files Browse the repository at this point in the history
  • Loading branch information
thrix committed Oct 23, 2019
2 parents aa7f1ad + b08b516 commit f44c942
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 1 deletion.
1 change: 1 addition & 0 deletions tmt/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Step(object):
""" Common parent of all test steps """
# Test steps need to be explicitly enabled
enabled = False
how = False

# Required name of the step
name = 'unknown-step'
Expand Down
45 changes: 44 additions & 1 deletion tmt/steps/provision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,51 @@
""" Provision Step Classes """

import tmt
import random
import string
import os

from click import echo

from .localhost import ProvisionLocalhost


class Provision(tmt.steps.Step):
""" Provision an environment for testing (or use localhost) """
"""
Provision step
Note: provision.how contains forced how step from command-line
"""
name = 'provision'

def __init__(self, data, plan):
super(Provision, self).__init__(data, plan)

# If this is not an initialization for 'run' command, just ignore
if not self.plan.run:
return

# List of provisioned guests
self.guests = []

# if there are no data but user forces it, use local provisioner
if not data:
if self.how:
self.data = [{'how': 'local'}]
return

# choose correct plugin
for item in self.data:
how = self.how
if how == 'local':
self.guests.append(GuestLocalost(item, self))
else:
raise SpecificationError("Unknown how '{}'".format(how))

def go(self):
""" provision all resources """
super(Provision, self).go()

for guest in self.guests:
guest.provision()
guest.save()
33 changes: 33 additions & 0 deletions tmt/steps/provision/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class ProvisionBase(object):
def __init__(self, data, step, instance_name=None):
self.instance_name = instance_name or ''.join(random.choices(string.ascii_letters, k=16))
self.provision_dir = os.path.join(step.workdir, self.instance_name)

def execute(self, command):
""" executes one command in a gyes """
pass

def sync_workdir_to_guest(self):
""" sync step workdir from host to guests """
pass

def sync_workdir_from_guest(self):
""" sync step workdir from guest to host """
pass

def provision(self):
""" do the actual provisioning """
pass

def load(self):
""" load state from workdir """
pass

def save(self):
""" save state to workdir """
pass

def destroy(self):
""" destroy the machine """
pass

11 changes: 11 additions & 0 deletions tmt/steps/provision/localhost.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from click import echo

from tmt.steps.provision.base import ProvisionBase


class ProvisionLocalhost(ProvisionBase):
def provision(self):
echo ('provisioning localhost')

def save(self):
echo ('saving localhost')

0 comments on commit f44c942

Please sign in to comment.