Commit 6f9f9afa authored by Jonathon Duerig's avatar Jonathon Duerig

Checkpoint of demo code as of GEC5. Added abstract nodes, shared nodes, SES,...

Checkpoint of demo code as of GEC5. Added abstract nodes, shared nodes, SES, updated to interact with new CMs, compatibility with old CMs mostly preserved.
parent 878b4645
<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="boss.emulab.net" />
</cross-domain-policy>
No preview for this file type
/* GENIPUBLIC-COPYRIGHT
* Copyright (c) 2009 University of Utah and the Flux Group.
* All rights reserved.
*
* Permission to use, copy, modify and distribute this software is hereby
* granted provided that (1) source code retains these copyright, permission,
* and disclaimer notices, and (2) redistributions including binaries
* reproduce the notices in supporting documentation.
*
* THE UNIVERSITY OF UTAH ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. THE UNIVERSITY OF UTAH DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*/
package
{
import flash.events.MouseEvent;
public class AbstractNodes
{
public function AbstractNodes(clip : SliceDetailClip,
newNodes : ActiveNodes,
newManagers : ComponentView) : void
{
exclusive = clip.exclusiveNode;
shared = clip.sharedNode;
nodes = newNodes;
managers = newManagers;
setupNode(exclusive, "Exclusive");
setupNode(shared, "Shared");
exclusive.addEventListener(MouseEvent.MOUSE_DOWN, createExclusive);
shared.addEventListener(MouseEvent.MOUSE_DOWN, createShared);
}
public function cleanup() : void
{
exclusive.removeEventListener(MouseEvent.MOUSE_DOWN, createExclusive);
shared.removeEventListener(MouseEvent.MOUSE_DOWN, createShared);
}
function setupNode(node : NodeClip, name : String) : void
{
node.node.nameField.text = name;
node.node.cmField.text = "*";
node.node.mouseChildren = false;
node.node.selected.visible = false;
}
function createExclusive(event : MouseEvent) : void
{
createNode(event, "exclusive", false);
}
function createShared(event : MouseEvent) : void
{
createNode(event, "shared", true);
}
function createNode(event : MouseEvent, namePrefix : String,
isShared : Boolean) : void
{
if (managers.isValidManager())
{
var currentManager = managers.getCurrentManager();
var component = new Component();
component.name = namePrefix + nextNumber();
component.isVirtual = true;
component.isShared = isShared;
nodes.addNode(component, currentManager, -1,
event.stageX, event.stageY);
}
}
static function nextNumber() : int
{
++nameSuffix;
return nameSuffix;
}
static var nameSuffix = 0;
var exclusive : NodeClip;
var shared : NodeClip;
var nodes : ActiveNodes;
var managers : ComponentView;
}
}
......@@ -88,6 +88,7 @@ package
newNode.move(x - dragX, y - dragY);
nodes.push(newNode);
beginDrag(newNode);
newNode.getManager().setChanged();
}
function removeNode(doomedNode : Node) : void
......@@ -98,6 +99,7 @@ package
{
removeLink(nodeLinks[i]);
}
doomedNode.getManager().setChanged();
doomedNode.cleanup();
var index = nodes.indexOf(doomedNode);
......@@ -239,6 +241,8 @@ package
var newLink = new Link(linkLayer, links.length, source, dest,
removeLinkEvent);
links.push(newLink);
source.getManager().setChanged();
dest.getManager().setChanged();
}
function removeLinkEvent(event : MouseEvent)
......@@ -248,6 +252,8 @@ package
function removeLink(doomedLink : Link)
{
doomedLink.getLeft().getManager().setChanged();
doomedLink.getRight().getManager().setChanged();
doomedLink.cleanup();
var index : int = links.indexOf(doomedLink);
if (index != -1)
......@@ -284,41 +290,55 @@ package
}
return result;
}
/*
public function setSliverId(cmIndex : int, name : String,
public function setSliverId(cm : ComponentManager, name : String,
sliverId : String) : void
{
var i : int = 0;
for (; i < nodes.length; ++i)
{
if (nodes[i].getCmIndex() == cmIndex
if (nodes[i].getManager() == cm
&& nodes[i].getName() == name)
{
nodes[i].setSliverId(sliverId);
}
}
}
*/
public function getXml(useTunnels : Boolean) : XML
public function getXml(useTunnels : Boolean, cm : ComponentManager) : XML
{
var result = <rspec xmlns="http://protogeni.net/resources/rspec/0.1" />;
var version = 2;
if (cm != null)
{
version = cm.getVersion();
}
var result = XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?> "
+ "<rspec "
+ "xmlns=\"http://www.protogeni.net/resources/rspec/0.1\" "
+ "type=\"request\" />");
var i : int = 0;
for (i = 0; i < nodes.length; ++i)
{
var currentNode : XML = nodes[i].getXml(useTunnels);
if (currentNode != null)
if (version >= 1 || cm == nodes[i].getManager())
{
result.appendChild(currentNode);
var currentNode : XML = nodes[i].getXml(useTunnels, version);
if (currentNode != null)
{
result.appendChild(currentNode);
}
}
}
for (i = 0; i < links.length; ++i)
{
var currentLink : XML = links[i].getXml(useTunnels);
if (currentLink != null)
if (version >= 3 || links[i].isConnectedTo(cm))
{
result.appendChild(currentLink);
var currentLink : XML = links[i].getXml(useTunnels, version);
if (currentLink != null)
{
result.appendChild(currentLink);
}
}
}
......@@ -362,6 +382,7 @@ package
{
nodes[i].revertState(target);
}
updateSelectText();
}
public function commitState(target : ComponentManager) : void
......@@ -371,6 +392,7 @@ package
{
nodes[i].commitState(target);
}
updateSelectText();
}
public function existsState(target : ComponentManager,
......@@ -430,6 +452,20 @@ package
return result;
}
public function mapRequest(request : String,
manager : ComponentManager) : void
{
var root : XML = XML(request);
var nodeName : QName = new QName(root.namespace(), "node");
var nodeXml = root.elements(nodeName);
var i : int = 0;
for (; i < nodes.length; ++i)
{
nodes[i].mapRequest(nodeXml[i], manager);
}
updateSelectText();
}
var nodes : Array;
var links : Array;
var parent : DisplayObjectContainer;
......
......@@ -25,11 +25,15 @@ package
uuid = "";
managerId = "";
interfaces = new Array();
isVirtual = false;
isShared = false;
}
public var name : String;
public var uuid : String;
public var managerId : String;
public var interfaces : Array;
public var isVirtual : Boolean;
public var isShared : Boolean;
}
}
......@@ -27,13 +27,17 @@ package
newName : String,
newHostName : String,
newUrl : String,
newUpdate : Function) : void
newUpdate : Function,
newVersion : int) : void
{
id = newId;
name = newName;
hostName = newHostName;
url = newUrl;
ad = "";
update = newUpdate;
version = newVersion;
changed = false;
components = new Array();
used = new Array();
......@@ -52,6 +56,11 @@ package
return url;
}
public function getAd() : String
{
return ad;
}
public function getHostName() : String
{
return hostName;
......@@ -127,6 +136,63 @@ package
return components.length;
}
public function getVersion() : int
{
return version;
}
public function setChanged() : void
{
changed = true;
}
public function clearChanged() : void
{
changed = false;
}
public function hasChanged() : Boolean
{
return changed;
}
public function isUsedString(id : String) : Boolean
{
var result = true;
var index = findId(id);
if (index != -1)
{
result = isUsed(index);
}
return result;
}
// Returns the node index of the now used node.
public function makeUsed(id : String) : int
{
var index = findId(id);
if (index != -1 && ! isUsed(index))
{
addUsed(index);
update();
}
return index;
}
function findId(id : String) : int
{
var result : int = -1;
var i : int = 0;
for (; i < components.length && result == -1; ++i)
{
if (components[i].uuid == id)
{
result = i;
}
}
return result;
}
public function resourceFailure() : void
{
setState(FAILED);
......@@ -142,6 +208,7 @@ package
}
try
{
ad = str;
if (str != null)
{
var uuidToNode = new Dictionary();
......@@ -160,7 +227,7 @@ package
var i : int = 0;
for (; i < xmlNodes.length; ++i)
{
if (isAvailable(xmlNodes[i]))
if (version < 2 || isAvailable(xmlNodes[i]))
{
var com : Component = new Component();
components.push(com);
......@@ -168,13 +235,33 @@ package
uuidToNode[uuid] = com;
com.name = xmlNodes[i].attribute("component_name");
com.uuid = uuid;
com.managerId = xmlNodes[i].attribute("component_manager_uuid");
if (version < 2)
{
com.managerId = id;
}
else
{
com.managerId = xmlNodes[i].attribute("component_manager_uuid");
}
var interfaceName = new QName(rspec.namespace(), "interface");
var interfaceList = xmlNodes[i].elements(interfaceName);
var interfaceNumber = 0;
for each (var inter in interfaceList)
{
var interName = inter.attribute("component_id");
com.interfaces.push(new Interface(interName));
var interName = null;
if (version < 2)
{
interName = inter.attribute("component_name");
}
else
{
interName = inter.attribute("component_id");
}
var newInterface = new Interface("virt-"
+ String(interfaceNumber),
interName);
com.interfaces.push(newInterface);
++interfaceNumber;
}
}
}
......@@ -202,16 +289,28 @@ package
{
var interElement : QName = new QName(rspec.namespace(),
"interface_ref");
if (version < 2)
{
interElement = new QName(rspec.namespace(), "interface");
}
for each (var inter in link.descendants(interElement))
{
// var uuidList = inter.elements(new QName(rspec.namespace(),
// "component_node_uuid"));
// var uuid : String = uuidList.text();
var uuid : String = inter.attribute("component_node_uuid");
// var nameList = inter.elements(new QName(rspec.namespace(),
// "component_interface_name"));
// var interName : String = nameList.text();
var interName : String = inter.attribute("component_interface_id");
var interName : String = null;
var uuid : String = null;
if (version < 2)
{
var uuidList = inter.elements(new QName(rspec.namespace(),
"component_node_uuid"));
uuid = uuidList.text();
var nameList = inter.elements(new QName(rspec.namespace(),
"component_interface_name"));
interName = nameList.text();
}
else
{
uuid = inter.attribute("component_node_uuid");
interName = inter.attribute("component_interface_id");
}
var node : Component = uuidToNode[uuid];
if (node != null)
{
......@@ -281,6 +380,7 @@ package
var name : String;
var hostName : String;
var url : String;
var ad : String;
var components : Array;
var used : Array;
......@@ -289,5 +389,12 @@ package
var sliver : String;
var state : int;
var update : Function;
var changed : Boolean;
// Version 0 is baseline from GEC 4
// Version 1 is request converted but advertisement the same
// Version 2 is both ad and request converted
var version : int;
}
}
......@@ -31,46 +31,46 @@ package
select = newSelect;
list = newList;
list.allowMultipleSelection = true;
list.setStyle("cellRenderer", CustomCellRenderer);
listStatus = new ListStatusClip();
list.addChild(listStatus);
listStatus.alpha = 0.3;
nodes = newNodes;
managers = new Array(
new ComponentManager("", "", "", "", updateList),
/*
new ComponentManager("", "", "", "", updateList, 2),
new ComponentManager("e2a9e480-aa9f-11dd-9fcd-001143e43770",
"ProtoGENI",
".emulab.net",
"https://myboss.myelab.testbed.emulab.net:443/protogeni/xmlrpc",
updateList),
*/
updateList, 2),
new ComponentManager("28a10955-aa00-11dd-ad1f-001143e453fe",
"Emulab",
".emulab.net",
"https://boss.emulab.net:443/protogeni/xmlrpc/",
updateList)/*,
// Doesn't work ??? "https://boss.emulab.net:443/dev/stoller/protogeni/xmlrpc/",
updateList, 2),
new ComponentManager("be300821-ecb7-11dd-a0f8-001143e43ff3",
"gtwelab",
".emulab.net",
"https://myboss.emulab.geni.emulab.net:443/protogeni/xmlrpc",
updateList),
updateList, 2),
new ComponentManager("b83b47be-e7f0-11dd-848b-0013468d3dc8",
"Kentucky",
".uky.emulab.net",
"https://www.uky.emulab.net/protogeni/xmlrpc",
updateList),
updateList, 0),
new ComponentManager("f38e8571-f7af-11dd-ab88-00304868a4be",
"Wisconsin",
".schooner.wail.wisc.edu",
"https://www.schooner.wail.wisc.edu/protogeni/xmlrpc",
updateList),
updateList, 0),
new ComponentManager("", "CMU", ".cmcl.cs.cmu.edu",
"https://boss.cmcl.cs.cmu.edu/protogeni/xmlrpc",
updateList)*/);
updateList, 0));
select.removeAll();
select.selectedIndex = 0;
select.rowCount = 4;
var i : int = 0;
for (; i < managers.length; ++i)
......@@ -100,38 +100,16 @@ package
return managers;
}
/*
public function getTicket(index : int) : String
public function getCurrentManager() : ComponentManager
{
return tickets[index];
return managers[select.selectedIndex];
}
public function setTicket(index : int, value : String) : void
public function isValidManager() : Boolean
{
tickets[index] = value;
return select.selectedIndex != 0;
}
public function getUrl(index : int) : String
{
return cmUrls[index];
}
*/
/*
public function getCmCount() : int
{
return managers.length;
}
*/
/*
public function removeNode(cm : ComponentManager, nodeIndex : int) : void
{
cm.removeUsed(nodeIndex);
if (cm == select.selectedItem.data)
{
updateList();
}
}
*/
function clickItem(event : ListEvent) : void
{
var cm : ComponentManager = managers[select.selectedIndex];
......@@ -153,6 +131,7 @@ package
function changeComponent(event : Event) : void
{
updateList();
list.scrollToIndex(0);
}
function updateList() : void
......@@ -183,39 +162,12 @@ package
listStatus.text.backgroundColor = 0xff0000;
}
}
/*
public function succeedResources(cm : ComponentManager, str : String)
{
cm.populateNodes(str);
updateList();
}
public function failResources(cm : ComponentManager)
{
cm.setState(FAILED);
updateList();
}
*/
var select : ComboBox;
var list : List;
var listStatus : ListStatusClip;
var nodes : ActiveNodes;
// The ComponentManagers
var managers : Array;
/*
// An array of arrays. Outer == CM, inner == Component
var components : Array;
var used : Array;
var tickets : Array;
var states : Array;
*/
/*
public static var hostName : Array = new Array("",
public static var cmNames : Array = new Array("", ,
static var cmUrls : Array =
static var cmUuids : Array =
static var cmResults : Array =
*/
}
}
......@@ -15,12 +15,15 @@
package
{
import flash.display.DisplayObjectContainer;
import flash.text.TextField;
import flash.events.MouseEvent;
import flash.events.ErrorEvent;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.system.System;
import flash.text.TextField;
import fl.controls.Button;
import com.mattism.http.xmlrpc.MethodFault;
......@@ -51,15 +54,19 @@ package
arena.bootButton,
arena.speedButton,
arena.deleteButton,
arena.embedButton,
arena.rspecButton,
clip.backButton,
clip.rspecButton),
clip.copyButton),
new Array(clickConsole,
clickCreateSlivers,
clickBootSlivers,
clickRunSpeedTest,
clickDeleteSlivers,
clickEmbed,
clickRspec,
clickBack,
clickRspec));
clickCopy));
queue = new Queue();
working = false;
......@@ -83,11 +90,22 @@ package
function discoverSliver(cm : ComponentManager) : Request
{
return new RequestResourceDiscovery(cm);
if (cm != managers.getManagers()[0])
{
return new RequestResourceDiscovery(cm);
}
else
{
return null;
}
}
function clickConsole(event : MouseEvent) : void
{
clip.text.visible = true;
clip.textScroll.visible = true;
clip.rspecText.visible = false;
clip.rspecScroll.visible = false;
clip.visible = true;
}
......@@ -98,14 +116,19 @@ package
if (cm.getUrl() != null)
{
var newRequest = func(cm);
if (newRequest != null)
{
queue.push(newRequest);
if (! working)
{
start();
}
}
pushRequest(newRequest);
}
}
}
function pushRequest(newRequest : Request) : void
{
if (newRequest != null)
{
queue.push(newRequest);
if (! working)
{
start();
}
}
}
......@@ -122,17 +145,18 @@ package
{
var result : Request = null;
var shouldSend = nodes.managerUsed(cm);
if (shouldSend)
if (shouldSend && cm.hasChanged())
{
cm.clearChanged();
var rspec = null;
if (cm.getSliver() == null)
{
rspec = nodes.getXml(false);
rspec = nodes.getXml(false, cm);
result = new RequestSliverCreate(cm, nodes, rspec);
}
else
else if (cm.getVersion() >= 2)
{
rspec = nodes.getXml(true);
rspec = nodes.getXml(true, cm);
result = new RequestSliverUpdate(cm, nodes, rspec, false);
}
}
......@@ -190,25 +214,60 @@ package
return result;
}
function clickEmbed(event : MouseEvent) : void
{
if (managers.isValidManager() && queue.isEmpty())
{
var currentManager = managers.getCurrentManager();
var request = new RequestSliceEmbedding(currentManager, nodes,
nodes.getXml(false,