Serializers Conversion extension for Fuel Nailgun
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_pipelines.py 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2015 Mirantis, Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. from copy import deepcopy
  16. import mock
  17. import six
  18. import nailgun
  19. from nailgun import consts
  20. from nailgun.db.sqlalchemy import models
  21. from nailgun import objects
  22. from nailgun import rpc
  23. from nailgun.orchestrator import deployment_serializers
  24. from nailgun.orchestrator.deployment_serializers import \
  25. get_serializer_for_cluster
  26. from nailgun.orchestrator.neutron_serializers import \
  27. NeutronNetworkDeploymentSerializer80
  28. from nailgun.orchestrator.neutron_serializers import \
  29. NeutronNetworkTemplateSerializer80
  30. from nailgun.test.integration.test_orchestrator_serializer import \
  31. BaseDeploymentSerializer
  32. from nailgun.test.integration.test_orchestrator_serializer import \
  33. TestSerializeInterfaceDriversData
  34. from nailgun.test.integration.test_orchestrator_serializer_70 import \
  35. TestDeploymentHASerializer70
  36. from nailgun.test.integration.test_orchestrator_serializer_80 import \
  37. TestSerializer80Mixin
  38. class TestSerializerWrapper(deployment_serializers.DeploymentLCMSerializer):
  39. def serialize(self, cluster, nodes, ignore_customized=False):
  40. return deployment_serializers.serialize_for_lcm(
  41. cluster, nodes, ignore_customized=ignore_customized)
  42. def get_net_provider_serializer(cls, cluster):
  43. return deployment_serializers\
  44. .DeploymentHASerializer80.get_net_provider_serializer(cluster)
  45. class TestSerializerConverter80To90MixIn(TestSerializer80Mixin):
  46. env_version = "liberty-8.0"
  47. task_deploy = True
  48. is_propagate_task_deploy = True
  49. enforce_lcm = True
  50. @classmethod
  51. def create_serializer(cls, cluster):
  52. serializer_type = TestSerializerWrapper
  53. return serializer_type(None)
  54. class TestNetworkTemplateSerializer80MixIn(
  55. TestSerializerConverter80To90MixIn,
  56. BaseDeploymentSerializer
  57. ):
  58. legacy_serializer = NeutronNetworkDeploymentSerializer80
  59. template_serializer = NeutronNetworkTemplateSerializer80
  60. def setUp(self, *args):
  61. super(TestNetworkTemplateSerializer80MixIn, self).setUp()
  62. self.env.create(
  63. release_kwargs={'version': self.env_version},
  64. cluster_kwargs={
  65. 'mode': consts.CLUSTER_MODES.ha_compact,
  66. 'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron,
  67. 'net_segment_type': consts.NEUTRON_SEGMENT_TYPES.vlan})
  68. self.net_template = self.env.read_fixtures(['network_template_80'])[0]
  69. self.cluster = self.env.clusters[-1]
  70. self.cluster.extensions = ['volume_manager', 'converted_serializers']
  71. self.serializer = self.create_serializer(self.cluster)
  72. def test_get_net_provider_serializer(self):
  73. self.cluster.network_config.configuration_template = None
  74. net_serializer = self.serializer.\
  75. get_net_provider_serializer(self.cluster)
  76. self.assertIs(net_serializer, self.legacy_serializer)
  77. self.cluster.network_config.configuration_template = \
  78. self.net_template
  79. net_serializer = self.serializer.\
  80. get_net_provider_serializer(self.cluster)
  81. self.assertIs(net_serializer, self.template_serializer)
  82. def test_baremetal_neutron_attrs(self):
  83. brmtl_template = deepcopy(
  84. self.net_template['adv_net_template']['default'])
  85. brmtl_template['network_assignments']['baremetal'] = {
  86. 'ep': 'br-baremetal'}
  87. brmtl_template['templates_for_node_role']['controller'].append(
  88. 'baremetal')
  89. brmtl_template['nic_mapping']['default']['if8'] = 'eth7'
  90. brmtl_template['network_scheme']['baremetal'] = {
  91. 'endpoints': ['br-baremetal'],
  92. 'transformations': [],
  93. 'roles': {'baremetal': 'br-baremetal'}}
  94. self.cluster.network_config.configuration_template = {
  95. 'adv_net_template': {'default': brmtl_template}, 'pk': 1}
  96. self._check_baremetal_neutron_attrs(self.cluster)
  97. def test_network_schemes_priorities(self):
  98. expected = [
  99. {
  100. "action": "add-br",
  101. "name": "br-prv",
  102. "provider": "ovs"
  103. },
  104. {
  105. "action": "add-br",
  106. "name": "br-aux"
  107. },
  108. {
  109. "action": "add-patch",
  110. "bridges": [
  111. "br-prv",
  112. "br-aux"
  113. ],
  114. "provider": "ovs",
  115. "mtu": 65000
  116. },
  117. {
  118. "action": "add-port",
  119. "bridge": "br-aux",
  120. "name": "eth3.101"
  121. },
  122. {
  123. "action": "add-br",
  124. "name": "br-fw-admin"
  125. },
  126. {
  127. "action": "add-port",
  128. "bridge": "br-fw-admin",
  129. "name": "eth0"
  130. },
  131. {
  132. "action": "add-br",
  133. "name": "br-mgmt"
  134. },
  135. {
  136. "action": "add-port",
  137. "bridge": "br-mgmt",
  138. "name": "eth1.104"
  139. },
  140. {
  141. "action": "add-br",
  142. "name": "br-storage"
  143. },
  144. {
  145. "action": "add-port",
  146. "bridge": "br-storage",
  147. "name": "eth2"
  148. }
  149. ]
  150. objects.Cluster.set_network_template(
  151. self.cluster,
  152. self.net_template
  153. )
  154. node = self.env.create_nodes_w_interfaces_count(
  155. 1, 8, roles=['compute', 'cinder'],
  156. cluster_id=self.cluster.id
  157. )[0]
  158. self.serializer = get_serializer_for_cluster(self.cluster)
  159. net_serializer = self.serializer.get_net_provider_serializer(
  160. self.cluster)
  161. nm = objects.Cluster.get_network_manager(self.cluster)
  162. network_scheme = net_serializer.generate_network_scheme(
  163. node, nm.get_node_networks(node))
  164. self.assertEqual(expected, network_scheme['transformations'])
  165. class TestDeploymentTasksSerialization80MixIn(
  166. TestSerializerConverter80To90MixIn,
  167. BaseDeploymentSerializer
  168. ):
  169. tasks_for_rerun = {"globals", "netconfig"}
  170. def setUp(self):
  171. super(TestDeploymentTasksSerialization80MixIn, self).setUp()
  172. self.env.create(
  173. release_kwargs={'version': self.env_version},
  174. cluster_kwargs={
  175. 'mode': consts.CLUSTER_MODES.ha_compact,
  176. 'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron,
  177. 'net_segment_type': consts.NEUTRON_SEGMENT_TYPES.vlan,
  178. 'status': consts.CLUSTER_STATUSES.operational},
  179. nodes_kwargs=[
  180. {'roles': ['controller'],
  181. 'status': consts.NODE_STATUSES.ready}]
  182. )
  183. self.cluster = self.env.clusters[-1]
  184. self.cluster.extensions = ['volume_manager', 'converted_serializers']
  185. if not self.task_deploy:
  186. self.env.disable_task_deploy(self.cluster)
  187. def add_node(self, role):
  188. return self.env.create_node(
  189. cluster_id=self.cluster.id,
  190. pending_roles=[role],
  191. pending_addition=True
  192. )
  193. def get_rpc_args(self):
  194. self.env.launch_deployment()
  195. args, kwargs = nailgun.task.manager.rpc.cast.call_args
  196. return args[1][1]['args']
  197. def check_add_node_for_task_deploy(self, rpc_message):
  198. tasks_graph = rpc_message['tasks_graph']
  199. for node_id, tasks in six.iteritems(tasks_graph):
  200. if node_id is None or node_id == consts.MASTER_NODE_UID:
  201. # skip virtual node
  202. continue
  203. task_ids = {
  204. t['id'] for t in tasks
  205. if t['type'] != consts.ORCHESTRATOR_TASK_TYPES.skipped
  206. }
  207. # all tasks are run on all nodes
  208. self.assertTrue(self.tasks_for_rerun.issubset(task_ids))
  209. def check_add_compute_for_granular_deploy(self, new_node_uid, rpc_message):
  210. for node in rpc_message['deployment_info']:
  211. task_ids = {t['id'] for t in node['tasks']}
  212. if node['tasks'][0]['uids'] == [new_node_uid]:
  213. # all tasks are run on a new node
  214. self.assertTrue(
  215. self.tasks_for_rerun.issubset(task_ids))
  216. else:
  217. # only selected tasks are run on a deployed node
  218. self.assertItemsEqual(self.tasks_for_rerun, task_ids)
  219. def check_add_controller_for_granular_deploy(self, rpc_message):
  220. for node in rpc_message['deployment_info']:
  221. task_ids = {t['id'] for t in node['tasks']}
  222. # controller is redeployed when other one is added
  223. # so all tasks are run on all nodes
  224. self.assertTrue(
  225. self.tasks_for_rerun.issubset(task_ids))
  226. @mock.patch('nailgun.rpc.cast')
  227. def test_add_compute(self, _):
  228. new_node = self.add_node('compute')
  229. rpc_deploy_message = self.get_rpc_args()
  230. if self.task_deploy:
  231. self.check_add_node_for_task_deploy(rpc_deploy_message)
  232. else:
  233. self.check_add_compute_for_granular_deploy(
  234. new_node.uid, rpc_deploy_message
  235. )
  236. @mock.patch('nailgun.rpc.cast')
  237. def test_add_controller(self, _):
  238. self.add_node('controller')
  239. rpc_deploy_message = self.get_rpc_args()
  240. if self.task_deploy:
  241. self.check_add_node_for_task_deploy(rpc_deploy_message)
  242. else:
  243. self.check_add_controller_for_granular_deploy(rpc_deploy_message)
  244. class TestDeploymentAttributesSerialization80MixIn(
  245. TestSerializerConverter80To90MixIn,
  246. BaseDeploymentSerializer
  247. ):
  248. def setUp(self):
  249. super(TestDeploymentAttributesSerialization80MixIn, self).setUp()
  250. self.cluster = self.env.create(
  251. release_kwargs={
  252. 'version': self.env_version,
  253. 'operating_system': consts.RELEASE_OS.ubuntu},
  254. cluster_kwargs={
  255. 'mode': consts.CLUSTER_MODES.ha_compact,
  256. 'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron,
  257. 'net_segment_type': consts.NEUTRON_SEGMENT_TYPES.vlan})
  258. self.cluster_db = self.db.query(models.Cluster).get(self.cluster['id'])
  259. self.cluster.extensions = ['volume_manager', 'converted_serializers']
  260. self.serializer = self.create_serializer(self.cluster_db)
  261. def test_neutron_attrs(self):
  262. self.env.create_node(
  263. cluster_id=self.cluster_db.id,
  264. roles=['controller'], primary_roles=['controller']
  265. )
  266. objects.Cluster.prepare_for_deployment(self.cluster_db)
  267. serialized_for_astute = self.serializer.serialize(
  268. self.cluster_db, self.cluster_db.nodes)
  269. for node in serialized_for_astute:
  270. self.assertEqual(
  271. {
  272. "bridge": consts.DEFAULT_BRIDGES_NAMES.br_floating,
  273. "vlan_range": None
  274. },
  275. node['quantum_settings']['L2']['phys_nets']['physnet1']
  276. )
  277. l2 = (node["quantum_settings"]["predefined_networks"]
  278. [self.cluster_db.network_config.floating_name]["L2"])
  279. self.assertEqual("physnet1", l2["physnet"])
  280. self.assertEqual("flat", l2["network_type"])
  281. def test_baremetal_transformations(self):
  282. self.env._set_additional_component(self.cluster_db, 'ironic', True)
  283. self.env.create_node(cluster_id=self.cluster_db.id,
  284. roles=['primary-controller'])
  285. objects.Cluster.prepare_for_deployment(self.cluster_db)
  286. serialized_for_astute = self.serializer.serialize(
  287. self.cluster_db, self.cluster_db.nodes)
  288. for node in serialized_for_astute:
  289. if node['uid'] == 'master':
  290. continue
  291. transformations = node['network_scheme']['transformations']
  292. baremetal_brs = filter(lambda t: t.get('name') ==
  293. consts.DEFAULT_BRIDGES_NAMES.br_baremetal,
  294. transformations)
  295. baremetal_ports = filter(lambda t: t.get('name') == "eth0.104",
  296. transformations)
  297. expected_patch = {
  298. 'action': 'add-patch',
  299. 'bridges': [consts.DEFAULT_BRIDGES_NAMES.br_ironic,
  300. consts.DEFAULT_BRIDGES_NAMES.br_baremetal],
  301. 'provider': 'ovs'}
  302. self.assertEqual(len(baremetal_brs), 1)
  303. self.assertEqual(len(baremetal_ports), 1)
  304. self.assertEqual(baremetal_ports[0]['bridge'],
  305. consts.DEFAULT_BRIDGES_NAMES.br_baremetal)
  306. self.assertIn(expected_patch, transformations)
  307. def test_disks_attrs(self):
  308. disks = [
  309. {
  310. "model": "TOSHIBA MK1002TS",
  311. "name": "sda",
  312. "disk": "sda",
  313. "size": 1004886016
  314. },
  315. ]
  316. expected_node_volumes_hash = [
  317. {
  318. u'name': u'sda',
  319. u'bootable': True,
  320. u'extra': [],
  321. u'free_space': 330,
  322. u'volumes': [
  323. {
  324. u'type': u'boot',
  325. u'size': 300
  326. },
  327. {
  328. u'mount': u'/boot',
  329. u'type': u'partition',
  330. u'file_system': u'ext2',
  331. u'name': u'Boot',
  332. u'size': 200
  333. },
  334. {
  335. u'type': u'lvm_meta_pool',
  336. u'size': 64
  337. },
  338. {
  339. u'vg': u'os',
  340. u'type': u'pv',
  341. u'lvm_meta_size': 64,
  342. u'size': 394
  343. },
  344. {
  345. u'vg': u'vm',
  346. u'type': u'pv',
  347. u'lvm_meta_size': 0,
  348. u'size': 0
  349. }
  350. ],
  351. u'type': u'disk',
  352. u'id': u'sda',
  353. u'size': 958
  354. },
  355. {
  356. u'_allocate_size': u'min',
  357. u'label': u'Base System',
  358. u'min_size': 19456,
  359. u'volumes': [
  360. {
  361. u'mount': u'/',
  362. u'size': -3766,
  363. u'type': u'lv',
  364. u'name': u'root',
  365. u'file_system': u'ext4'
  366. },
  367. {
  368. u'mount': u'swap',
  369. u'size': 4096,
  370. u'type': u'lv',
  371. u'name': u'swap',
  372. u'file_system': u'swap'
  373. }
  374. ],
  375. u'type': u'vg',
  376. u'id': u'os'
  377. },
  378. {
  379. u'_allocate_size': u'all',
  380. u'label': u'Virtual Storage',
  381. u'min_size': 5120,
  382. u'volumes': [
  383. {
  384. u'mount': u'/var/lib/nova',
  385. u'size': 0,
  386. u'type': u'lv',
  387. u'name': u'nova',
  388. u'file_system': u'xfs'
  389. }
  390. ],
  391. u'type': u'vg',
  392. u'id': u'vm'
  393. }
  394. ]
  395. self.env.create_node(
  396. cluster_id=self.cluster_db.id,
  397. roles=['compute'],
  398. meta={"disks": disks},
  399. )
  400. objects.Cluster.prepare_for_deployment(self.cluster_db)
  401. serialized_for_astute = self.serializer.serialize(
  402. self.cluster_db, self.cluster_db.nodes)
  403. for node in serialized_for_astute:
  404. if node['uid'] == 'master':
  405. continue
  406. self.assertIn("node_volumes", node)
  407. self.assertItemsEqual(
  408. expected_node_volumes_hash, node["node_volumes"])
  409. def test_attributes_contains_plugins(self):
  410. self.env.create_plugin(
  411. cluster=self.cluster_db,
  412. name='plugin_1',
  413. attributes_metadata={'attributes': {'name': 'plugin_1'}},
  414. package_version='4.0.0',
  415. fuel_version=['8.0'])
  416. self.env.create_plugin(
  417. cluster=self.cluster_db,
  418. name='plugin_2',
  419. attributes_metadata={'attributes': {'name': 'plugin_2'}},
  420. package_version='4.0.0',
  421. fuel_version=['8.0'])
  422. self.env.create_plugin(
  423. cluster=self.cluster_db,
  424. enabled=False,
  425. name='plugin_3',
  426. attributes_metadata={'attributes': {'name': 'plugin_3'}},
  427. package_version='4.0.0',
  428. fuel_version=['8.0'])
  429. expected_plugins_list = ['plugin_1', 'plugin_2']
  430. self.env.create_node(
  431. cluster_id=self.cluster_db.id,
  432. roles=['compute']
  433. )
  434. objects.Cluster.prepare_for_deployment(self.cluster_db)
  435. serialized_for_astute = self.serializer.serialize(
  436. self.cluster_db, self.cluster_db.nodes)
  437. for node in serialized_for_astute:
  438. if node['uid'] == 'master':
  439. continue
  440. self.assertIn('plugins', node)
  441. self.assertItemsEqual(
  442. expected_plugins_list, node['plugins'])
  443. self.assertTrue(all(name in node for name
  444. in expected_plugins_list))
  445. def test_common_attributes_contains_plugin_metadata(self):
  446. expected_value = 'check_value'
  447. plugin = self.env.create_plugin(
  448. cluster=self.cluster_db,
  449. name='test_plugin',
  450. package_version='4.0.0',
  451. fuel_version=['8.0'],
  452. attributes_metadata={
  453. 'attributes': {
  454. 'config': {
  455. 'description': "Description",
  456. 'weight': 52,
  457. 'value': expected_value
  458. }
  459. }
  460. }
  461. )
  462. attrs = self.serializer.get_common_attrs(self.cluster_db)
  463. self.assertIn('test_plugin', attrs)
  464. self.assertIn('metadata', attrs['test_plugin'])
  465. self.assertEqual(
  466. plugin.id, attrs['test_plugin']['metadata']['plugin_id']
  467. )
  468. self.assertEqual(expected_value, attrs['test_plugin']['config'])
  469. class TestMultiNodeGroupsSerialization80MixIn(
  470. TestSerializerConverter80To90MixIn,
  471. BaseDeploymentSerializer
  472. ):
  473. def setUp(self):
  474. super(TestMultiNodeGroupsSerialization80MixIn, self).setUp()
  475. cluster = self.env.create(
  476. release_kwargs={'version': self.env_version},
  477. cluster_kwargs={
  478. 'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron,
  479. 'net_segment_type': consts.NEUTRON_SEGMENT_TYPES.vlan}
  480. )
  481. self.env.create_nodes_w_interfaces_count(
  482. nodes_count=3,
  483. if_count=2,
  484. roles=['controller', 'cinder'],
  485. pending_addition=True,
  486. cluster_id=cluster['id'])
  487. self.cluster_db = self.db.query(models.Cluster).get(cluster['id'])
  488. cluster.extensions = ['volume_manager', 'converted_serializers']
  489. self.serializer = self.create_serializer(cluster)
  490. def _add_node_group_with_node(self, cidr_start, node_address):
  491. node_group = self.env.create_node_group(
  492. api=False, cluster_id=self.cluster_db.id,
  493. name='ng_' + cidr_start + '_' + str(node_address))
  494. with mock.patch.object(rpc, 'cast'):
  495. resp = self.env.setup_networks_for_nodegroup(
  496. cluster_id=self.cluster_db.id, node_group=node_group,
  497. cidr_start=cidr_start)
  498. self.assertEqual(resp.status_code, 200)
  499. self.db.query(models.Task).filter_by(
  500. name=consts.TASK_NAMES.update_dnsmasq
  501. ).delete(synchronize_session=False)
  502. self.env.create_nodes_w_interfaces_count(
  503. nodes_count=1,
  504. if_count=2,
  505. roles=['compute'],
  506. pending_addition=True,
  507. cluster_id=self.cluster_db.id,
  508. group_id=node_group.id,
  509. ip='{0}.9.{1}'.format(cidr_start, node_address))
  510. def _check_routes_count(self, count):
  511. objects.Cluster.prepare_for_deployment(self.cluster_db)
  512. facts = self.serializer.serialize(
  513. self.cluster_db, self.cluster_db.nodes)
  514. for node in facts:
  515. if node['uid'] == 'master':
  516. continue
  517. endpoints = node['network_scheme']['endpoints']
  518. for name, descr in six.iteritems(endpoints):
  519. if descr['IP'] == 'none':
  520. self.assertNotIn('routes', descr)
  521. else:
  522. self.assertEqual(len(descr['routes']), count)
  523. def test_routes_with_no_shared_networks_2_nodegroups(self):
  524. self._add_node_group_with_node('199.99', 3)
  525. # all networks have different CIDRs
  526. self._check_routes_count(1)
  527. def test_routes_with_no_shared_networks_3_nodegroups(self):
  528. self._add_node_group_with_node('199.99', 3)
  529. self._add_node_group_with_node('199.77', 3)
  530. # all networks have different CIDRs
  531. self._check_routes_count(2)
  532. def test_routes_with_shared_networks_3_nodegroups(self):
  533. self._add_node_group_with_node('199.99', 3)
  534. self._add_node_group_with_node('199.99', 4)
  535. # networks in two racks have equal CIDRs
  536. self._check_routes_count(1)
  537. class TestBlockDeviceDevicesSerialization80MixIn(
  538. TestSerializerConverter80To90MixIn,
  539. BaseDeploymentSerializer
  540. ):
  541. def setUp(self):
  542. super(TestBlockDeviceDevicesSerialization80MixIn, self).setUp()
  543. self.cluster = self.env.create(
  544. release_kwargs={'version': self.env_version},
  545. cluster_kwargs={
  546. 'mode': consts.CLUSTER_MODES.ha_compact,
  547. 'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron,
  548. 'net_segment_type': consts.NEUTRON_SEGMENT_TYPES.vlan})
  549. self.cluster_db = self.db.query(models.Cluster).get(self.cluster['id'])
  550. self.cluster.extensions = ['volume_manager', 'converted_serializers']
  551. self.serializer = self.create_serializer(self.cluster_db)
  552. def test_block_device_disks(self):
  553. self.env.create_node(
  554. cluster_id=self.cluster_db.id,
  555. roles=['cinder-block-device']
  556. )
  557. self.env.create_node(
  558. cluster_id=self.cluster_db.id,
  559. roles=['controller']
  560. )
  561. objects.Cluster.prepare_for_deployment(self.cluster_db)
  562. serialized_for_astute = self.serializer.serialize(
  563. self.cluster_db, self.cluster_db.nodes)
  564. for node in serialized_for_astute:
  565. if node['uid'] == 'master':
  566. continue
  567. self.assertIn("node_volumes", node)
  568. for node_volume in node["node_volumes"]:
  569. if node_volume["id"] == "cinder-block-device":
  570. self.assertEqual(node_volume["volumes"], [])
  571. else:
  572. self.assertNotEqual(node_volume["volumes"], [])
  573. class TestSerializeInterfaceDriversData80MixIn(
  574. TestSerializerConverter80To90MixIn,
  575. TestSerializeInterfaceDriversData
  576. ):
  577. pass
  578. class TestDeploymentHASerializer80MixIn(
  579. TestSerializerConverter80To90MixIn,
  580. TestDeploymentHASerializer70
  581. ):
  582. pass