Skip to content

Commit

Permalink
FTD Onboarding Verification Tests (#46)
Browse files Browse the repository at this point in the history
Co-authored-by: Siddhu Warrier <[email protected]>
  • Loading branch information
weilueluo and siddhuwarrier authored Sep 13, 2023
1 parent 7727004 commit 240f5a4
Show file tree
Hide file tree
Showing 13 changed files with 723 additions and 98 deletions.
3 changes: 3 additions & 0 deletions client/device/cloudfmc/fmcconfig/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func UntilTaskStatusSuccess(ctx context.Context, client http.Client, readInp Rea
func UntilCreateDeviceRecordSuccess(ctx context.Context, client http.Client, createDeviceRecordInput CreateDeviceRecordInput, output *CreateDeviceRecordOutput) retry.Func {
return func() (bool, error) {
createDeviceOutp, err := CreateDeviceRecord(ctx, client, createDeviceRecordInput)
if err != nil {
return false, err
}
*output = *createDeviceOutp
if err != nil {
return false, err
Expand Down
28 changes: 27 additions & 1 deletion client/device/cloudftd/cloudftdonboarding/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/CiscoDevnet/terraform-provider-cdo/go-client/device/cloudftd"
"github.com/CiscoDevnet/terraform-provider-cdo/go-client/internal/http"
"github.com/CiscoDevnet/terraform-provider-cdo/go-client/internal/retry"
"github.com/CiscoDevnet/terraform-provider-cdo/go-client/model/ftd/license"
"github.com/CiscoDevnet/terraform-provider-cdo/go-client/user"
"time"
)
Expand Down Expand Up @@ -71,13 +72,18 @@ func Create(ctx context.Context, client http.Client, createInp CreateInput) (*Cr
if err != nil {
return nil, err
}
// 3.1.5 handle license
licenseCaps, err := license.DeserializeAllFromCdo(readFtdOutp.Metadata.LicenseCaps)
if err != nil {
return nil, err
}
// 3.2 create ftd device
createDeviceInp := fmcconfig.NewCreateDeviceRecordInputBuilder().
Type("Device").
NatId(readFtdOutp.Metadata.NatID).
Name(readFtdOutp.Name).
AccessPolicyUid(readFtdOutp.Metadata.AccessPolicyUid).
LicenseCaps(readFtdOutp.Metadata.LicenseCaps).
LicenseCaps(&licenseCaps).
PerformanceTier(readFtdOutp.Metadata.PerformanceTier).
RegKey(readFtdOutp.Metadata.RegKey).
FmcDomainUid(fmcDomainUid).
Expand Down Expand Up @@ -117,6 +123,26 @@ func Create(ctx context.Context, client http.Client, createInp CreateInput) (*Cr
if err != nil {
return nil, err
}
// 4.3 wait until state machine done
err = retry.Do(
cloudftd.UntilSpecificStateDone(
ctx,
client,
cloudftd.NewReadSpecificInputBuilder().
Uid(ftdSpecificOutp.SpecificUid).
Build(),
),
retry.NewOptionsBuilder().
Retries(-1).
Delay(1*time.Second).
Timeout(20*time.Minute). // usually done in less than 5 minutes because we already registered in FTDc
Logger(client.Logger).
EarlyExitOnError(false).
Build(),
)
if err != nil {
return nil, err
}

return &createOutp, nil
}
Loading

0 comments on commit 240f5a4

Please sign in to comment.