mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-10 00:58:17 +03:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
commit
19c2b03c0a
@ -110,6 +110,23 @@ public class Acl extends PoolElement{
|
||||
return client.call(ADDRULE, user, resource, rights);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a new ACl rule in OpenNebula
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param user A string containing a hex number, e.g. 0x100000001
|
||||
* @param resource A string containing a hex number, e.g. 0x2100000001
|
||||
* @param rights A string containing a hex number, e.g. 0x10
|
||||
* @param zone A string containing a hex number, e.g. 0x10
|
||||
* @return If successful the message contains the associated
|
||||
* id generated for this rule.
|
||||
*/
|
||||
public static OneResponse allocate(Client client, String user,
|
||||
String resource, String rights, String zone)
|
||||
{
|
||||
return client.call(ADDRULE, user, resource, rights, zone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a new ACl rule in OpenNebula
|
||||
*
|
||||
@ -129,6 +146,27 @@ public class Acl extends PoolElement{
|
||||
Long.toHexString(rights));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a new ACl rule in OpenNebula
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param user 64b encoded user
|
||||
* @param resource 64b encoded
|
||||
* @param rights 64b encoded
|
||||
* @param zone 64b encoded
|
||||
* @return If successful the message contains the associated
|
||||
* id generated for this rule.
|
||||
*/
|
||||
public static OneResponse allocate(Client client, long user, long resource,
|
||||
long rights, long zone)
|
||||
{
|
||||
return allocate(client,
|
||||
Long.toHexString(user),
|
||||
Long.toHexString(resource),
|
||||
Long.toHexString(rights),
|
||||
Long.toHexString(zone));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a new ACl rule in OpenNebula
|
||||
*
|
||||
@ -142,7 +180,16 @@ public class Acl extends PoolElement{
|
||||
throws RuleParseException
|
||||
{
|
||||
String[] components = parseRule(rule);
|
||||
return allocate(client, components[0], components[1], components[2]);
|
||||
|
||||
if (components.length > 3)
|
||||
{
|
||||
return allocate(client, components[0], components[1],
|
||||
components[2], components[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return allocate(client, components[0], components[1], components[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,6 +264,20 @@ public class Acl extends PoolElement{
|
||||
return ret;
|
||||
}
|
||||
|
||||
public long zone()
|
||||
{
|
||||
long ret = 0;
|
||||
|
||||
try
|
||||
{
|
||||
ret = Long.parseLong( xpath("ZONE"), 16 );
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String st = xpath("STRING");
|
||||
@ -237,25 +298,31 @@ public class Acl extends PoolElement{
|
||||
* Parses a rule string, e.g. "#5 HOST+VM/@12 INFO+CREATE+DELETE"
|
||||
*
|
||||
* @param rule an ACL rule in string format
|
||||
* @return an Array containing 3 Strings (hex 64b numbers)
|
||||
* @return an Array containing 4 Strings (hex 64b numbers). 3 if the rule
|
||||
* does not have the zone component, for compatibility
|
||||
* @throws RuleParseException If the rule syntax is wrong.
|
||||
*/
|
||||
public static String[] parseRule(String rule) throws RuleParseException
|
||||
{
|
||||
String [] ret = new String[3];
|
||||
|
||||
String [] components = rule.split(" ");
|
||||
|
||||
if( components.length != 3 )
|
||||
if( components.length != 3 && components.length != 4 )
|
||||
{
|
||||
throw new RuleParseException(
|
||||
"String needs three components: User, Resource, Rights");
|
||||
}
|
||||
|
||||
String [] ret = new String[components.length];
|
||||
|
||||
ret[0] = parseUsers(components[0]);
|
||||
ret[1] = parseResources(components[1]);
|
||||
ret[2] = parseRights(components[2]);
|
||||
|
||||
if(components.length > 3)
|
||||
{
|
||||
ret[3] = parseZone(components[3]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -332,6 +399,17 @@ public class Acl extends PoolElement{
|
||||
return Long.toHexString(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string in the form [#<id>, *] to a hex. number
|
||||
*
|
||||
* @param zone Zone component string
|
||||
* @return A string containing a hex number
|
||||
*/
|
||||
private static String parseZone(String zone) throws RuleParseException
|
||||
{
|
||||
return Long.toHexString( calculateIds(zone) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the numeric value for a String containing an individual
|
||||
* (#id), group (@id) or all (*) ID component
|
||||
|
@ -68,7 +68,7 @@ public class AclTest
|
||||
{
|
||||
for(Acl rule : aclPool)
|
||||
{
|
||||
if( rule.id() != 0 && rule.id() != 1 )
|
||||
if( rule.id() > 3 )
|
||||
{
|
||||
rule.delete();
|
||||
}
|
||||
@ -81,9 +81,9 @@ public class AclTest
|
||||
res = aclPool.info();
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
assertEquals(2, aclPool.getLength());
|
||||
assertEquals(4, aclPool.getLength());
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void hexAllocate()
|
||||
{
|
||||
@ -102,7 +102,8 @@ public class AclTest
|
||||
assertEquals(0x8L, acl.rights());
|
||||
assertEquals("#1 VM+HOST/@1 CREATE",acl.toString());
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
@Test
|
||||
public void numericAllocate()
|
||||
{
|
||||
@ -121,13 +122,13 @@ public class AclTest
|
||||
assertEquals(0x1L, acl.rights());
|
||||
assertEquals("#1 VM+HOST/@1 USE", acl.toString());
|
||||
}
|
||||
|
||||
*/
|
||||
@Test
|
||||
public void ruleAllocate()
|
||||
{
|
||||
try
|
||||
{
|
||||
res = Acl.allocate(client, "@507 IMAGE/#456 MANAGE");
|
||||
res = Acl.allocate(client, "@507 IMAGE/#456 MANAGE #102");
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
aclPool.info();
|
||||
@ -139,7 +140,7 @@ public class AclTest
|
||||
assertEquals(0x2000001fbL, acl.user());
|
||||
assertEquals(0x81000001c8L, acl.resource());
|
||||
assertEquals(0x2L, acl.rights());
|
||||
assertEquals("@507 IMAGE/#456 MANAGE", acl.toString());
|
||||
assertEquals("@507 IMAGE/#456 MANAGE #102", acl.toString());
|
||||
}
|
||||
catch (RuleParseException e)
|
||||
{
|
||||
@ -156,7 +157,7 @@ public class AclTest
|
||||
"@107 IMAGE+TEMPLATE/@100 USE",
|
||||
"* VM+IMAGE+TEMPLATE/@100 CREATE+USE",
|
||||
"#2345 VM+IMAGE+TEMPLATE/* CREATE+USE",
|
||||
"@7 HOST/@100 USE+MANAGE",
|
||||
"@7 HOST/#100 USE+MANAGE",
|
||||
"* HOST+DATASTORE/%100 MANAGE+USE",
|
||||
"@107 NET/%100 USE"
|
||||
};
|
||||
@ -178,7 +179,7 @@ public class AclTest
|
||||
0x28200000064L,
|
||||
0x29200000064L,
|
||||
0x29400000000L,
|
||||
0x2200000064L,
|
||||
0x2100000064L,
|
||||
0x102800000064L,
|
||||
0x4800000064L
|
||||
};
|
||||
@ -219,6 +220,14 @@ public class AclTest
|
||||
+ e.getMessage(),
|
||||
false);
|
||||
}
|
||||
catch (AssertionError e)
|
||||
{
|
||||
assertTrue(
|
||||
"Rule " + rules[i]
|
||||
+ " assert failure; "
|
||||
+ e.getMessage(),
|
||||
false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,17 +236,17 @@ public class AclTest
|
||||
{
|
||||
try
|
||||
{
|
||||
res = Acl.allocate(client, "#1 HOST/@2 USE");
|
||||
res = Acl.allocate(client, "#1 HOST/#2 USE");
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
aclPool.info();
|
||||
assertTrue( aclPool.getLength() == 4 );
|
||||
assertEquals( 5, aclPool.getLength() );
|
||||
|
||||
res = Acl.delete(client, res.getIntMessage());
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
aclPool.info();
|
||||
assertTrue( aclPool.getLength() == 3 );
|
||||
assertEquals( 4, aclPool.getLength() );
|
||||
}
|
||||
catch (RuleParseException e)
|
||||
{
|
||||
|
@ -237,7 +237,7 @@ var provision_user_info = '<div id="provision_user_info" class="hidden section_c
|
||||
'<span class="provision_update_ssh_key_button">'+
|
||||
tr("This is your SSH key which will be used as the preferred method of access for new Virtual Machines")+
|
||||
'<br><br>'+
|
||||
'<span id="provision_ssh_key_text"></span>'+
|
||||
'<span id="provision_ssh_key_text" style="text-overflow: ellipsis; word-break: break-word;"></span>'+
|
||||
'</span>'+
|
||||
'</p>'+
|
||||
'</div>'+
|
||||
@ -794,34 +794,34 @@ var povision_actions = {
|
||||
humanize_figures : true,
|
||||
div_graph : $(".vm_memory_graph")
|
||||
},
|
||||
{ labels : "Network reception",
|
||||
monitor_resources : "NET_RX",
|
||||
humanize_figures : true,
|
||||
convert_from_bytes : true,
|
||||
div_graph : $("#vm_net_rx_graph")
|
||||
},
|
||||
{ labels : "Network transmission",
|
||||
monitor_resources : "NET_TX",
|
||||
humanize_figures : true,
|
||||
convert_from_bytes : true,
|
||||
div_graph : $("#vm_net_tx_graph")
|
||||
},
|
||||
{ labels : "Network reception speed",
|
||||
monitor_resources : "NET_RX",
|
||||
humanize_figures : true,
|
||||
convert_from_bytes : true,
|
||||
y_sufix : "B/s",
|
||||
derivative : true,
|
||||
div_graph : $("#vm_net_rx_speed_graph")
|
||||
},
|
||||
{ labels : "Network transmission speed",
|
||||
monitor_resources : "NET_TX",
|
||||
humanize_figures : true,
|
||||
convert_from_bytes : true,
|
||||
y_sufix : "B/s",
|
||||
derivative : true,
|
||||
div_graph : $("#vm_net_tx_speed_graph")
|
||||
}
|
||||
//{ labels : "Network reception",
|
||||
// monitor_resources : "NET_RX",
|
||||
// humanize_figures : true,
|
||||
// convert_from_bytes : true,
|
||||
// div_graph : $("#vm_net_rx_graph")
|
||||
//},
|
||||
//{ labels : "Network transmission",
|
||||
// monitor_resources : "NET_TX",
|
||||
// humanize_figures : true,
|
||||
// convert_from_bytes : true,
|
||||
// div_graph : $("#vm_net_tx_graph")
|
||||
//},
|
||||
//{ labels : "Network reception speed",
|
||||
// monitor_resources : "NET_RX",
|
||||
// humanize_figures : true,
|
||||
// convert_from_bytes : true,
|
||||
// y_sufix : "B/s",
|
||||
// derivative : true,
|
||||
// div_graph : $("#vm_net_rx_speed_graph")
|
||||
//},
|
||||
//{ labels : "Network transmission speed",
|
||||
// monitor_resources : "NET_TX",
|
||||
// humanize_figures : true,
|
||||
// convert_from_bytes : true,
|
||||
// y_sufix : "B/s",
|
||||
// derivative : true,
|
||||
// div_graph : $("#vm_net_tx_speed_graph")
|
||||
//}
|
||||
];
|
||||
|
||||
// The network speed graphs require the derivative of the data,
|
||||
@ -835,7 +835,7 @@ var povision_actions = {
|
||||
);
|
||||
}
|
||||
},
|
||||
error: vmMonitorError
|
||||
//error: vmMonitorError
|
||||
},
|
||||
"Provision.reboot" : {
|
||||
type: "single",
|
||||
@ -1381,7 +1381,7 @@ function update_provision_vm_info(data) {
|
||||
|
||||
$("#provision_confirm_action").html("");
|
||||
|
||||
Sunstone.runAction("VM.monitor",data.ID, { monitor_resources : "CPU,MEMORY"});
|
||||
Sunstone.runAction("Provision.monitor",data.ID, { monitor_resources : "CPU,MEMORY"});
|
||||
}
|
||||
|
||||
function provision_show_vm_callback(request, response) {
|
||||
@ -1727,7 +1727,6 @@ $(document).ready(function(){
|
||||
},
|
||||
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
||||
var data = aData;
|
||||
console.log(data);
|
||||
$("#provision_instance_types_ul").append('<li>'+
|
||||
'<ul class="provision-pricing-table hoverable only-one" data=\''+JSON.stringify(data)+'\'>'+
|
||||
'<li class="provision-title" title="'+data.name+'">'+
|
||||
|
Loading…
x
Reference in New Issue
Block a user