Files
fuel-qa/fuelweb_test/models/pp_environment.py
Ivan Kliuk 0168055fe6 System tests movement from fuel-main
Apply refactoring patch https://review.openstack.org/#/c/149612/.
  Move contents of fuel-main/fuelweb_test to the repo.
  Add run_tests.sh.
  Change fuel-devops version to 2.9.0 in requirements file.

Change-Id: Id321d63d97290f2fb22736abbe1d74315aed2893
2015-02-06 11:44:08 +02:00

56 lines
1.9 KiB
Python

# Copyright 2014 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
from devops.helpers.helpers import tcp_ping
from devops.helpers.helpers import wait
from fuelweb_test.models.environment import EnvironmentModel
from fuelweb_test import settings
class PuppetEnvironment(EnvironmentModel):
"""Create environment for puppet modules testing."""
def __init__(self, os_image=None):
"""Constructor for create environment."""
self.os_image = os_image or settings.OS_IMAGE
super(PuppetEnvironment, self).__init__(self.os_image)
self.environment = \
super(PuppetEnvironment, self).get_virtual_environment()
self.start_env()
@property
def env_name(self):
return os.environ.get('PPENV_NAME', 'pp-integration')
def start_env(self):
self.get_virtual_environment().start(self.nodes())
def execute_cmd(self, command, debug=True):
"""Execute command on node."""
return self.get_admin_remote().execute(command,
verbose=debug)['exit_code']
def await(self, timeout=1200):
wait(
lambda: tcp_ping(self.get_admin_node_ip(), 22), timeout=timeout)
if __name__ == "__main__":
env = PuppetEnvironment(
'/var/lib/libvirt/images/ubuntu-12.04.1-server-amd64-p2.qcow2')
env.await()
env.make_snapshot(snapshot_name="test1")
env.execute_cmd('apt-get install mc')