Add method to update node interfaces

- Add method to update node interfaces through cli
- Update cli tests with new method

Change-Id: Icd79684f7a2b48972135bed6e25261dc8e977255
Closes-Bug: #1564462
This commit is contained in:
asledzinskiy 2016-04-19 19:27:40 +03:00 committed by Andrey Sledzinskiy
parent 1d43e9a3ca
commit 2a68b9a487
5 changed files with 111 additions and 33 deletions

View File

@ -167,6 +167,7 @@ class CommandLineTest(test_cli_base.CommandLine):
cmd = ('fuel --env-id={0} node set --node {1}\ cmd = ('fuel --env-id={0} node set --node {1}\
--role=controller'.format(cluster_id, node_ids[0])) --role=controller'.format(cluster_id, node_ids[0]))
self.ssh_manager.execute_on_remote(admin_ip, cmd) self.ssh_manager.execute_on_remote(admin_ip, cmd)
self.update_node_interfaces(node_ids[0])
cmd = ('fuel --env-id={0} node --provision --node={1} --json'.format( cmd = ('fuel --env-id={0} node --provision --node={1} --json'.format(
cluster_id, node_ids[0])) cluster_id, node_ids[0]))
task = self.ssh_manager.execute_on_remote(admin_ip, task = self.ssh_manager.execute_on_remote(admin_ip,
@ -181,6 +182,8 @@ class CommandLineTest(test_cli_base.CommandLine):
cmd = ('fuel --env-id={0} node set --node {1},{2} \ cmd = ('fuel --env-id={0} node set --node {1},{2} \
--role=compute,cinder'.format(cluster_id, node_ids[1], node_ids[2])) --role=compute,cinder'.format(cluster_id, node_ids[1], node_ids[2]))
self.ssh_manager.execute_on_remote(admin_ip, cmd) self.ssh_manager.execute_on_remote(admin_ip, cmd)
for node_id in (node_ids[1], node_ids[2]):
self.update_node_interfaces(node_id)
cmd = ('fuel --env-id={0} node --provision \ cmd = ('fuel --env-id={0} node --provision \
--node={1},{2} --json'.format(cluster_id, node_ids[1], node_ids[2])) --node={1},{2} --json'.format(cluster_id, node_ids[1], node_ids[2]))
task = self.ssh_manager.execute_on_remote(admin_ip, task = self.ssh_manager.execute_on_remote(admin_ip,
@ -423,6 +426,7 @@ class CommandLineTest(test_cli_base.CommandLine):
cmd = ('fuel --env-id={0} node set --node {1}\ cmd = ('fuel --env-id={0} node set --node {1}\
--role=controller'.format(cluster_id, node_ids[0])) --role=controller'.format(cluster_id, node_ids[0]))
self.ssh_manager.execute_on_remote(admin_ip, cmd) self.ssh_manager.execute_on_remote(admin_ip, cmd)
self.update_node_interfaces(node_ids[0])
cmd = ('fuel --env-id={0} node --provision --node={1} --json'.format( cmd = ('fuel --env-id={0} node --provision --node={1} --json'.format(
cluster_id, node_ids[0])) cluster_id, node_ids[0]))
task = self.ssh_manager.execute_on_remote(admin_ip, task = self.ssh_manager.execute_on_remote(admin_ip,
@ -443,6 +447,7 @@ class CommandLineTest(test_cli_base.CommandLine):
cmd = ('fuel --env-id={0} node set --node {1}\ cmd = ('fuel --env-id={0} node set --node {1}\
--role=compute'.format(cluster_id, node_ids[1])) --role=compute'.format(cluster_id, node_ids[1]))
self.ssh_manager.execute_on_remote(admin_ip, cmd) self.ssh_manager.execute_on_remote(admin_ip, cmd)
self.update_node_interfaces(node_ids[1])
cmd = ('fuel --env-id={0} node --provision \ cmd = ('fuel --env-id={0} node --provision \
--node={1} --json'.format(cluster_id, node_ids[1])) --node={1} --json'.format(cluster_id, node_ids[1]))
@ -464,6 +469,7 @@ class CommandLineTest(test_cli_base.CommandLine):
cmd = ('fuel --env-id={0} node set --node {1}\ cmd = ('fuel --env-id={0} node set --node {1}\
--role=cinder'.format(cluster_id, node_ids[2])) --role=cinder'.format(cluster_id, node_ids[2]))
self.ssh_manager.execute_on_remote(admin_ip, cmd) self.ssh_manager.execute_on_remote(admin_ip, cmd)
self.update_node_interfaces(node_ids[2])
cmd = ('fuel --env-id={0} node --provision \ cmd = ('fuel --env-id={0} node --provision \
--node={1} --json'.format(cluster_id, node_ids[2])) --node={1} --json'.format(cluster_id, node_ids[2]))
@ -485,6 +491,7 @@ class CommandLineTest(test_cli_base.CommandLine):
cmd = ('fuel --env-id={0} node set --node {1}\ cmd = ('fuel --env-id={0} node set --node {1}\
--role=mongo'.format(cluster_id, node_ids[3])) --role=mongo'.format(cluster_id, node_ids[3]))
self.ssh_manager.execute_on_remote(admin_ip, cmd) self.ssh_manager.execute_on_remote(admin_ip, cmd)
self.update_node_interfaces(node_ids[3])
cmd = ('fuel --env-id={0} node --provision \ cmd = ('fuel --env-id={0} node --provision \
--node={1} --json'.format(cluster_id, node_ids[3])) --node={1} --json'.format(cluster_id, node_ids[3]))
@ -507,6 +514,8 @@ class CommandLineTest(test_cli_base.CommandLine):
cmd = ('fuel --env-id={0} node set --node {1},{2} ' cmd = ('fuel --env-id={0} node set --node {1},{2} '
'--role=ceph-osd'.format(cluster_id, node_ids[4], node_ids[5])) '--role=ceph-osd'.format(cluster_id, node_ids[4], node_ids[5]))
self.ssh_manager.execute_on_remote(admin_ip, cmd) self.ssh_manager.execute_on_remote(admin_ip, cmd)
for node_id in (node_ids[4], node_ids[5]):
self.update_node_interfaces(node_id)
cmd = ('fuel ' cmd = ('fuel '
'--env-id={0} node --provision ' '--env-id={0} node --provision '
@ -529,6 +538,7 @@ class CommandLineTest(test_cli_base.CommandLine):
cmd = ('fuel --env-id={0} node set --node {1} ' cmd = ('fuel --env-id={0} node set --node {1} '
'--role=base-os'.format(cluster_id, node_ids[6])) '--role=base-os'.format(cluster_id, node_ids[6]))
self.ssh_manager.execute_on_remote(admin_ip, cmd) self.ssh_manager.execute_on_remote(admin_ip, cmd)
self.update_node_interfaces(node_ids[6])
cmd = ('fuel --env-id={0} node --provision ' cmd = ('fuel --env-id={0} node --provision '
'--node={1} --json'.format(cluster_id, node_ids[6])) '--node={1} --json'.format(cluster_id, node_ids[6]))

View File

@ -27,6 +27,7 @@ from fuelweb_test.tests.base_test_case import TestBasic
from fuelweb_test import logwrap from fuelweb_test import logwrap
from fuelweb_test import logger from fuelweb_test import logger
from fuelweb_test.helpers.utils import hiera_json_out from fuelweb_test.helpers.utils import hiera_json_out
from fuelweb_test.settings import iface_alias
from fuelweb_test.settings import SSL_CN from fuelweb_test.settings import SSL_CN
@ -297,3 +298,53 @@ class CommandLine(TestBasic):
'domain': url.hostname} 'domain': url.hostname}
endpoints.append(endpoint_info) endpoints.append(endpoint_info)
return endpoints return endpoints
@logwrap
def download_node_interfaces(self, node_id):
cmd = ' fuel node --node-id {} --network --download --dir' \
' /tmp --json'.format(node_id)
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd=cmd
)
out = self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd='cd /tmp && cat node_{}/interfaces.json'.format(node_id),
jsonify=True
)['stdout_json']
return out
def upload_node_interfaces(self, node_id, interfaces):
data = json.dumps(interfaces)
cmd = 'cd /tmp && echo {data} > node_{id}/interfaces.json'.format(
data=json.dumps(data),
id=node_id)
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd=cmd
)
cmd = ('fuel node --node-id {} --network --upload --dir /tmp'
' --json'.format(node_id))
self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip,
cmd=cmd
)
@logwrap
def update_node_interfaces(self, node_id):
interfaces = self.download_node_interfaces(node_id)
logger.debug("interfaces we get {}".format(interfaces))
assigned_networks = {
iface_alias('eth0'): [{'id': 1, 'name': 'fuelweb_admin'}],
iface_alias('eth1'): [{'id': 2, 'name': 'public'}],
iface_alias('eth2'): [{'id': 3, 'name': 'management'}],
iface_alias('eth3'): [{'id': 5, 'name': 'private'}],
iface_alias('eth4'): [{'id': 4, 'name': 'storage'}],
}
for interface in interfaces:
name = interface['name']
net_to_assign = assigned_networks.get(name, None)
if net_to_assign:
interface['assigned_networks'] = net_to_assign
logger.debug("interfaces after update {}".format(interfaces))
self.upload_node_interfaces(node_id, interfaces)

View File

@ -36,10 +36,11 @@ class CommandLineAcceptanceDeploymentTests(test_cli_base.CommandLine):
3. Add 1 controller 3. Add 1 controller
4. Add 1 compute 4. Add 1 compute
5. Add 1 cinder 5. Add 1 cinder
6. Verify networks 6. Update nodes interfaces
7. Deploy the environment 7. Verify networks
8. Verify networks 8. Deploy the environment
9. Run OSTF tests 9. Verify networks
10. Run OSTF tests
Duration 40m Duration 40m
""" """
@ -74,8 +75,11 @@ class CommandLineAcceptanceDeploymentTests(test_cli_base.CommandLine):
self.add_nodes_to_cluster(cluster_id, node_ids[1], ['compute']) self.add_nodes_to_cluster(cluster_id, node_ids[1], ['compute'])
self.add_nodes_to_cluster(cluster_id, node_ids[2], ['cinder']) self.add_nodes_to_cluster(cluster_id, node_ids[2], ['cinder'])
self.show_step(6) self.show_step(6)
self.fuel_web.verify_network(cluster_id) for node_id in node_ids:
self.update_node_interfaces(node_id)
self.show_step(7) self.show_step(7)
self.fuel_web.verify_network(cluster_id)
self.show_step(8)
cmd = 'fuel --env-id={0} deploy-changes --json'.format(cluster_id) cmd = 'fuel --env-id={0} deploy-changes --json'.format(cluster_id)
task = self.ssh_manager.execute_on_remote( task = self.ssh_manager.execute_on_remote(
@ -85,10 +89,10 @@ class CommandLineAcceptanceDeploymentTests(test_cli_base.CommandLine):
)['stdout_json'] )['stdout_json']
self.assert_cli_task_success(task, timeout=130 * 60) self.assert_cli_task_success(task, timeout=130 * 60)
self.show_step(8) self.show_step(9)
self.fuel_web.verify_network(cluster_id) self.fuel_web.verify_network(cluster_id)
self.show_step(9) self.show_step(10)
self.fuel_web.run_ostf( self.fuel_web.run_ostf(
cluster_id=cluster_id, test_sets=['ha', 'smoke', 'sanity'], cluster_id=cluster_id, test_sets=['ha', 'smoke', 'sanity'],
should_fail=1) should_fail=1)
@ -103,14 +107,15 @@ class CommandLineAcceptanceDeploymentTests(test_cli_base.CommandLine):
1. Create new environment 1. Create new environment
2. Choose Neutron, Vlan 2. Choose Neutron, Vlan
3. Add 3 controllers 3. Add 3 controllers
4. Provision 3 controllers 4. Update nodes interfaces
5. Provision 3 controllers
(fuel node --node-id x,x,x --provision --env x) (fuel node --node-id x,x,x --provision --env x)
5. Start netconfig on second controller 6. Start netconfig on second controller
(fuel node --node 2 --end netconfig --env x) (fuel node --node 2 --end netconfig --env x)
6. Deploy controller nodes 7. Deploy controller nodes
(fuel node --node x,x,x --deploy --env-id x) (fuel node --node x,x,x --deploy --env-id x)
7. Verify networks 8. Verify networks
8. Run OSTF tests 9. Run OSTF tests
Duration 50m Duration 50m
""" """
@ -137,6 +142,9 @@ class CommandLineAcceptanceDeploymentTests(test_cli_base.CommandLine):
self.add_nodes_to_cluster(cluster_id, node_ids[0:3], self.add_nodes_to_cluster(cluster_id, node_ids[0:3],
['controller']) ['controller'])
self.show_step(4) self.show_step(4)
for node_id in node_ids:
self.update_node_interfaces(node_id)
self.show_step(5)
cmd = ('fuel node --node-id {0} --provision --env {1} --json'. cmd = ('fuel node --node-id {0} --provision --env {1} --json'.
format(','.join(str(n) for n in node_ids), cluster_id)) format(','.join(str(n) for n in node_ids), cluster_id))
task = self.ssh_manager.execute_on_remote( task = self.ssh_manager.execute_on_remote(
@ -145,7 +153,7 @@ class CommandLineAcceptanceDeploymentTests(test_cli_base.CommandLine):
jsonify=True jsonify=True
)['stdout_json'] )['stdout_json']
self.assert_cli_task_success(task, timeout=20 * 60) self.assert_cli_task_success(task, timeout=20 * 60)
self.show_step(5) self.show_step(6)
cmd = ('fuel node --node {0} --end netconfig --env {1} --json'. cmd = ('fuel node --node {0} --end netconfig --env {1} --json'.
format(node_ids[1], release_id)) format(node_ids[1], release_id))
task = self.ssh_manager.execute_on_remote( task = self.ssh_manager.execute_on_remote(
@ -154,7 +162,7 @@ class CommandLineAcceptanceDeploymentTests(test_cli_base.CommandLine):
jsonify=True jsonify=True
)['stdout_json'] )['stdout_json']
self.assert_cli_task_success(task, timeout=30 * 60) self.assert_cli_task_success(task, timeout=30 * 60)
self.show_step(6) self.show_step(7)
cmd = 'fuel --env-id={0} deploy-changes --json'.format(cluster_id) cmd = 'fuel --env-id={0} deploy-changes --json'.format(cluster_id)
task = self.ssh_manager.execute_on_remote( task = self.ssh_manager.execute_on_remote(
ip=self.ssh_manager.admin_ip, ip=self.ssh_manager.admin_ip,
@ -162,9 +170,9 @@ class CommandLineAcceptanceDeploymentTests(test_cli_base.CommandLine):
jsonify=True jsonify=True
)['stdout_json'] )['stdout_json']
self.assert_cli_task_success(task, timeout=130 * 60) self.assert_cli_task_success(task, timeout=130 * 60)
self.show_step(7)
self.fuel_web.verify_network(cluster_id)
self.show_step(8) self.show_step(8)
self.fuel_web.verify_network(cluster_id)
self.show_step(9)
self.fuel_web.run_ostf( self.fuel_web.run_ostf(
cluster_id=cluster_id, test_sets=['ha', 'smoke', 'sanity'], cluster_id=cluster_id, test_sets=['ha', 'smoke', 'sanity'],
should_fail=1) should_fail=1)

View File

@ -37,11 +37,12 @@ class CommandLineAcceptanceCephDeploymentTests(test_cli_base.CommandLine):
4. Change ceph replication factor to 2 4. Change ceph replication factor to 2
5. Add 3 controller 5. Add 3 controller
6. Add 2 compute 6. Add 2 compute
7. Add 2 ceph 7. Add 2 cephi
8. Verify networks 8. Update nodes interfaces
9. Deploy the environment 9. Verify networks
10. Verify networks 10. Deploy the environment
11. Run OSTF tests 11. Verify networks
12. Run OSTF tests
Duration 40m Duration 40m
""" """
@ -79,15 +80,19 @@ class CommandLineAcceptanceCephDeploymentTests(test_cli_base.CommandLine):
self.show_step(4) self.show_step(4)
self.show_step(5) self.show_step(5)
self.show_step(6) self.show_step(6)
self.show_step(7)
self.add_nodes_to_cluster(cluster_id, node_ids[0:3], self.add_nodes_to_cluster(cluster_id, node_ids[0:3],
['controller']) ['controller'])
self.add_nodes_to_cluster(cluster_id, node_ids[3:5], self.add_nodes_to_cluster(cluster_id, node_ids[3:5],
['compute']) ['compute'])
self.add_nodes_to_cluster(cluster_id, node_ids[5:7], self.add_nodes_to_cluster(cluster_id, node_ids[5:7],
['ceph-osd']) ['ceph-osd'])
self.show_step(7)
self.fuel_web.verify_network(cluster_id)
self.show_step(8) self.show_step(8)
for node_id in node_ids:
self.update_node_interfaces(node_id)
self.show_step(9)
self.fuel_web.verify_network(cluster_id)
self.show_step(10)
cmd = 'fuel --env-id={0} deploy-changes --json'.format(cluster_id) cmd = 'fuel --env-id={0} deploy-changes --json'.format(cluster_id)
task = self.ssh_manager.execute_on_remote( task = self.ssh_manager.execute_on_remote(
@ -97,10 +102,10 @@ class CommandLineAcceptanceCephDeploymentTests(test_cli_base.CommandLine):
)['stdout_json'] )['stdout_json']
self.assert_cli_task_success(task, timeout=130 * 60) self.assert_cli_task_success(task, timeout=130 * 60)
self.show_step(9) self.show_step(11)
self.fuel_web.verify_network(cluster_id) self.fuel_web.verify_network(cluster_id)
self.show_step(10) self.show_step(12)
self.fuel_web.run_ostf( self.fuel_web.run_ostf(
cluster_id=cluster_id, test_sets=['ha', 'smoke', 'sanity']) cluster_id=cluster_id, test_sets=['ha', 'smoke', 'sanity'])
@ -117,10 +122,11 @@ class CommandLineAcceptanceCephDeploymentTests(test_cli_base.CommandLine):
4. Add 3 controller 4. Add 3 controller
5. Add 2 compute 5. Add 2 compute
6. Add 3 ceph 6. Add 3 ceph
7. Verify networks 7. Update nodes interfaces
8. Deploy the environment 8. Verify networks
9. Verify networks 9. Deploy the environment
10. Run OSTF tests 10. Verify networks
11. Run OSTF tests
Duration: 60 min Duration: 60 min
""" """
@ -167,11 +173,13 @@ class CommandLineAcceptanceCephDeploymentTests(test_cli_base.CommandLine):
cluster['id'], cluster['id'],
','.join(map(str, nodes[role])), role) ','.join(map(str, nodes[role])), role)
) )
self.show_step(7) self.show_step(7)
for node_id in node_ids:
self.update_node_interfaces(node_id)
self.show_step(8)
self.fuel_web.verify_network(cluster['id']) self.fuel_web.verify_network(cluster['id'])
self.show_step(8) self.show_step(9)
task = self.ssh_manager.execute_on_remote( task = self.ssh_manager.execute_on_remote(
ip=admin_ip, ip=admin_ip,
cmd='fuel --env-id={0} ' cmd='fuel --env-id={0} '
@ -180,9 +188,9 @@ class CommandLineAcceptanceCephDeploymentTests(test_cli_base.CommandLine):
)['stdout_json'] )['stdout_json']
self.assert_cli_task_success(task, timeout=130 * 60) self.assert_cli_task_success(task, timeout=130 * 60)
self.show_step(9)
self.fuel_web.verify_network(cluster['id'])
self.show_step(10) self.show_step(10)
self.fuel_web.verify_network(cluster['id'])
self.show_step(11)
self.fuel_web.run_ostf( self.fuel_web.run_ostf(
cluster_id=cluster['id'], cluster_id=cluster['id'],
test_sets=['ha', 'smoke', 'sanity'] test_sets=['ha', 'smoke', 'sanity']

View File

@ -182,6 +182,7 @@ class CreateDeployEnvironmentCli(test_cli_base.CommandLine):
cmd = ('fuel --env-id={0} node set --node {1} --role=controller' cmd = ('fuel --env-id={0} node set --node {1} --role=controller'
.format(cluster_id, node_id[0])) .format(cluster_id, node_id[0]))
remote.execute(cmd) remote.execute(cmd)
self.update_node_interfaces(node_id[0])
cmd = ('fuel --env-id={0} node --provision --node={1} --json' cmd = ('fuel --env-id={0} node --provision --node={1} --json'
.format(cluster_id, node_id[0])) .format(cluster_id, node_id[0]))
task = run_on_remote(remote, cmd, jsonify=True) task = run_on_remote(remote, cmd, jsonify=True)