def test_check_backup_edge_pools_with_vdr(self): self.edge_manager.edge_pool_dicts = self.vdr_edge_pool_dicts pool_edges = (self._create_edge_pools(1, 2, 3, 4, 5) + self._create_edge_pools( 1, 2, 3, 4, 5, size=nsxv_constants.COMPACT) + self._create_edge_pools( 1, 2, 3, 4, 5, edge_type=nsxv_constants.VDR_EDGE)) self._populate_vcns_router_binding(pool_edges) self.edge_manager._check_backup_edge_pools() router_bindings = nsxv_db.get_nsxv_router_bindings(self.ctx.session) expect_vdr_bindings = self._create_backup_router_bindings( 1, 2, 3, 4, 5, error_status=plugin_const.PENDING_DELETE, error_at_backend_status=plugin_const.PENDING_DELETE, edge_type=nsxv_constants.VDR_EDGE) vdr_bindings = [ binding for binding in router_bindings if (binding['appliance_size'] == nsxv_constants.LARGE and binding['edge_type'] == nsxv_constants.VDR_EDGE)] self._verify_router_bindings(expect_vdr_bindings, vdr_bindings) service_bindings = [ binding for binding in router_bindings if binding['edge_type'] == nsxv_constants.SERVICE_EDGE] for binding in service_bindings: self.assertEqual(plugin_const.PENDING_DELETE, binding['status'])
def test_check_backup_edge_pools_with_empty_conf(self): pool_edges = (self._create_edge_pools(1, 2, 3, 4, 5) + self._create_edge_pools( 1, 2, 3, 4, 5, size=nsxv_constants.COMPACT) + self._create_edge_pools( 1, 2, 3, 4, 5, edge_type=nsxv_constants.VDR_EDGE)) self._populate_vcns_router_binding(pool_edges) self.edge_manager._check_backup_edge_pools() router_bindings = nsxv_db.get_nsxv_router_bindings(self.ctx.session) for binding in router_bindings: self.assertEqual(plugin_const.PENDING_DELETE, binding['status'])
def test_check_backup_edge_pools_with_default(self): self.edge_manager.edge_pool_dicts = self.default_edge_pool_dicts pool_edges = ( self._create_edge_pools(1, 2, 3, 4, 5) + self._create_edge_pools(1, 2, 3, 4, 5, size=nsxv_constants.COMPACT) + self._create_edge_pools(1, 2, 3, 4, 5, edge_type=nsxv_constants.VDR_EDGE) ) self._populate_vcns_router_binding(pool_edges) self.edge_manager._check_backup_edge_pools() router_bindings = nsxv_db.get_nsxv_router_bindings(self.ctx.session) expect_large_bindings = self._create_backup_router_bindings( 1, 2, 3, 4, 5, error_status=plugin_const.PENDING_DELETE, error_at_backend_status=plugin_const.PENDING_DELETE ) large_bindings = [ binding for binding in router_bindings if ( binding["appliance_size"] == nsxv_constants.LARGE and binding["edge_type"] == nsxv_constants.SERVICE_EDGE ) ] self._verify_router_bindings(expect_large_bindings, large_bindings) expect_compact_bindings = self._create_backup_router_bindings( 1, 2, 3, 4, 5, error_status=plugin_const.PENDING_DELETE, error_at_backend_status=plugin_const.PENDING_DELETE, size=nsxv_constants.COMPACT, ) compact_bindings = [ binding for binding in router_bindings if ( binding["appliance_size"] == nsxv_constants.COMPACT and binding["edge_type"] == nsxv_constants.SERVICE_EDGE ) ] self._verify_router_bindings(expect_compact_bindings, compact_bindings) vdr_bindings = [ binding for binding in router_bindings if (binding["appliance_size"] == nsxv_constants.LARGE and binding["edge_type"] == nsxv_constants.VDR_EDGE) ] for binding in vdr_bindings: self.assertEqual(plugin_const.PENDING_DELETE, binding["status"])
def test_check_backup_edge_pool_with_max(self): appliance_size = nsxv_constants.LARGE edge_type = nsxv_constants.SERVICE_EDGE pool_edges = self._create_edge_pools(1, 2, 3, 4, 5) + self._create_edge_pools( 1, 2, 3, 4, 5, size=nsxv_constants.COMPACT ) self._populate_vcns_router_binding(pool_edges) expect_pool_bindings = self._create_backup_router_bindings( 1, 2, 3, 4, 5, error_status=plugin_const.ERROR, error_at_backend_status=plugin_const.PENDING_DELETE ) self.edge_manager._check_backup_edge_pool(0, 3, appliance_size=appliance_size, edge_type=edge_type) router_bindings = [ binding for binding in nsxv_db.get_nsxv_router_bindings(self.ctx.session) if (binding["appliance_size"] == appliance_size and binding["edge_type"] == edge_type) ] self._verify_router_bindings(expect_pool_bindings, router_bindings)
def test_get_available_router_bindings(self): appliance_size = nsxv_constants.LARGE edge_type = nsxv_constants.SERVICE_EDGE pool_edges = self._create_edge_pools(1, 2, 3, 0, 5) + self._create_edge_pools( 1, 2, 3, 0, 5, size=nsxv_constants.COMPACT ) self._populate_vcns_router_binding(pool_edges) expect_backup_bindings = self._create_backup_router_bindings(1, 2, 3, 0, 5, error_status=plugin_const.ERROR) binding = self.edge_manager._get_available_router_binding( self.ctx, appliance_size=appliance_size, edge_type=edge_type ) router_bindings = [ binding_db for binding_db in nsxv_db.get_nsxv_router_bindings(self.ctx.session) if (binding_db["appliance_size"] == appliance_size and binding_db["edge_type"] == edge_type) ] self._verify_router_bindings(expect_backup_bindings, router_bindings) edge_id = EDGE_AVAIL + appliance_size + "-" + edge_type + "-edge-" + str(0) self.assertEqual(edge_id, binding["edge_id"])
def test_check_backup_edge_pool_with_min(self): appliance_size = nsxv_constants.LARGE edge_type = nsxv_constants.SERVICE_EDGE pool_edges = self._create_edge_pools(1, 2, 3, 0, 5) + self._create_edge_pools( 1, 2, 3, 4, 5, size=nsxv_constants.COMPACT ) self._populate_vcns_router_binding(pool_edges) edge_utils.eventlet = mock.Mock() edge_utils.eventlet.spawn_n.return_value = None self.edge_manager._check_backup_edge_pool(5, 10, appliance_size=appliance_size, edge_type=edge_type) router_bindings = [ binding for binding in nsxv_db.get_nsxv_router_bindings(self.ctx.session) if binding["edge_id"] is None and binding["status"] == plugin_const.PENDING_CREATE ] binding_ids = [bind.router_id for bind in router_bindings] self.assertEqual(2, len(router_bindings)) edge_utils.eventlet.spawn_n.assert_called_with(mock.ANY, mock.ANY, binding_ids, appliance_size, edge_type)