-
Notifications
You must be signed in to change notification settings - Fork 32
/
service_template.go
35 lines (31 loc) · 993 Bytes
/
service_template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package types
import (
"context"
"github.com/Juniper/asf/pkg/models"
"github.com/Juniper/contrail/pkg/services"
)
// CreateServiceTemplate validates domain UUID and enables domain sharing for service template.
func (sv *ContrailTypeLogicService) CreateServiceTemplate(
ctx context.Context,
request *services.CreateServiceTemplateRequest,
) (response *services.CreateServiceTemplateResponse, err error) {
svcTemplate := request.GetServiceTemplate()
err = sv.InTransactionDoer.DoInTransaction(
ctx,
func(ctx context.Context) error {
domainUUID := svcTemplate.GetParentUUID()
if domainUUID == "" {
domainUUID, err = sv.FQNameToUUID(ctx, svcTemplate.GetFQName(), svcTemplate.GetParentType())
if err != nil {
return err
}
}
err = svcTemplate.GetPerms2().EnableDomainSharing(domainUUID, models.PermsRX)
if err != nil {
return err
}
response, err = sv.BaseService.CreateServiceTemplate(ctx, request)
return err
})
return response, err
}