Cobbler test start
This commit is contained in:
parent
d3d659d38b
commit
430909f672
@ -19,7 +19,8 @@ class BaseTestCase(unittest.TestCase):
|
|||||||
self.environment = self.ci().get_environment_or_create()
|
self.environment = self.ci().get_environment_or_create()
|
||||||
master = self.environment.node['master']
|
master = self.environment.node['master']
|
||||||
self.revert_snapshots()
|
self.revert_snapshots()
|
||||||
self.master_remote = ssh(master.ip_address, username='root',
|
self.master_remote = ssh(master.ip_address_by_network['public'],
|
||||||
|
username='root',
|
||||||
password='r00tme')
|
password='r00tme')
|
||||||
self.upload_recipes()
|
self.upload_recipes()
|
||||||
self.restart_puppet_muster()
|
self.restart_puppet_muster()
|
||||||
|
@ -12,7 +12,7 @@ from fuel_test.root import root
|
|||||||
from fuel_test.helpers import load
|
from fuel_test.helpers import load
|
||||||
|
|
||||||
|
|
||||||
class CiBase:
|
class CiBase(object):
|
||||||
@abstractproperty
|
@abstractproperty
|
||||||
def env_name(self):
|
def env_name(self):
|
||||||
"""
|
"""
|
||||||
@ -74,7 +74,7 @@ class CiBase:
|
|||||||
for node in nodes:
|
for node in nodes:
|
||||||
add_to_hosts(remote, node.ip_address, node.name, node.name)
|
add_to_hosts(remote, node.ip_address, node.name, node.name)
|
||||||
|
|
||||||
def setup_mater_node(self, master_remote, nodes):
|
def setup_master_node(self, master_remote, nodes):
|
||||||
setup_puppet_master_yum(master_remote)
|
setup_puppet_master_yum(master_remote)
|
||||||
add_nmap_yum(master_remote)
|
add_nmap_yum(master_remote)
|
||||||
switch_off_ip_tables(master_remote)
|
switch_off_ip_tables(master_remote)
|
||||||
@ -97,34 +97,39 @@ class CiBase:
|
|||||||
write_config(remote, '/etc/puppet/puppet.conf', agent_config)
|
write_config(remote, '/etc/puppet/puppet.conf', agent_config)
|
||||||
request_cerificate(remote)
|
request_cerificate(remote)
|
||||||
|
|
||||||
def setup_environment(self):
|
def make_vms(self):
|
||||||
if not self.base_image:
|
if not self.base_image:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Base image path is missing while trying to build %s environment" % self.environment_name)
|
"Base image path is missing while trying to build %s environment" % self.environment_name)
|
||||||
|
|
||||||
logging.info("Building %s environment" % self.environment_name)
|
logging.info("Building %s environment" % self.environment_name)
|
||||||
environment = self.describe_environment()
|
environment = self.describe_environment()
|
||||||
self.environment = environment
|
|
||||||
|
|
||||||
# todo environment should be saved before build
|
# todo environment should be saved before build
|
||||||
devops.build(environment)
|
devops.build(environment)
|
||||||
|
|
||||||
devops.save(environment)
|
devops.save(environment)
|
||||||
logging.info("Environment has been saved")
|
logging.info("Environment has been saved")
|
||||||
|
return environment
|
||||||
|
|
||||||
|
def rename_nodes(self, nodes):
|
||||||
|
for node in nodes:
|
||||||
|
remote = ssh(node.ip_address, username='root', password='r00tme')
|
||||||
|
change_host_name(remote, node.name, node.name)
|
||||||
|
logging.info("Renamed %s" % node.name)
|
||||||
|
|
||||||
|
def setup_environment(self):
|
||||||
|
environment = self.make_vms()
|
||||||
|
self.environment = environment
|
||||||
|
|
||||||
logging.info("Starting test nodes ...")
|
logging.info("Starting test nodes ...")
|
||||||
for node in environment.nodes:
|
for node in environment.nodes:
|
||||||
node.start()
|
node.start()
|
||||||
for node in environment.nodes:
|
for node in environment.nodes:
|
||||||
logging.info("Waiting ssh... %s" % node.ip_address)
|
logging.info("Waiting ssh... %s" % node.ip_address)
|
||||||
wait(lambda: tcp_ping(node.ip_address, 22), timeout=1800)
|
wait(lambda: tcp_ping(node.ip_address, 22), timeout=1800)
|
||||||
for node in environment.nodes:
|
self.rename_nodes(environment.nodes)
|
||||||
remote = ssh(node.ip_address, username='root', password='r00tme')
|
|
||||||
change_host_name(remote, node.name, node.name)
|
|
||||||
logging.info("Renamed %s" % node.name)
|
|
||||||
master_node = environment.node['master']
|
master_node = environment.node['master']
|
||||||
master_remote = ssh(master_node.ip_address, username='root',
|
master_remote = ssh(master_node.ip_address, username='root',
|
||||||
password='r00tme')
|
password='r00tme')
|
||||||
self.setup_mater_node(master_remote, environment.nodes)
|
self.setup_master_node(master_remote, environment.nodes)
|
||||||
self.setup_agent_nodes(environment.nodes)
|
self.setup_agent_nodes(environment.nodes)
|
||||||
sleep(5)
|
sleep(5)
|
||||||
sign_all_node_certificates(master_remote)
|
sign_all_node_certificates(master_remote)
|
||||||
|
67
fuel_test/ci/ci_cobbler.py
Normal file
67
fuel_test/ci/ci_cobbler.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import logging
|
||||||
|
from time import sleep
|
||||||
|
from devops.helpers import wait, tcp_ping, ssh
|
||||||
|
from devops.model import Environment, Network
|
||||||
|
import os
|
||||||
|
from fuel_test.ci.ci_base import CiBase
|
||||||
|
from fuel_test.helpers import sign_all_node_certificates
|
||||||
|
from fuel_test.node_roles import NodeRoles
|
||||||
|
|
||||||
|
class CiCobbler(CiBase):
|
||||||
|
def node_roles(self):
|
||||||
|
return NodeRoles(
|
||||||
|
cobbler_names=['fuel-cobbler'],
|
||||||
|
controller_names=['fuel-01', 'fuel-02'],
|
||||||
|
compute_names=['fuel-03', 'fuel-04']
|
||||||
|
)
|
||||||
|
|
||||||
|
def env_name(self):
|
||||||
|
return os.environ.get('ENV_NAME', 'cobbler')
|
||||||
|
|
||||||
|
def describe_environment(self):
|
||||||
|
environment = Environment(self.environment_name)
|
||||||
|
internal = Network(name='internal', dhcp_server=False)
|
||||||
|
environment.networks.append(internal)
|
||||||
|
private = Network(name='private', dhcp_server=False)
|
||||||
|
environment.networks.append(private)
|
||||||
|
public = Network(name='public', dhcp_server=True)
|
||||||
|
environment.networks.append(public)
|
||||||
|
master = self.describe_node('master', [internal, private, public])
|
||||||
|
environment.nodes.append(master)
|
||||||
|
for node_name in self.node_roles().cobbler_names:
|
||||||
|
client = self.describe_node(node_name, [internal, private, public])
|
||||||
|
environment.nodes.append(client)
|
||||||
|
for node_name in self.node_roles().controller_names:
|
||||||
|
client = self.describe_node(node_name, [internal, private, public])
|
||||||
|
environment.nodes.append(client)
|
||||||
|
for node_name in self.node_roles().compute_names:
|
||||||
|
client = self.describe_node(
|
||||||
|
node_name, [internal, private, public], memory=4096)
|
||||||
|
environment.nodes.append(client)
|
||||||
|
return environment
|
||||||
|
|
||||||
|
def setup_environment(self):
|
||||||
|
environment = self.make_vms()
|
||||||
|
self.environment = environment
|
||||||
|
|
||||||
|
logging.info("Starting test nodes ...")
|
||||||
|
master_node = environment.node['master']
|
||||||
|
start_nodes = self.nodes().cobblers + [master_node]
|
||||||
|
for node in start_nodes:
|
||||||
|
node.start()
|
||||||
|
for node in start_nodes:
|
||||||
|
logging.info("Waiting ssh... %s" % node.ip_address)
|
||||||
|
wait(lambda: tcp_ping(node.ip_address, 22), timeout=1800)
|
||||||
|
self.rename_nodes(start_nodes)
|
||||||
|
|
||||||
|
master_remote = ssh(master_node.ip_address, username='root',
|
||||||
|
password='r00tme')
|
||||||
|
self.setup_master_node(master_remote, environment.nodes)
|
||||||
|
self.setup_agent_nodes(self.nodes().cobblers)
|
||||||
|
sleep(5)
|
||||||
|
sign_all_node_certificates(master_remote)
|
||||||
|
sleep(5)
|
||||||
|
for node in environment.nodes:
|
||||||
|
logging.info("Creating snapshot 'empty'")
|
||||||
|
node.save_snapshot('empty')
|
||||||
|
logging.info("Test node is ready at %s" % node.ip_address)
|
1
fuel_test/cobbler/__init__.py
Normal file
1
fuel_test/cobbler/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
__author__ = 'vic'
|
38
fuel_test/cobbler/cobbler_test_case.py
Normal file
38
fuel_test/cobbler/cobbler_test_case.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import unittest
|
||||||
|
from fuel_test.base_test_case import BaseTestCase
|
||||||
|
from fuel_test.ci.ci_cobbler import CiCobbler
|
||||||
|
from fuel_test.root import root
|
||||||
|
|
||||||
|
class CobblerTestCase(BaseTestCase):
|
||||||
|
def ci(self):
|
||||||
|
if not hasattr(self, '_ci'):
|
||||||
|
self._ci = CiCobbler()
|
||||||
|
return self._ci
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(CobblerTestCase, self).setUp()
|
||||||
|
|
||||||
|
def write_cobbler_manifest(self):
|
||||||
|
cobbler = self.nodes.cobblers[0]
|
||||||
|
self.write_site_pp_manifest(
|
||||||
|
root('fuel', 'deployment', 'puppet', 'cobbler', 'examples',
|
||||||
|
'server_site.pp'),
|
||||||
|
server="'%s'" % cobbler.ip_address,
|
||||||
|
name_server="'%s'" % cobbler.ip_address,
|
||||||
|
next_server="'%s'" % cobbler.ip_address,
|
||||||
|
dhcp_start_address="'%s'" % self.environment.network[
|
||||||
|
'internal'].ip_addresses[-5],
|
||||||
|
dhcp_end_address="'%s'" %
|
||||||
|
self.environment.network['internal'].ip_addresses[
|
||||||
|
-5],
|
||||||
|
dhcp_netmask="'%s'" % '255.255.255.0',
|
||||||
|
dhcp_gateway="'%s'" % cobbler.ip_address
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -4,11 +4,13 @@ class NodeRoles(object):
|
|||||||
compute_names=None,
|
compute_names=None,
|
||||||
storage_names=None,
|
storage_names=None,
|
||||||
proxy_names=None,
|
proxy_names=None,
|
||||||
|
cobbler_names=None,
|
||||||
keystone_names=None):
|
keystone_names=None):
|
||||||
self.controller_names = controller_names or []
|
self.controller_names = controller_names or []
|
||||||
self.compute_names = compute_names or []
|
self.compute_names = compute_names or []
|
||||||
self.storage_names = storage_names or []
|
self.storage_names = storage_names or []
|
||||||
self.proxy_names = proxy_names or []
|
self.proxy_names = proxy_names or []
|
||||||
|
self.cobbler_names = cobbler_names or []
|
||||||
self.keystone_names = keystone_names or []
|
self.keystone_names = keystone_names or []
|
||||||
|
|
||||||
|
|
||||||
@ -19,6 +21,7 @@ class Nodes(object):
|
|||||||
self.storages = []
|
self.storages = []
|
||||||
self.proxies = []
|
self.proxies = []
|
||||||
self.keystones = []
|
self.keystones = []
|
||||||
|
self.cobblers = []
|
||||||
for node_name in node_roles.controller_names:
|
for node_name in node_roles.controller_names:
|
||||||
print('asdf %s' % node_name)
|
print('asdf %s' % node_name)
|
||||||
self.controllers.append(devops_environment.node[node_name])
|
self.controllers.append(devops_environment.node[node_name])
|
||||||
@ -28,6 +31,8 @@ class Nodes(object):
|
|||||||
self.storages.append(devops_environment.node[node_name])
|
self.storages.append(devops_environment.node[node_name])
|
||||||
for node_name in node_roles.proxy_names:
|
for node_name in node_roles.proxy_names:
|
||||||
self.proxies.append(devops_environment.node[node_name])
|
self.proxies.append(devops_environment.node[node_name])
|
||||||
|
for node_name in node_roles.cobbler_names:
|
||||||
|
self.cobblers.append(devops_environment.node[node_name])
|
||||||
for node_name in node_roles.keystone_names:
|
for node_name in node_roles.keystone_names:
|
||||||
self.keystones.append(devops_environment.node[node_name])
|
self.keystones.append(devops_environment.node[node_name])
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import unittest
|
|||||||
|
|
||||||
class CobblerTestCase(OpenStackTestCase):
|
class CobblerTestCase(OpenStackTestCase):
|
||||||
def test_deploy_cobbler(self):
|
def test_deploy_cobbler(self):
|
||||||
node01 = self.environment.node[self.ci().controllers[0]]
|
node01 = self.nodes.controllers[0]
|
||||||
self.write_site_pp_manifest(
|
self.write_site_pp_manifest(
|
||||||
root('fuel', 'deployment', 'puppet', 'cobbler', 'examples',
|
root('fuel', 'deployment', 'puppet', 'cobbler', 'examples',
|
||||||
'server_site.pp'),
|
'server_site.pp'),
|
||||||
|
Loading…
Reference in New Issue
Block a user