Skip to content

Commit

Permalink
Merge pull request cloud-barista#1348 from ish-hcc/azure_list_iid
Browse files Browse the repository at this point in the history
[Azure] Implement VM's ListIID()
  • Loading branch information
powerkimhub authored Sep 28, 2024
2 parents ab69c0d + 3e709af commit 535acec
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,8 @@ func testVMHandlerListPrint() {
cblogger.Info("7. SuspendVM()")
cblogger.Info("8. ResumeVM()")
cblogger.Info("9. TerminateVM()")
cblogger.Info("10. Exit")
cblogger.Info("10. ListIID()")
cblogger.Info("11. Exit")
}

func testVMHandler(config Config) {
Expand Down Expand Up @@ -890,6 +891,14 @@ Loop:
}
cblogger.Info("Finish TerminateVM()")
case 10:
cblogger.Info("Start ListIID() ...")
if listIID, err := vmHandler.ListIID(); err != nil {
cblogger.Error(err)
} else {
spew.Dump(listIID)
}
cblogger.Info("Finish ListIID()")
case 11:
cblogger.Info("Exit")
break Loop
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1850,6 +1850,38 @@ func windowUserIdCheck(userId string) (bool, error) {
}

func (vmHandler *AzureVMHandler) ListIID() ([]*irs.IID, error) {
cblogger.Info("Cloud driver: called ListIID()!!")
return nil, errors.New("Does not support ListIID() yet!!")
hiscallInfo := GetCallLogScheme(vmHandler.Region, call.VM, VM, "ListIID()")

start := call.Start()

var iidList []*irs.IID

pager := vmHandler.Client.NewListPager(vmHandler.Region.Region, nil)

for pager.More() {
page, err := pager.NextPage(vmHandler.Ctx)
if err != nil {
getErr := errors.New(fmt.Sprintf("Failed to List VM. err = %s", err))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return make([]*irs.IID, 0), err
}

for _, vm := range page.Value {
var iid irs.IID

if vm.ID != nil {
iid.SystemId = *vm.ID
}
if vm.Name != nil {
iid.NameId = *vm.Name
}

iidList = append(iidList, &iid)
}
}

LoggingInfo(hiscallInfo, start)

return iidList, nil
}

0 comments on commit 535acec

Please sign in to comment.