Skip to content

Conversation

@jocardeMSFT
Copy link
Contributor

@jocardeMSFT jocardeMSFT commented Feb 14, 2024

Adding ability to call static methods on Wmi Classes using literal parameters in line with pattern of Wmi Instances

// both are SWbemObjects: https://docs.microsoft.com/en-us/windows/win32/wmisdk/swbemobject
}

func (c *WmiClass) InvokeMethodWithLiteralParams(methodName string, params ...interface{}) ([]interface{}, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are we planning to use this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use it to create cluster group sets, before we didn't have a way to invoke static methods on wmi classes.

https://github.com/jocardeMSFT/moc-pkg/blob/13ffa1b226223a15f1eff1dfa64bb64695eff408/pkg/failovercluster/fc_avset_windows.go#L90C2-L90C183

Copy link
Member

@JocelynBerrendonner JocelynBerrendonner Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, how different is this from the unimplemented InvokeMethod call that is right above? (line 282)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words, let's just name this function "InvokeMethod"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the method above takes a methodParams []string argument, this definition takes effectively an array of interfaces.

(one of the params on the call we invoke this is actually a string[] itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hesitated to replace the signature as technically the original InvokeMethod is a public interface (residing in a pkg subdir with capital name). But can just replace if you think there is no build dependency anywhere on it (obviously there is no functional dependency as it is not implemented)

Copy link
Contributor Author

@jocardeMSFT jocardeMSFT Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced call, please resolve this comment if you are satisfied @JocelynBerrendonner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good.

@jocardeMSFT jocardeMSFT changed the title added InvokeMethodWithLiteralParams on WmiClass added InvokeMethod on WmiClass Feb 26, 2024
Copy link
Member

@JocelynBerrendonner JocelynBerrendonner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jocardeMSFT jocardeMSFT merged commit e89cd1c into microsoft:master Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants