Skip to content

Commit 12942c3

Browse files
hvedatiHarika Vedati
andauthored
vm connect changes (#328)
Co-authored-by: Harika Vedati <havedati@microsoft.com>
1 parent 74700cd commit 12942c3

File tree

5 files changed

+94
-3
lines changed

5 files changed

+94
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/Azure/go-autorest/autorest/date v0.3.0
99
github.com/google/go-cmp v0.6.0
1010
github.com/google/uuid v1.6.0
11-
github.com/microsoft/moc v0.30.4
11+
github.com/microsoft/moc v0.31.1
1212
google.golang.org/grpc v1.72.0
1313
k8s.io/klog v1.0.0
1414
sigs.k8s.io/controller-runtime v0.20.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V
122122
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
123123
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
124124
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
125-
github.com/microsoft/moc v0.30.4 h1:CdP494TaHqhBrwn12ojBAqy5UvgHdNXWQYOz3l1dtjg=
126-
github.com/microsoft/moc v0.30.4/go.mod h1:OZ1rc2/qs9AVRKCLfwY0N8R+ZXJlVz5UyWYS5vNH4m0=
125+
github.com/microsoft/moc v0.31.1 h1:JtmQAKErI4DfDAZHbSF8U1sVg7sRue6PzL3PIZICre4=
126+
github.com/microsoft/moc v0.31.1/go.mod h1:OZ1rc2/qs9AVRKCLfwY0N8R+ZXJlVz5UyWYS5vNH4m0=
127127
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
128128
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
129129
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=

services/compute/compute.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,3 +1313,15 @@ type ZoneConfiguration struct {
13131313
// Strict Placement
13141314
StrictPlacement *bool `json:"strictPlacement,omitempty"`
13151315
}
1316+
1317+
type VirtualMachineHyperVVmId struct {
1318+
HyperVVmId *string `json:"hyperVVmId ,omitempty"`
1319+
}
1320+
1321+
type VirtualMachineHostNodeName struct {
1322+
HostNodeName *string `json:"hostNodeName ,omitempty"`
1323+
}
1324+
1325+
type VirtualMachineHostNodeIpAddress struct {
1326+
HostNodeIpAddress *string `json:"hostNodeIpAddress ,omitempty"`
1327+
}

services/compute/virtualmachine/client.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ type Service interface {
3030
Validate(context.Context, string, string) error
3131
Precheck(context.Context, string, []*compute.VirtualMachine) (bool, error)
3232
RemoveIsoDisk(context.Context, string, string) error
33+
GetHyperVVmId(context.Context, string, string) (*compute.VirtualMachineHyperVVmId, error)
34+
GetHostNodeName(context.Context, string, string) (*compute.VirtualMachineHostNodeName, error)
35+
GetHostNodeIpAddress(context.Context, string, string) (*compute.VirtualMachineHostNodeIpAddress, error)
3336
}
3437

3538
type VirtualMachineClient struct {
@@ -396,3 +399,15 @@ func (c *VirtualMachineClient) Validate(ctx context.Context, group, name string)
396399
func (c *VirtualMachineClient) Precheck(ctx context.Context, group string, vms []*compute.VirtualMachine) (bool, error) {
397400
return c.internal.Precheck(ctx, group, vms)
398401
}
402+
403+
func (c *VirtualMachineClient) GetHyperVVmId(ctx context.Context, group string, name string) (*compute.VirtualMachineHyperVVmId, error) {
404+
return c.internal.GetHyperVVmId(ctx, group, name)
405+
}
406+
407+
func (c *VirtualMachineClient) GetHostNodeName(ctx context.Context, group string, name string) (*compute.VirtualMachineHostNodeName, error) {
408+
return c.internal.GetHostNodeName(ctx, group, name)
409+
}
410+
411+
func (c *VirtualMachineClient) GetHostNodeIpAddress(ctx context.Context, group string, name string) (*compute.VirtualMachineHostNodeIpAddress, error) {
412+
return c.internal.GetHostNodeIpAddress(ctx, group, name)
413+
}

services/compute/virtualmachine/wssd.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,67 @@ func (c *client) virtualMachineValidations(opType wssdcloudproto.Operation, vmss
410410
}
411411
return nil
412412
}
413+
414+
func (c *client) GetHyperVVmId(ctx context.Context, group, name string) (*compute.VirtualMachineHyperVVmId, error) {
415+
vm, err := c.get(ctx, group, name)
416+
if err != nil {
417+
return nil, err
418+
}
419+
420+
if len(vm) == 0 {
421+
return nil, fmt.Errorf("Virtual machine [%s] not found", name)
422+
}
423+
mocResponse, err := c.VirtualMachineAgentClient.GetHyperVVmId(ctx, vm[0])
424+
if err != nil {
425+
return nil, err
426+
}
427+
428+
response := &compute.VirtualMachineHyperVVmId{
429+
HyperVVmId: &mocResponse.HyperVVmId,
430+
}
431+
432+
return response, nil
433+
}
434+
435+
func (c *client) GetHostNodeName(ctx context.Context, group, name string) (*compute.VirtualMachineHostNodeName, error) {
436+
vm, err := c.get(ctx, group, name)
437+
if err != nil {
438+
return nil, err
439+
}
440+
441+
if len(vm) == 0 {
442+
return nil, fmt.Errorf("Virtual machine [%s] not found", name)
443+
}
444+
mocResponse, err := c.VirtualMachineAgentClient.GetHostNodeName(ctx, vm[0])
445+
if err != nil {
446+
return nil, err
447+
}
448+
449+
response := &compute.VirtualMachineHostNodeName{
450+
HostNodeName: &mocResponse.HostNodeName,
451+
}
452+
453+
return response, nil
454+
}
455+
456+
func (c *client) GetHostNodeIpAddress(ctx context.Context, group, name string) (*compute.VirtualMachineHostNodeIpAddress, error) {
457+
458+
vm, err := c.get(ctx, group, name)
459+
if err != nil {
460+
return nil, err
461+
}
462+
463+
if len(vm) == 0 {
464+
return nil, fmt.Errorf("Virtual machine [%s] not found", name)
465+
}
466+
mocResponse, err := c.VirtualMachineAgentClient.GetHostNodeIpAddress(ctx, vm[0])
467+
if err != nil {
468+
return nil, err
469+
}
470+
471+
response := &compute.VirtualMachineHostNodeIpAddress{
472+
HostNodeIpAddress: &mocResponse.HostNodeIpAddress,
473+
}
474+
475+
return response, nil
476+
}

0 commit comments

Comments
 (0)