@@ -21,12 +21,13 @@ import (
2121
2222 . "github.com/onsi/gomega" //revive:disable:dot-imports
2323
24+ "maps"
25+
2426 batchv1 "k8s.io/api/batch/v1"
2527 corev1 "k8s.io/api/core/v1"
2628 k8s_errors "k8s.io/apimachinery/pkg/api/errors"
2729 "k8s.io/apimachinery/pkg/types"
2830 "k8s.io/utils/ptr"
29- "maps"
3031 "sigs.k8s.io/controller-runtime/pkg/client"
3132
3233 memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1"
@@ -164,6 +165,30 @@ func CreateNovaWithCell0(name types.NamespacedName) client.Object {
164165 return th .CreateUnstructured (rawNova )
165166}
166167
168+ func CreateNovaWithNotificationBus (
169+ name types.NamespacedName ,
170+ notificationsBus NotificationsBusNames ) client.Object {
171+
172+ rawNova := map [string ]interface {}{
173+ "apiVersion" : "nova.openstack.org/v1beta1" ,
174+ "kind" : "Nova" ,
175+ "metadata" : map [string ]interface {}{
176+ "name" : name .Name ,
177+ "namespace" : name .Namespace ,
178+ },
179+ "spec" : map [string ]interface {}{
180+ "secret" : SecretName ,
181+ "apiDatabaseAccount" : novaNames .APIMariaDBDatabaseAccount .Name ,
182+ // I think we don't need cell0.transport-url here
183+ // but its in CR.
184+ "apiMessageBusInstance" : cell0 .TransportURLName .Name ,
185+ "notificationsBusInstance" : notificationsBus .TransportURLName .Name ,
186+ },
187+ }
188+
189+ return th .CreateUnstructured (rawNova )
190+ }
191+
167192func GetNova (name types.NamespacedName ) * novav1.Nova {
168193 instance := & novav1.Nova {}
169194 Eventually (func (g Gomega ) {
@@ -228,6 +253,20 @@ func CreateNovaMessageBusSecret(cell CellNames) *corev1.Secret {
228253 return s
229254}
230255
256+ func CreateNovaNotificationBusSecret (notificationsBus NotificationsBusNames ) * corev1.Secret {
257+ logger .Info ("" , "rabbit-notification" , notificationsBus )
258+ s := th .CreateSecret (
259+ types.NamespacedName {
260+ Namespace : novaNames .NovaName .Namespace ,
261+ Name : fmt .Sprintf ("%s-secret" , notificationsBus .TransportURLName .Name )},
262+ map [string ][]byte {
263+ "transport_url" : []byte (fmt .Sprintf ("rabbit://%s/fake" , novaNames .notificationsBusName )),
264+ },
265+ )
266+ logger .Info ("Secret created" , "name" , s .Name )
267+ return s
268+ }
269+
231270func GetDefaultNovaCellSpec (cell CellNames ) map [string ]interface {} {
232271 return map [string ]interface {}{
233272 "cellName" : cell .CellName ,
@@ -485,6 +524,47 @@ func GetCellNames(novaName types.NamespacedName, cell string) CellNames {
485524 return c
486525}
487526
527+ type NotificationsBusNames struct {
528+ notificationsBusName string
529+ notificationsBusCRName types.NamespacedName
530+ TransportURLName types.NamespacedName
531+
532+ // MariaDBDatabaseName types.NamespacedName
533+ // MariaDBAccountName types.NamespacedName
534+ // APIDatabaseAccountName types.NamespacedName
535+ // ConductorName types.NamespacedName
536+ // DBSyncJobName types.NamespacedName
537+ // ConductorConfigDataName types.NamespacedName
538+ // ConductorScriptDataName types.NamespacedName
539+ // ConductorStatefulSetName types.NamespacedName
540+ // CellMappingJobName types.NamespacedName
541+ // CellDeleteJobName types.NamespacedName
542+ // MetadataName types.NamespacedName
543+ // MetadataStatefulSetName types.NamespacedName
544+ // MetadataConfigDataName types.NamespacedName
545+ // MetadataNeutronConfigDataName types.NamespacedName
546+ // NoVNCProxyName types.NamespacedName
547+ // NoVNCProxyStatefulSetName types.NamespacedName
548+ // CellNoVNCProxyNameConfigDataName types.NamespacedName
549+ // InternalCellSecretName types.NamespacedName
550+ // InternalAPINetworkNADName types.NamespacedName
551+ // ComputeConfigSecretName types.NamespacedName
552+ // NovaComputeName types.NamespacedName
553+ // NovaComputeStatefulSetName types.NamespacedName
554+ // NovaComputeConfigDataName types.NamespacedName
555+ // HostDiscoveryJobName types.NamespacedName
556+ // DBPurgeCronJobName types.NamespacedName
557+ }
558+
559+ func GetNotificationsBusNames (novaName types.NamespacedName ) NotificationsBusNames {
560+ busName := "rabbitmq-broadcaster"
561+ return NotificationsBusNames {
562+ notificationsBusName : busName ,
563+ notificationsBusCRName : types.NamespacedName {Namespace : novaName .Namespace , Name : busName },
564+ TransportURLName : types.NamespacedName {Namespace : novaName .Namespace , Name : busName },
565+ }
566+ }
567+
488568type NovaNames struct {
489569 Namespace string
490570 NovaName types.NamespacedName
@@ -519,6 +599,7 @@ type NovaNames struct {
519599 MemcachedNamespace types.NamespacedName
520600 Cells map [string ]CellNames
521601 NovaTopologies []types.NamespacedName
602+ notificationsBusName types.NamespacedName
522603}
523604
524605func GetNovaNames (novaName types.NamespacedName , cellNames []string ) NovaNames {
0 commit comments