Commit 3c4549d3 authored by Matt Strum's avatar Matt Strum

Made all changes for 10/2 meeting

parent 8b9ad6dd
......@@ -39,9 +39,7 @@
public var rspecView:XmlWindow;
[Bindable]
public var comHandler:ProtoGeniHandler;
public var mapHandler:ProtoGeniMapHandler;
public var pgHandler:ProtoGeniHandler;
public var main:Main;
......@@ -58,11 +56,7 @@
main.setConole(console);
comHandler = new ProtoGeniHandler();
comHandler.main = this;
mapHandler = new ProtoGeniMapHandler();
mapHandler.main = this;
pgHandler = new ProtoGeniHandler(this);
chooseCMWindow = new ChooseComponentManagerWindow();
chooseCMWindow.main = this;
......@@ -82,7 +76,7 @@
private function viewRspec():void {
PopUpManager.addPopUp(rspecView, this, false);
PopUpManager.centerPopUp(rspecView);
rspecView.loadXml(comHandler.Rspec);
rspecView.loadXml(pgHandler.rpc.Rspec);
}
public function refresh():void {
......@@ -90,14 +84,10 @@
map.clearOverlays();
// Get a fresh dataset
if(comHandler.credential != null && comHandler.credential.base != null) {
comHandler.AfterCall = null;
comHandler.startResourceLookup();
} else {
comHandler.AfterCall = comHandler.startResourceLookup;
comHandler.startCredential();
}
pgHandler.guarenteeCredential(pgHandler.getResourcesAndSlices);
}
//------------------------------------------
// GUI
......
......@@ -17,7 +17,7 @@
public var main:pgmap;
public function success():void {
main.comHandler.ComponentManagerURL = listManagers.selectedItem.url;
main.pgHandler.rpc.ComponentManagerURL = listManagers.selectedItem.url;
main.refresh();
close();
}
......@@ -29,44 +29,29 @@
public function open():void {
PopUpManager.addPopUp(this, main, true);
PopUpManager.centerPopUp(this);
if(main.comHandler.Components == null || main.comHandler.Components.length == 0) {
if(main.pgHandler.rpc.Components == null || main.pgHandler.rpc.Components.length == 0) {
startRefreshList();
} else
okButton.enabled = true;
//urlInput.text = main.comHandler.ComponentManagerURL;
}
public function startRefreshList():void {
//progressLabel.text = "Updating list...";
//waitingIcon.visible = true;
if(main.comHandler.credential == null || main.comHandler.credential.base == null) {
main.console.appendText("Getting credential...\n");
main.comHandler.AfterCall = afterCredential;
main.comHandler.startCredential();
} else
afterCredential();
main.pgHandler.guarenteeCredential( getComponents );
}
public function afterCredential():void {
main.console.appendText("After credential...\n");
main.comHandler.AfterCall = refreshList;
main.comHandler.startListComponents();
public function getComponents():void {
main.pgHandler.getComponents( refreshList );
}
public function refreshList():void {
main.comHandler.AfterCall = null;
okButton.enabled = true;
//progressLabel.text = "List updated";
//waitingIcon.visible = false;
}
]]>
</mx:Script>
<mx:HBox width="100%" verticalAlign="middle">
<mx:Button id="refreshButton" label="Refresh" icon="@Embed('../images/arrow_refresh.png')"/>
<mx:ComboBox editable="false" width="100%" id="listManagers" dataProvider="{main.comHandler.Components}" labelField="hrn"></mx:ComboBox>
<mx:ComboBox editable="false" width="100%" id="listManagers" dataProvider="{main.pgHandler.rpc.Components}" labelField="hrn"></mx:ComboBox>
</mx:HBox>
<mx:HBox width="100%" horizontalAlign="right">
<mx:Label id="progressLabel" fontStyle="normal" fontWeight="bold"/>
......
......@@ -6,6 +6,25 @@ package pgmap
public static var failColor:String = "#FE0000";
public static var waitColor:String = "#FF7F00";
[Bindable]
[Embed(source="../../images/tick.png")]
public static var availableIcon:Class;
[Bindable]
[Embed(source="../../images/cross.png")]
public static var notAvailableIcon:Class;
[Bindable]
[Embed(source="../../images/computer.png")]
public static var ownedIcon:Class;
public static function assignIcon(val:Boolean):Class {
if (val)
return Common.availableIcon;
else
return Common.notAvailableIcon;
}
public static function kbsToString(bandwidth:Number):String {
var bw:String = "";
if(bandwidth < 1000) {
......
......@@ -37,6 +37,9 @@
public var available:Boolean;
public var exclusive:Boolean;
public var slice : Slice = null;
public var status : String;
[Bindable]
public var types:ArrayCollection = new ArrayCollection();
......
......@@ -51,8 +51,8 @@
public function loadNode(n:Node):void {
node = n;
imgAvailable.source = assignIcon(n.available);
imgExclusive.source = assignIcon(n.exclusive);
imgAvailable.source = assignIcon(n);
imgExclusive.source = Common.assignIcon(n.exclusive);
linkedNodes = new ArrayCollection();
......@@ -99,24 +99,18 @@
PopUpManager.centerPopUp(rspecView);
rspecView.loadXml(node.rspec);
}
[Bindable]
[Embed(source="../../images/tick.png")]
public var availableIcon:Class;
[Bindable]
[Embed(source="../../images/cross.png")]
public var notAvailableIcon:Class;
private function assignAvailableIcon(item:Object):Class {
return assignIcon(item.available);
return assignIcon(item as Node);
}
private function assignIcon(val:Boolean):Class {
if (val)
return availableIcon;
private function assignIcon(val:Node):Class {
if(val.slice != null)
return Common.ownedIcon;
else if (val.available)
return Common.availableIcon;
else
return notAvailableIcon;
return Common.notAvailableIcon;
}
]]>
</mx:Script>
......
......@@ -74,6 +74,6 @@
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
<mx:Button label="More Info" click="main.mapHandler.viewNodeGroup(group)"/>
<mx:Button label="More Info" click="main.pgHandler.map.viewNodeGroup(group)"/>
</mx:VBox>
......@@ -14,233 +14,58 @@
package pgmap
{
import com.mattism.http.xmlrpc.MethodFault;
import flash.events.ErrorEvent;
import flash.utils.ByteArray;
import mx.utils.Base64Decoder;
public class ProtoGeniHandler
{
public var op : Operation;
public var opName : String;
public var credential : Credential;
public var main : pgmap;
public var ComponentManagerURL:String = "https://boss.emulab.net:443/protogeni/xmlrpc/cm";
public var Rspec:XML = null;
[Bindable]
public var rpc : ProtoGeniRpcHandler;
[Bindable]
public var Components:Array = null;
public var map : ProtoGeniMapHandler;
public var Nodes:NodeGroupCollection = new NodeGroupCollection();
public var Links:LinkGroupCollection = new LinkGroupCollection();
public var AfterCall:Function;
public function ProtoGeniHandler()
{
op = new Operation(null);
opName = null;
credential = null;
credential = new Credential();
}
public var slice:Slice = new Slice();
public function clearAll() : void
public function ProtoGeniHandler(m:pgmap)
{
clearResources();
Components = null;
rpc = new ProtoGeniRpcHandler();
map = new ProtoGeniMapHandler();
rpc.main = m;
map.main = m;
main = m;
}
public function clearResources() : void
public function clear() : void
{
Nodes = new NodeGroupCollection();
Links = new LinkGroupCollection();
Rspec = null;
}
public function startCredential() : void
{
main.console.clear();
opName = "Acquiring credential";
main.setProgress(opName, Common.waitColor);
main.startWaiting();
main.console.appendText(opName);
op.reset(Geni.getCredential);
op.call(completeCredential, failure);
addSend();
}
public function completeCredential(code : Number, response : Object) : void
{
main.setProgress("Done", Common.successColor);
main.stopWaiting();
addResponse();
if (code == 0)
{
credential.base = String(response.value);
}
else
{
codeFailure();
}
postCall();
}
public function postCall() : void {
main.console.appendText("Seeing if there are any other method to call...\n");
if(AfterCall != null) {
main.console.appendText("Doing a post call...\n");
AfterCall();
}
}
public function failure(event : ErrorEvent, fault : MethodFault) : void
{
main.openConsole();
main.setProgress("Operation failed!", Common.failColor);
main.stopWaiting();
main.console.appendText("****fail****");
if (fault != null)
{
main.console.appendText("\nFAILURE fault: " + opName + ": "
+ fault.getFaultString());
}
else
{
main.console.appendText("\nFAILURE event: " + opName + ": "
+ event.toString());
}
main.console.appendText("\nURL: " + op.getUrl());
}
public function codeFailure() : void
{
main.console.appendText("Code Failure: " + opName);
}
public function addSend() : void
{
main.console.appendText("\n-----------------------------------------\n");
main.console.appendText("SEND: " + opName + "\n");
main.console.appendText("URL: " + op.getUrl() + "\n");
main.console.appendText("-----------------------------------------\n\n");
main.console.appendText(op.getSendXml());
// clip.xmlText.scrollV = clip.xmlText.maxScrollV;
}
public function addResponse() : void
{
main.console.appendText("\n-----------------------------------------\n");
main.console.appendText("RESPONSE: " + opName + "\n");
main.console.appendText("-----------------------------------------\n\n");
main.console.appendText(op.getResponseXml());
}
public function startSshLookup() : void
{
opName = "Acquiring SSH Keys";
main.setProgress(opName, Common.waitColor);
main.startWaiting();
main.console.appendText(opName);
op.reset(Geni.getKeys);
op.addField("credential", credential.base);
op.call(completeSshLookup, failure);
addSend();
}
public function completeSshLookup(code : Number, response : Object) : void
{
main.setProgress("Done", Common.successColor);
main.stopWaiting();
addResponse();
if (code == 0)
{
credential.ssh = response.value;
}
else
{
codeFailure();
}
postCall();
}
public function startResourceLookup() : void
{
clearResources();
opName = "Looking up resources";
main.setProgress(opName, Common.waitColor);
main.startWaiting();
main.console.appendText(opName + "...\n");
op.reset(Geni.discoverResources);
op.addField("credential", credential.base);
op.addField("compress", true);
op.setUrl(ComponentManagerURL);
op.call(completeResourceLookup, failure);
}
public function completeResourceLookup(code : Number, response : Object) : void
{
main.setProgress("Done", Common.successColor);
main.stopWaiting();
main.console.appendText("Resource lookup complete...\n");
if (code == 0)
{
var x:Base64Decoder = new Base64Decoder();
x.decode(response.value);
var s:ByteArray = x.toByteArray();
s.uncompress();
var s2:String = s.toString();
Rspec = new XML(s2);
processRspec();
}
else
{
codeFailure();
main.console.appendText(op.getResponseXml());
}
postCall();
}
public function startListComponents() : void
{
opName = "Looking up components";
main.setProgress(opName, Common.waitColor);
main.startWaiting();
main.console.appendText(opName + "...\n");
op.reset(Geni.listComponents);
op.addField("credential", credential.base);
op.setUrl("https://boss.emulab.net:443/protogeni/xmlrpc/ch");
op.call(completeListComponents, failure);
}
public function completeListComponents(code : Number, response : Object) : void
{
main.setProgress("Done", Common.successColor);
main.stopWaiting();
main.console.appendText("List Components complete...\n");
if (code == 0)
{
Components = response.value;
main.console.appendText(op.getResponseXml());
}
else
{
codeFailure();
main.console.appendText(op.getResponseXml());
}
postCall();
}
public function getCredential(afterCompletion : Function):void {
rpc.AfterCall = afterCompletion;
rpc.startCredential();
}
public function guarenteeCredential(afterCompletion : Function):void {
if(rpc.hasCredential())
afterCompletion();
else
getCredential(afterCompletion);
}
public function getComponents(afterCompletion : Function):void {
rpc.AfterCall = afterCompletion;
rpc.startListComponents();
}
public function getResourcesAndSlices():void {
rpc.startResourceLookup();
}
private function processRspec():void {
public function processRspec(afterCompletion : Function):void {
namespace rsync01namespace = "http://www.protogeni.net/resources/rspec/0.1";
use namespace rsync01namespace;
......@@ -248,7 +73,7 @@
main.console.appendText("Processing RSPEC...\n");
// Process nodes
var locations:XMLList = Rspec.node.location;
var locations:XMLList = rpc.Rspec.node.location;
main.console.appendText("Detected " + locations.length().toString() + " nodes with location info...\n");
// Process nodes, combining same locations
......@@ -269,8 +94,8 @@
var p:XML = location.parent();
n.name = p.@component_name;
n.uuid = p.@component_uuid;
n.available = Boolean(p.available);
n.exclusive = Boolean(p.exclusive);
n.available = p.available == "true";
n.exclusive = p.exclusive == "true";
n.manager = p.@component_manager_uuid;
for each(var ix:XML in p.children()) {
......@@ -293,7 +118,7 @@
}
// Process links
var links:XMLList = Rspec.link;
var links:XMLList = rpc.Rspec.link;
for each(var link:XML in links) {
var interfaces:XMLList = link.interface_ref;
// 1
......@@ -337,8 +162,15 @@
main.console.appendText("Found " + Links.collection.length + " visible links\n");
main.console.appendText("Detected " + links.length().toString() + " Links...\n");
main.mapHandler.drawMap();
if(afterCompletion != null)
afterCompletion();
}
public function addSliceNode(urn:String):void {
var n : Node = Nodes.GetByUUID(urn);
if(n != null)
n.slice = slice;
}
}
}
\ No newline at end of file
......@@ -60,7 +60,6 @@ package pgmap
}
});
geocoder.addEventListener(GeocodingEvent.GEOCODING_FAILURE,
function(event:GeocodingEvent):void {
//Alert.show("Geocoding failed");
......@@ -100,7 +99,7 @@ package pgmap
var t:TooltipOverlay = new TooltipOverlay(ll, Common.kbsToString(lg.TotalBandwidth()));
t.addEventListener(MouseEvent.CLICK, function(e:Event):void {
e.stopImmediatePropagation();
main.mapHandler.viewLinkGroup(lg)
main.pgHandler.map.viewLinkGroup(lg)
});
main.map.addOverlay(t);
......@@ -111,11 +110,11 @@ package pgmap
main.setProgress("Drawing map",Common.waitColor);
for each(var g:NodeGroup in main.comHandler.Nodes.collection) {
for each(var g:NodeGroup in main.pgHandler.Nodes.collection) {
addMarker(g);
}
for each(var l:LinkGroup in main.comHandler.Links.collection) {
for each(var l:LinkGroup in main.pgHandler.Links.collection) {
if(!l.IsSameSite()) {
addLink(l);
}
......
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