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 = bc.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('Invalid hosting device template definition '
                              'in configuration file for template = %s',
                              hdt_uuid)
def _create_hosting_device_templates_from_config ( self ) : hdt_dict = config . get_specific_config ( 'cisco_hosting_device_template' ) attr_info = ciscohostingdevicemanager . RESOURCE_ATTRIBUTE_MAP [ ciscohostingdevicemanager . DEVICE_TEMPLATES ] adm_context = bc . context . get_admin_context ( ) for hdt_uuid , kv_dict in hdt_dict . items ( ) : 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 ( 'Invalid hosting device template definition ' 'in configuration file for template = %s' , hdt_uuid )
To be called late during plugin initialization so that any hosting
        device templates defined in the config file is properly inserted in
        the DB.