@@ -312,6 +312,22 @@ func (r *IronicNeutronAgentReconciler) findObjectsForSrc(ctx context.Context, sr
312312 return requests
313313}
314314
315+ func (r * IronicNeutronAgentReconciler ) getTransportURL (
316+ ctx context.Context ,
317+ h * helper.Helper ,
318+ instance * ironicv1.IronicNeutronAgent ,
319+ ) (string , error ) {
320+ transportURLSecret , _ , err := secret .GetSecret (ctx , h , instance .Status .TransportURLSecret , instance .Namespace )
321+ if err != nil {
322+ return "" , err
323+ }
324+ transportURL , ok := transportURLSecret .Data ["transport_url" ]
325+ if ! ok {
326+ return "" , fmt .Errorf ("transport_url %w Transport Secret" , util .ErrNotFound )
327+ }
328+ return string (transportURL ), nil
329+ }
330+
315331func (r * IronicNeutronAgentReconciler ) reconcileTransportURL (
316332 ctx context.Context ,
317333 instance * ironicv1.IronicNeutronAgent ,
@@ -435,17 +451,13 @@ func (r *IronicNeutronAgentReconciler) reconcileConfigMapsAndSecrets(
435451 // all cert input checks out so report InputReady
436452 instance .Status .Conditions .MarkTrue (condition .TLSInputReadyCondition , condition .InputReadyMessage )
437453
438- //
439- // Create ConfigMaps required as input for the Service and calculate an overall hash of hashes
454+ // Create Secrets required as input for the Service and calculate an overall hash of hashes
440455 //
441456
442- // create custom Configmap for IronicNeutronAgent input
443- // - %-scripts configmap holding scripts to e.g. bootstrap the service
444- // - %-config configmap holding minimal neutron config required to get the
445- // service up, user can add additional files to be added to the service
446- // - parameters which has passwords gets added from the OpenStack secret via the init container
447457 //
448- err = r .generateServiceConfigMaps (ctx , helper , instance , & configMapVars )
458+ // create Secret required for ironicneutronagent input. It contains minimal ironicneutronagent config required
459+ // to get the service up, user can add additional files to be added to the service.
460+ err = r .generateServiceSecrets (ctx , helper , instance , & configMapVars )
449461 if err != nil {
450462 instance .Status .Conditions .Set (condition .FalseCondition (
451463 condition .ServiceConfigReadyCondition ,
@@ -455,7 +467,8 @@ func (r *IronicNeutronAgentReconciler) reconcileConfigMapsAndSecrets(
455467 err .Error ()))
456468 return ctrl.Result {}, "" , err
457469 }
458- // Create ConfigMaps - end
470+
471+ // Create ConfigMaps and Secrets - end
459472
460473 // create hash over all the different input resources to identify if any those changed
461474 // and a restart/recreate is required.
@@ -476,7 +489,6 @@ func (r *IronicNeutronAgentReconciler) reconcileConfigMapsAndSecrets(
476489 instance .Status .Conditions .MarkTrue (
477490 condition .ServiceConfigReadyCondition ,
478491 condition .ServiceConfigReadyMessage )
479- // Create ConfigMaps and Secrets - end
480492
481493 return ctrl.Result {}, inputHash , nil
482494}
@@ -712,24 +724,25 @@ func (r *IronicNeutronAgentReconciler) reconcileUpgrade(
712724 return ctrl.Result {}, nil
713725}
714726
715- // generateServiceConfigMaps - create custom configmap to hold service-specific config
716- func (r * IronicNeutronAgentReconciler ) generateServiceConfigMaps (
727+ // generateServiceSecrets - create secrets which service configuration
728+ func (r * IronicNeutronAgentReconciler ) generateServiceSecrets (
717729 ctx context.Context ,
718730 h * helper.Helper ,
719731 instance * ironicv1.IronicNeutronAgent ,
720732 envVars * map [string ]env.Setter ,
721733) error {
722- //
723- // create custom Configmap for ironic-neutron-agnet-specific config input
724- // - %-config-data configmap holding custom config for the service config
725- //
726-
727- cmLabels := labels .GetLabels (instance , labels .GetGroupLabel (ironic .ServiceName ), map [string ]string {})
734+ // Create/update secrets from templates
735+ cmLabels := labels .GetLabels (instance , labels .GetGroupLabel (ironicneutronagent .ServiceName ), map [string ]string {})
728736
729737 // customData hold any customization for the service.
730- // custom.conf is going to be merged into /etc/ironic/ironic.conf
731- // TODO: make sure custom.conf can not be overwritten
732- customData := map [string ]string {common .CustomServiceConfigFileName : instance .Spec .CustomServiceConfig }
738+ // 02-ironic_neutron_agent-custom.conf is going to /etc/neutron/neutron.conf.d
739+ // 01-ironic_neutron_agent.conf is going to /etc/neutron/neutron.conf.d such that it gets loaded before custom one
740+ customData := map [string ]string {
741+ "02-ironic_neutron_agent-custom.conf" : instance .Spec .CustomServiceConfig ,
742+ }
743+ for key , data := range instance .Spec .DefaultConfigOverwrite {
744+ customData [key ] = data
745+ }
733746
734747 keystoneAPI , err := keystonev1 .GetKeystoneAPI (ctx , h , instance .Namespace , map [string ]string {})
735748 if err != nil {
@@ -744,35 +757,40 @@ func (r *IronicNeutronAgentReconciler) generateServiceConfigMaps(
744757 return err
745758 }
746759
760+ transportURL , err := r .getTransportURL (ctx , h , instance )
761+ if err != nil {
762+ return err
763+ }
764+
765+ ospSecret , _ , err := secret .GetSecret (ctx , h , instance .Spec .Secret , instance .Namespace )
766+ if err != nil {
767+ return err
768+ }
769+
747770 templateParameters := make (map [string ]interface {})
748771 templateParameters ["ServiceUser" ] = instance .Spec .ServiceUser
749772 templateParameters ["KeystoneInternalURL" ] = keystoneInternalURL
750773 templateParameters ["KeystonePublicURL" ] = keystonePublicURL
774+ templateParameters ["TransportURL" ] = transportURL
775+
776+ // Other OpenStack services
777+ servicePassword := string (ospSecret .Data [instance .Spec .PasswordSelectors .Service ])
778+ templateParameters ["ServicePassword" ] = servicePassword
779+ templateParameters ["keystone_authtoken" ] = servicePassword
780+ templateParameters ["service_catalog" ] = servicePassword
781+ templateParameters ["ironic" ] = servicePassword
751782
752783 cms := []util.Template {
753- // Scripts ConfigMap
754- {
755- Name : fmt .Sprintf ("%s-scripts" , instance .Name ),
756- Namespace : instance .Namespace ,
757- Type : util .TemplateTypeScripts ,
758- InstanceType : instance .Kind ,
759- AdditionalTemplate : map [string ]string {
760- "common.sh" : "/common/bin/common.sh" ,
761- },
762- Labels : cmLabels ,
763- },
764- // Custom ConfigMap
765784 {
766785 Name : fmt .Sprintf ("%s-config-data" , instance .Name ),
767786 Namespace : instance .Namespace ,
768787 Type : util .TemplateTypeConfig ,
769788 InstanceType : instance .Kind ,
770789 CustomData : customData ,
771- ConfigOptions : templateParameters ,
772790 Labels : cmLabels ,
791+ ConfigOptions : templateParameters ,
773792 },
774793 }
775-
776794 return secret .EnsureSecrets (ctx , h , instance , cms , envVars )
777795}
778796
0 commit comments