From: peusterm Date: Wed, 25 Apr 2018 13:36:15 +0000 (+0200) Subject: Fix: hackfest_1 deployment using OSM LB returned X-Git-Tag: v4.0.0~2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=7c16ebcfd5af529961175fb53b5788c276e5ae86;p=osm%2Fvim-emu.git Fix: hackfest_1 deployment using OSM LB returned and network not found error. This fix ensures that some default networks are always available for OSM. Change-Id: I0ae791d64c527ea451b406452619d04e6f3b98af Signed-off-by: peusterm --- diff --git a/src/emuvim/api/openstack/compute.py b/src/emuvim/api/openstack/compute.py index 7ba52f1..b812953 100755 --- a/src/emuvim/api/openstack/compute.py +++ b/src/emuvim/api/openstack/compute.py @@ -607,7 +607,10 @@ class OpenstackCompute(object): for net in self.nets.values(): if net.name == name_or_id: return net - + LOG.warning("Could not find net '{}' in {} or {}" + .format(name_or_id, + self.nets.keys(), + [n.name for n in self.nets.values()])) return None def create_network(self, name, stack_operation=False): diff --git a/src/emuvim/api/openstack/manage.py b/src/emuvim/api/openstack/manage.py index f2aad33..5405e78 100755 --- a/src/emuvim/api/openstack/manage.py +++ b/src/emuvim/api/openstack/manage.py @@ -107,17 +107,18 @@ class OpenstackManage(object): def net(self, value): if self._net is None: self._net = value + # create default networks self.init_floating_network() self._net = value - def init_floating_network(self): + def init_floating_network(self, name="default"): """ Initialize the floating network component for the emulator. Will not do anything if already initialized. """ if self.net is not None and self.floating_switch is None: # create a floating network - fn = self.floating_network = Net("default") + fn = self.floating_network = Net(name) fn.id = str(uuid.uuid4()) fn.set_cidr(self.floating_netmask) diff --git a/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py index 7386e63..6f6d3dc 100755 --- a/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py +++ b/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py @@ -44,6 +44,10 @@ class NeutronDummyApi(BaseOpenstackDummy): super(NeutronDummyApi, self).__init__(ip, port) self.compute = compute + # create default networks (OSM usually assumes to have these pre-configured) + self.compute.create_network("mgmt") + self.compute.create_network("mgmtnet") + self.api.add_resource(NeutronListAPIVersions, "/") self.api.add_resource(NeutronShowAPIv2Details, "/v2.0") self.api.add_resource(NeutronListNetworks, "/v2.0/networks.json", "/v2.0/networks", @@ -224,14 +228,19 @@ class NeutronListNetworks(Resource): :rtype: :class:`flask.response` """ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__)) + # LOG.debug("ARGS: {}".format(request.args)) try: if request.args.get('name'): tmp_network = NeutronShowNetwork(self.api) - return tmp_network.get_network(request.args.get('name'), True) + response = tmp_network.get_network(request.args.get('name'), True) + LOG.debug("{} RESPONSE (1): {}".format(self.__class__.__name__, response)) + return response id_list = request.args.getlist('id') if len(id_list) == 1: tmp_network = NeutronShowNetwork(self.api) - return tmp_network.get_network(request.args.get('id'), True) + response = tmp_network.get_network(request.args.get('id'), True) + LOG.debug("{} RESPONSE (2): {}".format(self.__class__.__name__, response)) + return response network_list = list() network_dict = dict() @@ -249,7 +258,7 @@ class NeutronListNetworks(Resource): network_list.append(tmp_network_dict) network_dict["networks"] = network_list - + LOG.debug("{} RESPONSE (3): {}".format(self.__class__.__name__, network_dict)) return Response(json.dumps(network_dict), status=200, mimetype='application/json') except Exception as ex: