* better semantics for link-region command

* actually parse name for new link-region command
viewer-2-initial-appearance
Jonathan Freedman 2010-10-30 22:51:52 -04:00
parent 95a0ea78f9
commit 0a56cfbfd5
1 changed files with 21 additions and 21 deletions

View File

@ -128,8 +128,8 @@ namespace OpenSim.Services.GridService
if (MainConsole.Instance != null) if (MainConsole.Instance != null)
{ {
MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]", "Link a HyperGrid Region", RunCommand); MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region", "link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]", "Link a HyperGrid Region", RunCommand);
MainConsole.Instance.Commands.AddCommand("hypergrid", false, "legacy-link-region", MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region",
"legacy-link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]", "link-region <Xloc> <Yloc> <RegionIP> <RegionPort> [<RemoteRegionName>]",
"Link a hypergrid region (deprecated)", RunCommand); "Link a hypergrid region (deprecated)", RunCommand);
MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region", MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region",
"unlink-region <local name>", "unlink-region <local name>",
@ -206,14 +206,14 @@ namespace OpenSim.Services.GridService
return null; return null;
} }
public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string externalRegionName, uint externalPort, string externalHostName, UUID ownerID, out GridRegion regInfo, out string reason) public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, UUID ownerID, out GridRegion regInfo, out string reason)
{ {
return TryCreateLink(scopeID, xloc, yloc, externalRegionName, externalPort, externalHostName, null, ownerID, out regInfo, out reason); return TryCreateLink(scopeID, xloc, yloc, remoteRegionName, externalPort, externalHostName, null, ownerID, out regInfo, out reason);
} }
public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string externalRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason) public bool TryCreateLink(UUID scopeID, int xloc, int yloc, string remoteRegionName, uint externalPort, string externalHostName, string serverURI, UUID ownerID, out GridRegion regInfo, out string reason)
{ {
m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, externalRegionName, xloc, yloc); m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0}:{1}:{2}, in {3}-{4}", externalHostName, externalPort, remoteRegionName, xloc, yloc);
reason = string.Empty; reason = string.Empty;
regInfo = new GridRegion(); regInfo = new GridRegion();
@ -228,6 +228,9 @@ namespace OpenSim.Services.GridService
if ( serverURI != null) if ( serverURI != null)
regInfo.ServerURI = serverURI; regInfo.ServerURI = serverURI;
if ( remoteRegionName != string.Empty )
regInfo.RegionName = remoteRegionName;
regInfo.RegionLocX = xloc; regInfo.RegionLocX = xloc;
regInfo.RegionLocY = yloc; regInfo.RegionLocY = yloc;
regInfo.ScopeID = scopeID; regInfo.ScopeID = scopeID;
@ -326,13 +329,6 @@ namespace OpenSim.Services.GridService
} }
} }
//foreach (GridRegion r in m_HyperlinkRegions.Values)
//{
// m_log.DebugFormat("XXX Comparing {0}:{1} with {2}:{3}", host, port, r.ExternalHostName, r.HttpPort);
// if (host.Equals(r.ExternalHostName) && (port == r.HttpPort))
// regInfo = r;
//}
if (regInfo != null) if (regInfo != null)
{ {
RemoveHyperlinkRegion(regInfo.RegionID); RemoveHyperlinkRegion(regInfo.RegionID);
@ -500,7 +496,7 @@ namespace OpenSim.Services.GridService
} }
return; return;
} }
else if (command.Equals("legacy-link-region")) else if (command.Equals("link-region"))
{ {
if (cmdparams.Length < 3) if (cmdparams.Length < 3)
{ {
@ -515,7 +511,11 @@ namespace OpenSim.Services.GridService
return; return;
} }
if (cmdparams[2].Contains(":")) //this should be the prefererred way of setting up hg links now
if ( cmdparams[2].StartsWith("http") && ( cmdparams.Length >= 3 && cmdparams.Length <= 5 )) {
RunLinkRegionCommand(cmdparams);
}
else if (cmdparams[2].Contains(":"))
{ {
// New format // New format
int xloc, yloc; int xloc, yloc;
@ -578,7 +578,7 @@ namespace OpenSim.Services.GridService
xloc = xloc * (int)Constants.RegionSize; xloc = xloc * (int)Constants.RegionSize;
yloc = yloc * (int)Constants.RegionSize; yloc = yloc * (int)Constants.RegionSize;
string reason = string.Empty; string reason = string.Empty;
if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
{ {
if (cmdparams.Length >= 5) if (cmdparams.Length >= 5)
{ {
@ -592,7 +592,7 @@ namespace OpenSim.Services.GridService
} }
else if (command.Equals("unlink-region")) else if (command.Equals("unlink-region"))
{ {
if (cmdparams.Length < 1) if (cmdparams.Length < 1 || cmdparams.Length > 1)
{ {
UnlinkRegionCmdUsage(); UnlinkRegionCmdUsage();
return; return;
@ -680,7 +680,7 @@ namespace OpenSim.Services.GridService
xloc = xloc * (int)Constants.RegionSize; xloc = xloc * (int)Constants.RegionSize;
yloc = yloc * (int)Constants.RegionSize; yloc = yloc * (int)Constants.RegionSize;
string reason = string.Empty; string reason = string.Empty;
if (TryCreateLink(UUID.Zero, xloc, yloc, "", externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
{ {
regInfo.RegionName = config.GetString("localName", ""); regInfo.RegionName = config.GetString("localName", "");
} }
@ -692,14 +692,14 @@ namespace OpenSim.Services.GridService
private void LinkRegionCmdUsage() private void LinkRegionCmdUsage()
{ {
MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]"); MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <ServerURI> [<RemoteRegionName>]");
MainConsole.Instance.Output("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]"); MainConsole.Instance.Output("Usage (deprecated): link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
MainConsole.Instance.Output("Usage (deprecated): link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
MainConsole.Instance.Output("Usage: link-region <URI_of_xml> [<exclude>]"); MainConsole.Instance.Output("Usage: link-region <URI_of_xml> [<exclude>]");
} }
private void UnlinkRegionCmdUsage() private void UnlinkRegionCmdUsage()
{ {
MainConsole.Instance.Output("Usage: unlink-region <HostName>:<HttpPort>");
MainConsole.Instance.Output("Usage: unlink-region <LocalName>"); MainConsole.Instance.Output("Usage: unlink-region <LocalName>");
} }