This commit is contained in:
Alexander Gama Espinosa 2023-08-23 14:41:56 -07:00
Родитель 45aff35ce1
Коммит cbb7c9e3b6
5 изменённых файлов: 18 добавлений и 55 удалений

3
go.mod
Просмотреть файл

@ -7,7 +7,7 @@ require (
github.com/Azure/go-autorest/autorest v0.9.0
github.com/Azure/go-autorest/autorest/date v0.2.0
github.com/google/uuid v1.3.0
github.com/microsoft/moc v0.11.0-alpha.15
github.com/microsoft/moc v0.11.0-alpha.24
google.golang.org/grpc v1.54.0
k8s.io/klog v1.0.0
)
@ -24,7 +24,6 @@ replace (
github.com/Azure/go-autorest v11.1.2+incompatible => github.com/Azure/go-autorest/autorest v0.10.0
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.1.0
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
github.com/microsoft/moc => github.com/algamaes/moc v0.0.0-20230816064015-d805927665ec
github.com/miekg/dns => github.com/miekg/dns v1.1.25
golang.org/x/net => golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c
golang.org/x/sys => golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24

8
go.sum
Просмотреть файл

@ -404,8 +404,6 @@ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbt
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/algamaes/moc v0.0.0-20230816064015-d805927665ec h1:gLX3E6L0rbUe2eblMoe/DznjvXxaAlUbyUt6dbbJGuM=
github.com/algamaes/moc v0.0.0-20230816064015-d805927665ec/go.mod h1:oWva5QnxchPzA+W9v5INDHjUksw/UKJPuNHnIwEpyEw=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
@ -579,6 +577,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
github.com/microsoft/moc v0.11.0-alpha.24 h1:UYeqBWu3BwFn7XQ3bMNCFQFwm6yNAWwA1j8cz+jS950=
github.com/microsoft/moc v0.11.0-alpha.24/go.mod h1:XCARfNxCWJgQoKZGfggyj/lOF25XAxFYOuwAboxRCTc=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
@ -741,8 +741,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

Просмотреть файл

@ -1147,9 +1147,3 @@ type VirtualMachineRunCommandResponse struct {
// InstanceView - The virtual machine run command instance view.
InstanceView *VirtualMachineRunCommandInstanceView `json:"instanceView,omitempty"`
}
// VirtualMachineRepairGuestAgentResponse
type VirtualMachineRepairGuestAgentResponse struct {
Result *bool `json:"result,omitempty"`
Error *string `json:"error,omitempty"`
}

Просмотреть файл

@ -22,8 +22,8 @@ type Service interface {
Query(context.Context, string, string) (*[]compute.VirtualMachine, error)
Start(context.Context, string, string) error
Stop(context.Context, string, string) error
RepairGuestAgent(context.Context, string, string) error
RunCommand(context.Context, string, string, *compute.VirtualMachineRunCommandRequest) (*compute.VirtualMachineRunCommandResponse, error)
RepairGuestAgent(context.Context, string, string) (*compute.VirtualMachineRepairGuestAgentResponse, error)
Validate(context.Context, string, string) error
}
@ -306,7 +306,7 @@ func (c *VirtualMachineClient) RunCommand(ctx context.Context, group, vmName str
return c.internal.RunCommand(ctx, group, vmName, request)
}
func (c *VirtualMachineClient) RepairGuestAgent(ctx context.Context, group, vmName string) (response *compute.VirtualMachineRepairGuestAgentResponse, err error) {
func (c *VirtualMachineClient) RepairGuestAgent(ctx context.Context, group, vmName string) (err error) {
return c.internal.RepairGuestAgent(ctx, group, vmName)
}

Просмотреть файл

@ -137,6 +137,17 @@ func (c *client) Start(ctx context.Context, group, name string) (err error) {
return
}
// RepairGuestAgent
func (c *client) RepairGuestAgent(ctx context.Context, group, name string) (err error) {
request, err := c.getVirtualMachineOperationRequest(ctx, wssdcloudproto.ProviderAccessOperation_VirtualMachine_Repair_Guest_Agent, group, name)
if err != nil {
return
}
_, err = c.VirtualMachineAgentClient.Operate(ctx, request)
return
}
// RunCommand
func (c *client) RunCommand(ctx context.Context, group, name string, request *compute.VirtualMachineRunCommandRequest) (response *compute.VirtualMachineRunCommandResponse, err error) {
mocRequest, err := c.getVirtualMachineRunCommandRequest(ctx, group, name, request)
@ -152,21 +163,6 @@ func (c *client) RunCommand(ctx context.Context, group, name string, request *co
return
}
// RepairGuestAgent
func (c *client) RepairGuestAgent(ctx context.Context, group, name string) (response *compute.VirtualMachineRepairGuestAgentResponse, err error) {
mocRequest, err := c.getRepairGuestAgentRequest(ctx, group, name)
if err != nil {
return
}
mocResponse, err := c.VirtualMachineAgentClient.RepairGuestAgent(ctx, mocRequest)
if err != nil {
return
}
response, err = c.getRepairGuestAgentResponse(mocResponse)
return
}
// Get
func (c *client) Validate(ctx context.Context, group, name string) error {
request, err := c.getVirtualMachineRequest(wssdcloudproto.Operation_VALIDATE, group, name, nil)
@ -257,32 +253,6 @@ func (c *client) getVirtualMachineRunCommandResponse(mocResponse *wssdcloudcompu
return response, nil
}
func (c *client) getRepairGuestAgentRequest(ctx context.Context, group, name string) (mocRequest *wssdcloudcompute.VirtualMachineRepairGuestAgentRequest, err error) {
vms, err := c.get(ctx, group, name)
if err != nil {
return
}
if len(vms) != 1 {
err = errors.Wrapf(errors.InvalidInput, "Multiple Virtual Machines found in group %s with name %s", group, name)
return
}
vm := vms[0]
mocRequest = &wssdcloudcompute.VirtualMachineRepairGuestAgentRequest{
VirtualMachine: vm,
}
return
}
func (c *client) getRepairGuestAgentResponse(mocResponse *wssdcloudcompute.VirtualMachineRepairGuestAgentResponse) (*compute.VirtualMachineRepairGuestAgentResponse, error) {
response := &compute.VirtualMachineRepairGuestAgentResponse{
Result: &mocResponse.Result.Value,
Error: &mocResponse.Error,
}
return response, nil
}
func (c *client) getVirtualMachineFromResponse(response *wssdcloudcompute.VirtualMachineResponse, group string) *[]compute.VirtualMachine {
vms := []compute.VirtualMachine{}
for _, vm := range response.GetVirtualMachines() {