aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/utils/misc/src/main/java/org/onlab/util/ItemNotFoundException.java
blob: 01440abfae790191633be9263e44a76421d5e268 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright 2014 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onlab.util;

/**
 * Represents condition where an item is not found or not available.
 */
public class ItemNotFoundException extends RuntimeException {

    /**
     * Creates a new exception with no message.
     */
    public ItemNotFoundException() {
    }

    /**
     * Creates a new exception with the supplied message.
     * @param message error message
     */
    public ItemNotFoundException(String message) {
        super(message);
    }

    /**
     * Creates a new exception with the supplied message and cause.
     * @param message error message
     * @param cause cause of the error
     */
    public ItemNotFoundException(String message, Throwable cause) {
        super(message, cause);
    }

}
ER_SAME_HOST_SPLIT_VNF', 'description': ''' Client and server are on the same host. The VNFs are split between hosts Round Robin. ''' }, { 'id': 'CLIENT_SERVER_SAME_HOST', 'description': ''' Client instance and server instance are on the same compute host. All VNFs are on a different host. ''' } ] DEFAULT_TOPO = { 'id': 'DEFAULT', 'description': ''' The default topology created by nova scheduler ''' } WORKING_TOPOLOGIES = ['CLIENT_SERVER_VNF_SAME_HOST', 'CLIENT_VNF_SAME_HOST', 'SERVER_VNF_SAME_HOST'] def get_seed(): ''' Get a seed based on the day of the week to choose which topology to test NOTE: There's sure a smarter way to do this Probably with the Jenkins job id ''' # We only add the topologies which are working cutoff = len(WORKING_TOPOLOGIES) - 1 seed = datetime.datetime.today().weekday() if seed > cutoff: seed = random.randrange(cutoff) return seed def topology(vnf_names, os_sfc_util, av_zones=None, seed=None): ''' Get the topology for client, server and vnfs. The topology is returned as a dict in the form { 'client': <availability_zone>, 'server': <availability_zone>, 'vnf1': <availability_zone>, 'vnf2': <availability_zone> ... } Use seed=None to get the default topology created by nova-scheduler ''' if av_zones is None: av_zones = os_sfc_util.get_av_zones() if len(av_zones) < 2 or seed is None: # fall back to nova availability zone topology_assignment = { 'id': DEFAULT_TOPO['id'], 'description': DEFAULT_TOPO['description'], 'client': 'nova', 'server': 'nova' } for vnf in vnf_names: topology_assignment[vnf] = 'nova' return topology_assignment topo = TOPOLOGIES[seed] topology_assigment = { 'id': topo['id'], 'description': topo['description'] } if topo['id'] == 'CLIENT_SERVER_VNF_SAME_HOST': topology_assigment['client'] = av_zones[0] topology_assigment['server'] = av_zones[0] for vnf in vnf_names: topology_assigment[vnf] = av_zones[0] elif topo['id'] == 'CLIENT_VNF_SAME_HOST': topology_assigment['client'] = av_zones[0] topology_assigment['server'] = av_zones[1] for vnf in vnf_names: topology_assigment[vnf] = av_zones[0] elif topo['id'] == 'CLIENT_SERVER_SAME_HOST': topology_assigment['client'] = av_zones[0] topology_assigment['server'] = av_zones[0] for vnf in vnf_names: topology_assigment[vnf] = av_zones[1] elif topo['id'] == 'SERVER_VNF_SAME_HOST': topology_assigment['client'] = av_zones[1] topology_assigment['server'] = av_zones[0] for vnf in vnf_names: topology_assigment[vnf] = av_zones[0] elif topo['id'] == 'CLIENT_SERVER_SAME_HOST_SPLIT_VNF': topology_assigment['client'] = av_zones[0] topology_assigment['server'] = av_zones[0] for idx, vnf in enumerate(vnf_names): topology_assigment[vnf] = av_zones[idx % 2] elif topo['id'] == 'CLIENT_SERVER_DIFFERENT_HOST_SPLIT_VNF': topology_assigment['client'] = av_zones[0] topology_assigment['server'] = av_zones[1] for idx, vnf in enumerate(vnf_names): topology_assigment[vnf] = av_zones[idx % 2] logger.info("Creating enpoint and VNF topology on the compute hosts") logger.info(topo['description']) return topology_assigment