Add baremetalmachine.GetByComputerName function.
This commit is contained in:
Родитель
0b990b432c
Коммит
9eae2aea47
|
@ -5,6 +5,7 @@ package baremetalmachine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/microsoft/moc-sdk-for-go/services/compute"
|
"github.com/microsoft/moc-sdk-for-go/services/compute"
|
||||||
"github.com/microsoft/moc/pkg/auth"
|
"github.com/microsoft/moc/pkg/auth"
|
||||||
|
@ -50,3 +51,15 @@ func (c *BareMetalMachineClient) Delete(ctx context.Context, group string, name
|
||||||
func (c *BareMetalMachineClient) Query(ctx context.Context, group, query string) (*[]compute.BareMetalMachine, error) {
|
func (c *BareMetalMachineClient) Query(ctx context.Context, group, query string) (*[]compute.BareMetalMachine, error) {
|
||||||
return c.internal.Query(ctx, group, query)
|
return c.internal.Query(ctx, group, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the Virtual Machine by querying for the specified computer name
|
||||||
|
func (c *BareMetalMachineClient) GetByComputerName(ctx context.Context, group string, computerName string) (*[]compute.BareMetalMachine, error) {
|
||||||
|
query := fmt.Sprintf("[?baremetalmachineproperties.osprofile.computername=='%s']", computerName)
|
||||||
|
|
||||||
|
bmms, err := c.Query(ctx, group, query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return bmms, nil
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче