mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-10 13:57:22 +03:00
Merge branch 'feature-407rm'
This commit is contained in:
commit
b6ff150f5e
@ -32,6 +32,7 @@ public class Host extends PoolElement{
|
||||
private static final String INFO = METHOD_PREFIX + "info";
|
||||
private static final String DELETE = METHOD_PREFIX + "delete";
|
||||
private static final String ENABLE = METHOD_PREFIX + "enable";
|
||||
private static final String UPDATE = METHOD_PREFIX + "update";
|
||||
|
||||
private static final String[] HOST_STATES =
|
||||
{"INIT", "MONITORING", "MONITORED", "ERROR", "DISABLED"};
|
||||
@ -122,7 +123,19 @@ public class Host extends PoolElement{
|
||||
{
|
||||
return client.call(ENABLE, id, enable);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replaces the template contents.
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param id The image id of the target host we want to modify.
|
||||
* @param new_template New template contents
|
||||
* @return If successful the message contains the host id.
|
||||
*/
|
||||
public static OneResponse update(Client client, int id, String new_template)
|
||||
{
|
||||
return client.call(UPDATE, id, new_template);
|
||||
}
|
||||
|
||||
// =================================
|
||||
// Instanced object XML-RPC methods
|
||||
@ -181,6 +194,17 @@ public class Host extends PoolElement{
|
||||
return enable(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the template contents.
|
||||
*
|
||||
* @param new_template New template contents
|
||||
* @return If successful the message contains the host id.
|
||||
*/
|
||||
public OneResponse update(String new_template)
|
||||
{
|
||||
return update(client, id, new_template);
|
||||
}
|
||||
|
||||
// =================================
|
||||
// Helpers
|
||||
// =================================
|
||||
|
@ -99,7 +99,7 @@ public class HostTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void update()
|
||||
public void info()
|
||||
{
|
||||
res = host.info();
|
||||
assertTrue( !res.isError() );
|
||||
@ -152,6 +152,30 @@ public class HostTest
|
||||
|
||||
assertTrue( !found );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void update()
|
||||
{
|
||||
res = host.info();
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
assertTrue( host.xpath("TEMPLATE/ATT1").equals( "" ) );
|
||||
assertTrue( host.xpath("TEMPLATE/ATT2").equals( "" ) );
|
||||
|
||||
String new_template = "ATT2 = NEW_VAL\n" +
|
||||
"ATT3 = VAL3";
|
||||
|
||||
res = host.update(new_template);
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
|
||||
res = host.info();
|
||||
assertTrue( !res.isError() );
|
||||
assertTrue( host.xpath("TEMPLATE/ATT1").equals( "" ) );
|
||||
assertTrue( host.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) );
|
||||
assertTrue( host.xpath("TEMPLATE/ATT3").equals( "VAL3" ) );
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void attributes()
|
||||
|
@ -25,7 +25,8 @@ module OpenNebula
|
||||
:info => "host.info",
|
||||
:allocate => "host.allocate",
|
||||
:delete => "host.delete",
|
||||
:enable => "host.enable"
|
||||
:enable => "host.enable",
|
||||
:update => "host.update"
|
||||
}
|
||||
|
||||
HOST_STATES=%w{INIT MONITORING MONITORED ERROR DISABLED}
|
||||
@ -102,6 +103,13 @@ module OpenNebula
|
||||
set_enabled(false)
|
||||
end
|
||||
|
||||
# Replaces the template contents
|
||||
#
|
||||
# +new_template+ New template contents
|
||||
def update(new_template)
|
||||
super(HOST_METHODS[:update], new_template)
|
||||
end
|
||||
|
||||
#######################################################################
|
||||
# Helpers to get Host information
|
||||
#######################################################################
|
||||
|
Loading…
x
Reference in New Issue
Block a user