Entering Maintenance Mode for a device in C# and bug

Software-based VM-centric and flash-friendly VM storage + free version

Moderators: anton (staff), art (staff), Max (staff), Anatoly (staff)

Post Reply
zenny7100
Posts: 7
Joined: Wed Apr 10, 2019 6:06 pm

Sat Apr 13, 2019 3:14 am

Is there a way to do this in C#? I know how to do it in PS but there doesn't seem to be a method in the IDevice class to enter maintenance mode.

Also, there is a bug in the C# method GetDeviceByID - the following code doesn't work but should: d.DeviceID returns some string like "0x000001D35A748540" but attempting to find this device using that id and server.GetDeviceById() throws an exception:

IStarWindServer starWindServer1 = ... set up and connect to server
IDevice d = {some device}
starWindServer1.GetDeviceByID(d.DeviceId) => returns "device not found"
Sekkmer
Posts: 29
Joined: Thu Mar 08, 2018 12:11 pm

Sun Apr 14, 2019 8:34 pm

You have to cast your IDevice to IHADevice than you can use the SwitchMaintenanceMode function.

As for the problem, I never used the GetDeviceByID function but you can use this instead:

var device = Server.Devices.Cast<IDevice>().FirstOrDefault(d => d.DeviceId == "{your device id}");
Oleg(staff)
Staff
Posts: 568
Joined: Fri Nov 24, 2017 7:52 am

Fri Apr 19, 2019 11:15 am

Yes, GetDeviceByID was not working on the older builds.
Sekkmer, thank you for your input.
elaw
Posts: 14
Joined: Thu Jul 18, 2013 1:59 pm
Location: Bedford, MA

Fri Apr 19, 2019 1:26 pm

Hey... is documentation available online for accessing Starwind via C#?

I'd like to do something like the OP is doing... wasn't aware it is possible!
Oleg(staff)
Staff
Posts: 568
Joined: Fri Nov 24, 2017 7:52 am

Fri Apr 19, 2019 3:14 pm

Hi elaw,
Unfortunately, there is no documentation available online for accessing Starwind via C#.
Post Reply