Define netmask for cobbler

This commit is contained in:
vic 2013-02-10 03:52:13 +04:00
parent b0cf09ded1
commit 42b204c488
3 changed files with 29 additions and 20 deletions

View File

@ -162,5 +162,8 @@ class CiBase(object):
def internal_network(self):
return str(IPNetwork(self.environment().network_by_name('internal').ip_network))
def internal_net_mask(self):
return str(IPNetwork(self.environment().network_by_name('internal').ip_network).netmask)
def public_network(self):
return str(IPNetwork(self.environment().network_by_name('public').ip_network))

View File

@ -144,6 +144,7 @@ class CobblerTestCase(BaseTestCase):
node_mac1="00:17:3e:{0:02x}:{1:02x}:02".format(i, j),
node_mac2="00:17:3e:{0:02x}:{1:02x}:03".format(i, j),
node_ip="192.168.{0:d}.{1:d}".format(i, j),
net_mask="255.255.0.0",
stomp_name=stomp_name,
gateway=self.ci().internal_router()
)
@ -155,7 +156,7 @@ class CobblerTestCase(BaseTestCase):
return "0"
def _add_node(self, client, token, cobbler, node_name, node_mac0, node_mac1,
node_mac2, node_ip, stomp_name, gateway):
node_mac2, node_ip, stomp_name, gateway, net_mask):
system_id = client.new_system(token)
if OS_FAMILY == 'centos':
profile = 'centos63_x86_64'
@ -177,6 +178,7 @@ class CobblerTestCase(BaseTestCase):
"static-eth0": self._static(node_name),
"macaddress-eth1": str(node_mac1),
"ipaddress-eth1": str(node_ip),
"netmask-eth1": str(net_mask),
"dnsname-eth1": node_name + ".your-domain-name.com",
"static-eth1": self._static(node_name),
"macaddress-eth2": str(node_mac2),
@ -185,7 +187,7 @@ class CobblerTestCase(BaseTestCase):
client.save_system(system_id, token)
client.sync(token)
def add_node(self, client, token, cobbler, node, gateway):
def add_node(self, client, token, cobbler, node, gateway, net_mask):
node_name = node.name
node_mac0 = str(node.interfaces[0].mac_address)
node_mac1 = str(node.interfaces[1].mac_address)
@ -195,7 +197,7 @@ class CobblerTestCase(BaseTestCase):
client, token, cobbler, node_name,
node_mac0, node_mac1, node_mac2, node_ip,
stomp_name=self.ci().nodes().stomps[0].name,
gateway=gateway
gateway=gateway, net_mask=net_mask,
)
def configure_cobbler(self):
@ -204,7 +206,11 @@ class CobblerTestCase(BaseTestCase):
cobbler.get_ip_address_by_network_name('internal'))
token = client.login('cobbler', 'cobbler')
for node in self.ci().client_nodes():
self.add_node(client, token, cobbler, node, gateway=self.ci().internal_router())
self.add_node(
client, token, cobbler, node,
gateway=self.ci().internal_router(),
net_mask=self.ci().internal_net_mask()
)
master = self.environment().node_by_name('master')
remote = master.remote('internal',
login='root',

View File

@ -1,6 +1,5 @@
import subprocess
from time import sleep
import unittest
from devops.helpers.helpers import ssh
import glanceclient
import keystoneclient.v2_0
@ -19,8 +18,8 @@ class Prepare():
def remote(self):
return ssh(self.public_ip,
login='root',
password='r00tme').sudo.ssh
login='root',
password='r00tme').sudo.ssh
def ci(self):
if not hasattr(self, '_ci'):
@ -68,7 +67,7 @@ class Prepare():
image_ref=image_ref,
image_ref_alt=image_ref_alt,
path_to_private_key=root('fuel_test', 'config', 'ssh_keys',
'openstack'),
'openstack'),
compute_db_uri='mysql://nova:nova@%s/nova' % self.ci().internal_virtual_ip()
))
@ -160,25 +159,25 @@ class Prepare():
tenant1 = retry(10, keystone.tenants.create, tenant_name='tenant1')
tenant2 = retry(10, keystone.tenants.create, tenant_name='tenant2')
retry(10, keystone.users.create, name='tempest1', password='secret',
email='tempest1@example.com', tenant_id=tenant1.id)
email='tempest1@example.com', tenant_id=tenant1.id)
retry(10, keystone.users.create, name='tempest2', password='secret',
email='tempest2@example.com', tenant_id=tenant2.id)
email='tempest2@example.com', tenant_id=tenant2.id)
image_ref, image_ref_alt = self.tempest_add_images()
return image_ref, image_ref_alt
def _get_identity_client(self):
keystone = retry(10, keystoneclient.v2_0.client.Client,
username=self.username(), password=self.password(),
tenant_name=self.tenant(),
auth_url=self.get_auth_url())
username=self.username(), password=self.password(),
tenant_name=self.tenant(),
auth_url=self.get_auth_url())
return keystone
def _get_image_client(self):
keystone = self._get_identity_client()
endpoint = keystone.service_catalog.url_for(service_type='image',
endpoint_type='publicURL')
endpoint_type='publicURL')
return glanceclient.Client('1', endpoint=endpoint,
token=keystone.auth_token)
token=keystone.auth_token)
def upload(self, glance, name, path):
image = glance.images.create(
@ -194,9 +193,9 @@ class Prepare():
subprocess.check_call(['wget', CIRROS_IMAGE])
glance = self._get_image_client()
return self.upload(glance, 'cirros_0.3.0',
'cirros-0.3.0-x86_64-disk.img'),\
'cirros-0.3.0-x86_64-disk.img'), \
self.upload(glance, 'cirros_0.3.0',
'cirros-0.3.0-x86_64-disk.img')
'cirros-0.3.0-x86_64-disk.img')
def tempest_share_glance_images(self, network):
if OS_FAMILY == "centos":
@ -207,7 +206,7 @@ class Prepare():
self.remote().check_stderr('/etc/init.d/nfs restart')
else:
install_packages(self.remote(),
'nfs-kernel-server nfs-common portmap')
'nfs-kernel-server nfs-common portmap')
self.remote().check_stderr(
'echo "/var/lib/glance/images %s(rw,no_root_squash)" >> /etc/exports' % network)
self.remote().check_stderr('/etc/init.d/nfs-kernel-server restart')
@ -233,7 +232,8 @@ class Prepare():
'internal', login='root',
password='r00tme').sudo.ssh
self.tempest_mount_glance_images(remote, nfs_server)
sleep(60)
sleep(20)
if __name__ == '__main__':
unittest.main()
Prepare().prepare_tempest_folsom()