Commit ac5f7c9b authored by Matt Strum's avatar Matt Strum Committed by Gary Wong

Updated google maps package, SliceCredential call, added notice to user who...

Updated google maps package, SliceCredential call, added notice to user who hasnt followed directions on setting up the client, and other minor things
parent 90003d25
......@@ -6,12 +6,17 @@
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import protogeni.Util;
]]>
</mx:Script>
<mx:Label text="Displays resources from ProtoGENI" fontSize="12"/>
<mx:LinkButton label="Setup information">
<mx:click>Util.showSetup();</mx:click>
</mx:LinkButton>
<mx:HRule/>
<mx:Label text="Special thanks to" fontWeight="bold"/>
<mx:Label text="Special thanks to" fontWeight="bold" fontStyle="italic"/>
<mx:HBox width="100%" horizontalAlign="center">
<mx:Label text="Fatcow (CCA3 Icons)"/>
<mx:LinkButton label="Website">
......
......@@ -15,11 +15,17 @@
package protogeni
{
import flash.external.ExternalInterface;
import flash.net.*;
import mx.collections.ArrayCollection;
public class Util
{
public static function showSetup():void
{
navigateToURL(new URLRequest("https://www.protogeni.net/trac/protogeni/wiki/FlashClientSetup"), "_blank");
}
public static function makeUrn(authority : String,
type : String,
name : String) : String
......
......@@ -14,9 +14,10 @@
package protogeni.communication
{
import flash.events.ErrorEvent;
import com.mattism.http.xmlrpc.MethodFault;
import flash.events.ErrorEvent;
public class CommunicationUtil
{
// Namespaces
......
......@@ -22,6 +22,7 @@
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.utils.Base64Decoder;
import protogeni.Util;
......@@ -29,7 +30,8 @@
import protogeni.display.DisplayUtil;
import protogeni.resources.ComponentManager;
import protogeni.resources.Slice;
import protogeni.resources.Sliver;
import protogeni.resources.Sliver;
import protogeni.resources.SliverCollection;
// Handles all the XML-RPC calls
public class ProtogeniRpcHandler
......@@ -82,10 +84,33 @@
var old:Slice = Main.protogeniHandler.CurrentUser.slices.getByUrn(slice.urn);
if(old != null && old.hasAllocatedResources())
{
// Update
var newSlivers:SliverCollection = new SliverCollection();
var deleteSlivers:SliverCollection = new SliverCollection();
var updateSlivers:SliverCollection = slice.slivers.clone();
for each(var s:Sliver in old.slivers)
{
if(slice.slivers.getByCm(s.componentManager) == null)
deleteSlivers.addItem(s);
}
for each(s in slice.slivers)
{
if(old.slivers.getByCm(s.componentManager) == null)
{
newSlivers.addItem(s);
updateSlivers.removeItemAt(updateSlivers.getItemIndex(s));
}
}
Main.protogeniHandler.CurrentUser.slices.addOrReplace(slice);
for each(var sliver:Sliver in slice.slivers)
// Create
for each(sliver in newSlivers)
pushRequest(new RequestSliverCreate(sliver));
// Update
for each(var sliver:Sliver in updateSlivers)
pushRequest(new RequestSliverUpdate(sliver));
// Delete
for each(sliver in deleteSlivers)
pushRequest(new RequestSliverDelete(sliver));
} else {
// Create
Main.protogeniHandler.CurrentUser.slices.addOrReplace(slice);
......@@ -226,6 +251,21 @@
tryNext();
}
if(msg.search("#2048") > -1 || msg.search("#2032") > -1)
{
if(Main.protogeniHandler.CurrentUser.credential == null || Main.protogeniHandler.CurrentUser.credential.length == 0)
{
Alert.show("It appears that you may have never run this program before. In order to run correctly, you will need to follow the steps at https://www.protogeni.net/trac/protogeni/wiki/FlashClientSetup. Would you like to visit now?", "Set up", Alert.YES | Alert.NO, Main.Pgmap(),
function runSetup(e:CloseEvent):void
{
if(e.detail == Alert.YES)
{
Util.showSetup();
}
});
}
}
}
private function complete(node:Request, code : Number, response : Object) : void
......
......@@ -24,7 +24,7 @@ package protogeni.communication
super("SliceCredential", "Getting the slice credential for " + s.hrn, CommunicationUtil.getCredential, true);
slice = s;
op.addField("credential", Main.protogeniHandler.CurrentUser.credential);
op.addField("uuid", slice.uuid);
op.addField("urn", slice.urn);
op.addField("type", "Slice");
op.setUrl("https://boss.emulab.net:443/protogeni/xmlrpc");
}
......
......@@ -33,7 +33,7 @@ package protogeni.communication
if (code == CommunicationUtil.GENIRESPONSE_SUCCESS)
{
sliver.ticket = new XML(response.value);
return new RequestTicketRedeem(sliver);
return new RequestTicketRedeem(sliver);
}
else
{
......
......@@ -125,6 +125,10 @@
[Embed(source="../../../images/control_play_blue.png")]
public static var playIcon:Class;
[Bindable]
[Embed(source="../../../images/control_repeat_blue.png")]
public static var repeatIcon:Class;
[Bindable]
[Embed(source="../../../images/delete.png")]
public static var deleteIcon:Class;
......
......@@ -21,11 +21,14 @@
public function Load(cluster:ArrayCollection):void
{
var nodeCount:int = 0;
var coords:Array = new Array();
for each(var ng:PhysicalNodeGroup in cluster)
{
addNodeGroup(ng);
nodeCount += ng.collection.length;
coords.push(new LatLng(ng.latitude, ng.longitude));
}
setZoomButton(ProtogeniMapHandler.getBounds(coords));
clusterLabel.text = nodeCount + " Nodes in " + cluster.length + " Groups";
}
......
......@@ -4,6 +4,7 @@
preinitialize="mappreinit()"
mapevent_mappreinitialize="onMapPreinitialize(event)"
mapevent_mapready="onMapReady(event)"
sensor="false"
key="ABQIAAAAJfmFhYY_qvxp3r-UM7Zc6hRvSZn5G9iDjkMHpAGYHc8v1OnErBT5Vzf3wT7WhxaP7ouXIub2R00Wxg">
<mx:Script>
<![CDATA[
......
......@@ -55,6 +55,28 @@ package protogeni.display
public var userResourcesOnly:Boolean = false;
public var selectedSlice:Slice = null;
public static function getBounds(a:Array):LatLngBounds
{
var s:Number = (a[0] as LatLng).lat();
var n:Number = (a[0] as LatLng).lat();
var w:Number = (a[0] as LatLng).lng();
var e:Number = (a[0] as LatLng).lng();
for each(var ll:LatLng in a)
{
if(ll.lat() < s)
s = ll.lat();
else if(ll.lat() > n)
n = ll.lat();
if(ll.lng() < w)
w = ll.lng();
if(ll.lng() > e)
e = ll.lng();
}
return new LatLngBounds(new LatLng(s,w), new LatLng(n,e));
}
public function zoomToPhysicalNode(n:PhysicalNode):void
{
map.panTo(new LatLng(n.GetLatitude(), n.GetLongitude()));
......
......@@ -197,7 +197,7 @@
// Remove links
while(sn.links.length > 0)
sn.links[0].removeLink()
sn.links[0].removeLink();
// Remove nodes and slivers
for each(var s:Sliver in sn.node.slivers)
......
......@@ -236,13 +236,13 @@
</display:SliceCanvas>
</mx:HDividedBox>
<mx:ControlBar>
<display:ImageButton id="refreshButton" toolTip="Refresh slivers" width="16" height="16" click="Main.protogeniHandler.rpcHandler.refreshSlice(sliceCanvas.slice);" source="{DisplayUtil.refreshIcon}"/>
<display:ImageButton id="createButton" toolTip="Create slivers" width="16" height="16" click="Main.protogeniHandler.rpcHandler.submitSlice(sliceCanvas.slice);" source="{DisplayUtil.acceptIcon}"/>
<mx:Button id="createButton" toolTip="Create slivers" label="Create" click="Main.protogeniHandler.rpcHandler.submitSlice(sliceCanvas.slice);"/>
<display:ImageButton id="deleteButton" toolTip="Delete slivers" width="16" height="16" click="Main.protogeniHandler.rpcHandler.deleteSlice(sliceCanvas.slice);" source="{DisplayUtil.deleteIcon}"/>
<display:ImageButton id="refreshButton" toolTip="Refresh slivers" width="16" height="16" click="Main.protogeniHandler.rpcHandler.refreshSlice(sliceCanvas.slice);" source="{DisplayUtil.refreshIcon}"/>
<mx:VRule height="16"/>
<display:ImageButton id="startButton" toolTip="Start slivers" width="16" height="16" click="Main.protogeniHandler.rpcHandler.startSlice(sliceCanvas.slice);" source="{DisplayUtil.playIcon}"/>
<display:ImageButton id="stopButton" toolTip="Stop slivers" width="16" height="16" click="Main.protogeniHandler.rpcHandler.stopSlice(sliceCanvas.slice);" source="{DisplayUtil.stopIcon}"/>
<display:ImageButton id="restartButton" toolTip="Restart slivers" width="16" height="16" click="Main.protogeniHandler.rpcHandler.restartSlice(sliceCanvas.slice);" source="{DisplayUtil.refreshIcon}"/>
<display:ImageButton id="restartButton" toolTip="Restart slivers" width="16" height="16" click="Main.protogeniHandler.rpcHandler.restartSlice(sliceCanvas.slice);" source="{DisplayUtil.repeatIcon}"/>
<mx:Button label="Embed"/>
</mx:ControlBar>
......
......@@ -246,7 +246,7 @@
newNode.status = node.status;
for each(var nodeSliver:Sliver in node.slivers)
{
newNode.slivers.push(newSlice.slivers.getByUrn(nodeSliver.urn));
newNode.slivers.addIfNotExisting(newSlice.slivers.getByCm(nodeSliver.componentManager));
if(nodeSliver != sliver)
newSlice.slivers.getByUrn(nodeSliver.urn).nodes.addItem(newNode);
}
......
......@@ -69,6 +69,28 @@
status = "";
}
public function localNodes():VirtualNodeCollection
{
var on:VirtualNodeCollection = new VirtualNodeCollection();
for each(var vn:VirtualNode in this.nodes)
{
if(vn.manager == this.componentManager)
on.addItem(vn);
}
return on;
}
public function outsideNodes():VirtualNodeCollection
{
var on:VirtualNodeCollection = new VirtualNodeCollection();
for each(var vn:VirtualNode in this.nodes)
{
if(vn.manager != this.componentManager)
on.addItem(vn);
}
return on;
}
public function getVirtualNodeFor(pn:PhysicalNode):VirtualNode
{
for each(var vn:VirtualNode in this.nodes)
......@@ -207,13 +229,13 @@
// Deal with tunnel
if(virtualLink.firstNode.slivers[0] != this)
{
Util.addIfNonexistingToArray(virtualLink.firstNode.slivers, this);
Util.addIfNonexistingToArray(virtualLink.secondNode.slivers, virtualLink.firstNode.slivers[0]);
Util.addIfNonexistingToArrayCollection(virtualLink.firstNode.slivers, this);
Util.addIfNonexistingToArrayCollection(virtualLink.secondNode.slivers, virtualLink.firstNode.slivers[0]);
virtualLink.firstNode.slivers[0].links.addItem(virtualLink);
} else if(virtualLink.secondNode.slivers[0] != this)
{
Util.addIfNonexistingToArray(virtualLink.secondNode.slivers, this);
Util.addIfNonexistingToArray(virtualLink.firstNode.slivers, virtualLink.secondNode.slivers[0]);
Util.addIfNonexistingToArrayCollection(virtualLink.secondNode.slivers, this);
Util.addIfNonexistingToArrayCollection(virtualLink.firstNode.slivers, virtualLink.secondNode.slivers[0]);
virtualLink.secondNode.slivers[0].links.addItem(virtualLink);
}
......
......@@ -9,6 +9,26 @@ package protogeni.resources
super(source);
}
public function addIfNotExisting(s:Sliver):void
{
for each(var sliver:Sliver in this)
{
if(sliver.componentManager == s.componentManager)
return;
}
this.addItem(s);
}
public function clone():SliverCollection
{
var sc:SliverCollection = new SliverCollection();
for each(var sliver:Sliver in this)
{
sc.addItem(sliver);
}
return sc;
}
public function getByUrn(urn:String):Sliver
{
for each(var sliver:Sliver in this)
......
......@@ -14,7 +14,8 @@
package protogeni.resources
{
import mx.collections.ArrayCollection;
import mx.charts.renderers.DiamondItemRenderer;
import mx.collections.ArrayCollection;
// Link as part of a sliver/slice connecting virtual nodes
public class VirtualLink
......@@ -123,11 +124,23 @@
vi.virtualNode.interfaces.collection.removeItemAt(vi.virtualNode.interfaces.collection.getItemIndex(vi));
}
interfaces.removeAll();
// Remove nodes
firstNode.links.removeItemAt(firstNode.links.getItemIndex(this));
for(var i:int = 1; i < firstNode.slivers.length; i++)
{
if((firstNode.slivers[i] as Sliver).links.getForNode(firstNode).length == 0)
(firstNode.slivers[i] as Sliver).nodes.remove(firstNode);
}
secondNode.links.removeItemAt(secondNode.links.getItemIndex(this));
for(i = 1; i < secondNode.slivers.length; i++)
{
if((secondNode.slivers[i] as Sliver).links.getForNode(secondNode).length == 0)
(secondNode.slivers[i] as Sliver).nodes.remove(secondNode);
}
for each(var s:Sliver in slivers)
{
s.links.removeItemAt(s.links.getItemIndex(this));
// Remove nodes without links??
}
}
public function isTunnel():Boolean
......
......@@ -18,5 +18,22 @@ package protogeni.resources
}
return null;
}
public function getForNode(vn:VirtualNode):VirtualLinkCollection
{
var vlc:VirtualLinkCollection = new VirtualLinkCollection();
for each(var vl:VirtualLink in this)
{
for each(var vli:VirtualInterface in vl.interfaces)
{
if(vli.virtualNode == vn)
{
vlc.addItem(vl);
break;
}
}
}
return vlc;
}
}
}
\ No newline at end of file
......@@ -21,15 +21,19 @@
{
public function VirtualNode(owner:Sliver)
{
slivers = new Array(owner);
slivers = new SliverCollection();
if(owner != null)
{
slivers.addItem(owner);
manager = owner.componentManager;
}
interfaces = new VirtualInterfaceCollection();
var controlInterface:VirtualInterface = new VirtualInterface(this);
controlInterface.id = "control";
controlInterface.role = PhysicalNodeInterface.CONTROL;
controlInterface.isVirtual = true;
interfaces.Add(controlInterface);
if(owner != null)
manager = owner.componentManager;
}
[Bindable]
......@@ -66,7 +70,7 @@
public var rspec:XML;
[Bindable]
public var slivers:Array;
public var slivers:SliverCollection;
public var hostname:String;
public var sshdport:String;
......
......@@ -28,5 +28,11 @@ package protogeni.resources
}
return null;
}
public function remove(n:VirtualNode):void
{
if(this.getItemIndex(n) > -1)
this.removeItemAt(this.getItemIndex(n));
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment