Hello,
You can use following code:
HostService hostService = sysService.hostsService().hostService(hostId);
// Enable PM if not enabled:
hostService.update()
.host(
host()
.powerManagement(
powerManagement().enabled(true)
)
)
.send();
// Add first agent:
hostService.fenceAgentsService().add()
.agent(
agent()
.address("1.2.3.4")
.username("root")
.password("123456")
.type("ipmilan")
.order(0)
)
.send();
// Add second agent:
hostService.fenceAgentsService().add()
.agent(
agent()
.address("1.2.3.5")
.username("root")
.password("123456")
.type("ipmilan")
.order(1)
)
.send();
On 30/09/2019 13:56, scott.fitzgerald(a)oracle.com wrote:
Hi,
I am currently trying to enable Power Management on a host. I have created a
PowerManagementBuilder object, with an AgentBuilder. However, I am getting the error
.Error: Fault reason is "Operation Failed". Fault detail is "[Cannot edit
Host. Power Management is enabled for Host but no Agent type selected.]". HTTP
response code is "400". HTTP response message is "Bad Request"
sysService.hostsService().hostService(HostUtils.getHostObjectFromName(sysService,
vdsmHostName).id()).update().host(host().powerManagement(powerManagementBuilder.build())).send();
Am I missing a step? Or could someone post the snippet of building an Agent and
PowerManagement object so I can check against what I'm doing (below).
TIA
PowerManagementBuilder powerManagementBuilder = new PowerManagementBuilder();
AgentBuilder agentBuilder = new AgentBuilder();
agentBuilder.address(address);
agentBuilder.concurrent(true);
agentBuilder.host(host);
agentBuilder.id("newAgent");
agentBuilder.name("newAgent");
agentBuilder.username("test");
agentBuilder.type("apc");
agentBuilder.port(22);
agentBuilder.password("xxx");
sysService.hostsService().hostService(host.update().host(host().agents(agentBuilder.build())).send();
powerManagementBuilder.address(address);
powerManagementBuilder.agents(agentBuilder.build());
powerManagementBuilder.automaticPmEnabled(true);
powerManagementBuilder.enabled(true);
powerManagementBuilder.password("xxx");
powerManagementBuilder.type("apc");
powerManagementBuilder.username("test");
sysService.hostsService().hostService(host).update().host(host().powerManagement(powerManagementBuilder.build())).send();
_______________________________________________
Devel mailing list -- devel(a)ovirt.org
To unsubscribe send an email to devel-leave(a)ovirt.org
Privacy Statement:
https://www.ovirt.org/site/privacy-policy/
oVirt Code of Conduct:
https://www.ovirt.org/community/about/community-guidelines/
List Archives:
https://lists.ovirt.org/archives/list/devel@ovirt.org/message/IS7GNQNBP4T...