def _get_network_interface_map_from_config(cls):
     dni_dict = config.get_specific_config(
         'HwVLANTrunkingPlugDriver'.lower())
     temp = {}
     for hd_uuid, kv_dict in dni_dict.items():
         # ensure hd_uuid is properly formatted
         hd_uuid = config.uuidify(hd_uuid)
         if hd_uuid not in temp:
             temp[hd_uuid] = {'internal': {}, 'external': {}}
         for k, v in kv_dict.items():
             try:
                 entry = k[:k.index('_')]
                 net_spec, interface = v.split(':')
                 for net_id in net_spec.split(','):
                     temp[hd_uuid][entry][net_id] = interface
             except (ValueError, KeyError):
                 with excutils.save_and_reraise_exception() as ctx:
                     ctx.reraise = False
                     LOG.error(
                         _LE('Invalid network to interface mapping '
                             '%(key)s, %(value)s in configuration '
                             'file for device = %(dev)s'), {
                                 'key': k,
                                 'value': v,
                                 'dev': hd_uuid
                             })
     cls._device_network_interface_map = temp
Ejemplo n.º 2
0
    def _create_hosting_device_templates_from_config(self):
        """To be called late during plugin initialization so that any hosting
        device templates defined in the config file is properly inserted in
        the DB.
        """
        hdt_dict = config.get_specific_config('cisco_hosting_device_template')
        attr_info = ciscohostingdevicemanager.RESOURCE_ATTRIBUTE_MAP[
            ciscohostingdevicemanager.DEVICE_TEMPLATES]
        adm_context = neutron_context.get_admin_context()

        for hdt_uuid, kv_dict in hdt_dict.items():
            # ensure hdt_uuid is properly formatted
            hdt_uuid = config.uuidify(hdt_uuid)
            try:
                self.get_hosting_device_template(adm_context, hdt_uuid)
                is_create = False
            except ciscohostingdevicemanager.HostingDeviceTemplateNotFound:
                is_create = True
            kv_dict['id'] = hdt_uuid
            kv_dict['tenant_id'] = self.l3_tenant_id()
            config.verify_resource_dict(kv_dict, True, attr_info)
            hdt = {ciscohostingdevicemanager.DEVICE_TEMPLATE: kv_dict}
            try:
                if is_create:
                    self.create_hosting_device_template(adm_context, hdt)
                else:
                    self.update_hosting_device_template(adm_context,
                                                        kv_dict['id'], hdt)
            except n_exc.NeutronException:
                with excutils.save_and_reraise_exception():
                    LOG.error(_LE('Invalid hosting device template definition '
                                  'in configuration file for template = %s'),
                              hdt_uuid)
Ejemplo n.º 3
0
 def _obtain_hosting_device_credentials_from_config(self):
     """Obtains credentials from config file and stores them in memory.
     To be called before hosting device templates defined in the config file
     are created.
     """
     cred_dict = config.get_specific_config(
         'cisco_hosting_device_credential')
     attr_info = {
         'name': {'allow_post': True, 'allow_put': True,
                  'validate': {'type:string': None}, 'is_visible': True,
                  'default': ''},
         'description': {'allow_post': True, 'allow_put': True,
                         'validate': {'type:string': None},
                         'is_visible': True, 'default': ''},
         'user_name': {'allow_post': True, 'allow_put': True,
                       'validate': {'type:string': None},
                       'is_visible': True, 'default': ''},
         'password': {'allow_post': True, 'allow_put': True,
                      'validate': {'type:string': None},
                      'is_visible': True, 'default': ''},
         'type': {'allow_post': True, 'allow_put': True,
                  'validate': {'type:string': None}, 'is_visible': True,
                  'default': ''}}
     self._credentials = {}
     for cred_uuid, kv_dict in cred_dict.items():
         # ensure cred_uuid is properly formatted
         cred_uuid = config.uuidify(cred_uuid)
         config.verify_resource_dict(kv_dict, True, attr_info)
         self._credentials[cred_uuid] = kv_dict
 def _get_network_interface_map_from_config(cls):
     dni_dict = config.get_specific_config("HwVLANTrunkingPlugDriver".lower())
     temp = {}
     for hd_uuid, kv_dict in dni_dict.items():
         # ensure hd_uuid is properly formatted
         hd_uuid = config.uuidify(hd_uuid)
         if hd_uuid not in temp:
             temp[hd_uuid] = {"internal": {}, "external": {}}
         for k, v in kv_dict.items():
             try:
                 entry = k[: k.index("_")]
                 net_spec, interface = v.split(":")
                 for net_id in net_spec.split(","):
                     temp[hd_uuid][entry][net_id] = interface
             except (ValueError, KeyError):
                 with excutils.save_and_reraise_exception() as ctx:
                     ctx.reraise = False
                     LOG.error(
                         _LE(
                             "Invalid network to interface mapping "
                             "%(key)s, %(value)s in configuration "
                             "file for device = %(dev)s"
                         ),
                         {"key": k, "value": v, "dev": hd_uuid},
                     )
     cls._device_network_interface_map = temp
 def _get_network_interface_map_from_config(cls):
     dni_dict = config.get_specific_config(
         'HwVLANTrunkingPlugDriver'.lower())
     temp = {}
     for hd_uuid, kv_dict in dni_dict.items():
         # ensure hd_uuid is properly formatted
         hd_uuid = config.uuidify(hd_uuid)
         if hd_uuid not in temp:
             temp[hd_uuid] = {'internal': {}, 'external': {}}
         for k, v in kv_dict.items():
             try:
                 entry = k[:k.index('_')]
                 net_spec, interface = v.split(':')
                 for net_id in net_spec.split(','):
                     temp[hd_uuid][entry][net_id] = interface
             except (ValueError, KeyError):
                 with excutils.save_and_reraise_exception() as ctx:
                     ctx.reraise = False
                     LOG.error(_LE('Invalid network to interface mapping '
                                   '%(key)s, %(value)s in configuration '
                                   'file for device = %(dev)s'),
                               {'key': k, 'value': v, 'dev': hd_uuid})
     cls._device_network_interface_map = temp
Ejemplo n.º 6
0
    def _create_hosting_devices_from_config(self):
        """To be called late during plugin initialization so that any hosting
        device specified in the config file is properly inserted in the DB.
        """
        hd_dict = config.get_specific_config('cisco_hosting_device')
        attr_info = ciscohostingdevicemanager.RESOURCE_ATTRIBUTE_MAP[
            ciscohostingdevicemanager.DEVICES]
        adm_context = neutron_context.get_admin_context()

        for hd_uuid, kv_dict in hd_dict.items():
            # ensure hd_uuid is properly formatted
            hd_uuid = config.uuidify(hd_uuid)
            try:
                old_hd = self.get_hosting_device(adm_context, hd_uuid)
                is_create = False
            except ciscohostingdevicemanager.HostingDeviceNotFound:
                old_hd = {}
                is_create = True
            kv_dict['id'] = hd_uuid
            kv_dict['tenant_id'] = self.l3_tenant_id()
            # make sure we keep using same config agent if it has been assigned
            kv_dict['cfg_agent_id'] = old_hd.get('cfg_agent_id')
            # make sure we keep using management port if it exists
            kv_dict['management_port_id'] = old_hd.get('management_port_id')
            config.verify_resource_dict(kv_dict, True, attr_info)
            hd = {ciscohostingdevicemanager.DEVICE: kv_dict}
            try:
                if is_create:
                    self.create_hosting_device(adm_context, hd)
                else:
                    self.update_hosting_device(adm_context, kv_dict['id'], hd)
            except n_exc.NeutronException:
                with excutils.save_and_reraise_exception():
                    LOG.error(_LE('Invalid hosting device specification in '
                                  'configuration file for device = %s'),
                              hd_uuid)