Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
7b355473
Commit
7b355473
authored
Mar 26, 2009
by
Jonathon Duerig
Browse files
Robustness improvements. Merging with other changes.
parent
729b7fe7
Changes
7
Hide whitespace changes
Inline
Side-by-side
protogeni/demo/src/ActiveNodes.as
View file @
7b355473
...
...
@@ -316,16 +316,38 @@ package
return
result
;
}
public
function
changeState
(
cmIndex
:
int
,
newState
:
int
)
:
void
public
function
changeState
(
cmIndex
:
int
,
oldState
:
int
,
newState
:
int
)
:
void
{
var
i
:
int
=
0
;
for
(
;
i
<
nodes
.
length
;
++
i
)
{
nodes
[
i
].
changeState
(
cmIndex
,
newState
)
;
if
(
nodes
[
i
].
calculateState
()
==
oldState
)
{
nodes
[
i
].
changeState
(
cmIndex
,
newState
)
;
}
}
updateSelectText
()
;
}
public
function
revertState
(
cmIndex
:
int
)
:
void
{
var
i
:
int
=
0
;
for
(
;
i
<
nodes
.
length
;
++
i
)
{
nodes
[
i
].
revertState
(
cmIndex
)
;
}
}
public
function
commitState
(
cmIndex
:
int
)
:
void
{
var
i
:
int
=
0
;
for
(
;
i
<
nodes
.
length
;
++
i
)
{
nodes
[
i
].
commitState
(
cmIndex
)
;
}
}
public
function
existsState
(
cmIndex
:
int
,
newState
:
int
)
:
Boolean
{
var
result
:
Boolean
=
false
;
...
...
@@ -354,15 +376,13 @@ package
static
var
NO_SELECTION
:
int
=
-1
;
public
static
var
PLANNED
:
int
=
0
;
public
static
var
PENDING
:
int
=
1
;
public
static
var
CREATED
:
int
=
2
;
public
static
var
BOOTED
:
int
=
3
;
public
static
var
FAILED
:
int
=
4
;
public
static
var
CREATED
:
int
=
1
;
public
static
var
BOOTED
:
int
=
2
;
public
static
var
PENDING
:
int
=
3
;
public
static
var
statusText
=
new
Array
(
"Planned"
,
"Pending"
,
"Created"
,
"Booted"
,
"
Failed
"
)
;
"
Pending
"
)
;
}
}
protogeni/demo/src/Console.as
View file @
7b355473
...
...
@@ -104,7 +104,7 @@ package
if
(
newRequest
!=
null
)
{
queue
.
push
(
newRequest
)
;
nodes
.
changeState
(
i
,
ActiveNodes
.
PENDING
)
;
//
nodes.changeState(i, ActiveNodes.PENDING);
if
(
!
working
)
{
start
()
;
...
...
protogeni/demo/src/Node.as
View file @
7b355473
...
...
@@ -49,7 +49,9 @@ package
renumber
(
newNumber
)
;
links
=
new
Array
()
;
changeState
(
cmIndex
,
ActiveNodes
.
PLANNED
)
;
oldState
=
ActiveNodes
.
PLANNED
;
newState
=
ActiveNodes
.
PLANNED
;
updateState
()
;
}
public
function
cleanup
()
:
void
...
...
@@ -140,15 +142,50 @@ package
return
cmIndex
;
}
public
function
changeState
(
index
:
int
,
newS
tate
:
int
)
:
void
public
function
changeState
(
index
:
int
,
s
tate
:
int
)
:
void
{
if
(
index
==
cmIndex
)
{
clip
.
node
.
nameField
.
backgroundColor
=
stateColor
[
newState
]
;
state
=
new
State
;
newState
=
state
;
update
State
()
;
}
}
public
function
commitState
(
index
:
int
)
:
void
{
if
(
index
==
cmIndex
)
{
oldState
=
newState
;
updateState
()
;
}
}
public
function
revertState
(
index
:
int
)
:
void
{
if
(
index
==
cmIndex
)
{
newState
=
oldState
;
updateState
()
;
}
}
public
function
calculateState
()
:
int
{
var
state
:
int
=
newState
;
if
(
newState
!=
oldState
)
{
state
=
ActiveNodes
.
PENDING
;
}
return
state
;
}
public
function
updateState
()
:
void
{
var
state
:
int
=
calculateState
()
;
clip
.
node
.
nameField
.
backgroundColor
=
stateColor
[
state
]
;
}
public
function
getXml
(
targetIndex
:
int
)
:
XML
{
var
result
:
XML
=
null
;
...
...
@@ -165,11 +202,13 @@ package
public
function
isState
(
index
:
int
,
exemplar
:
int
)
:
Boolean
{
var
state
:
int
=
calculateState
()
;
return
index
==
cmIndex
&&
state
==
exemplar
;
}
public
function
getStatusText
()
:
String
{
var
state
:
int
=
calculateState
()
;
var
result
:
String
=
""
;
result
+=
"<font color=\"#7777ff\">Name:</font> "
+
name
+
"\n"
;
result
+=
"<font color=\"#7777ff\">UUID:</font> "
+
id
+
"\n"
;
...
...
@@ -179,6 +218,11 @@ package
{
result
+=
"<font color=\"#7777ff\">Status:</font> "
+
ActiveNodes
.
statusText
[
state
]
;
if
(
state
==
ActiveNodes
.
PENDING
)
{
result
+=
": "
+
ActiveNodes
.
statusText
[
oldState
]
+
" -> "
+
ActiveNodes
.
statusText
[
newState
]
;
}
}
return
result
;
}
...
...
@@ -192,7 +236,8 @@ package
var
links
:
Array
;
var
mouseDownNode
:
Function
;
var
mouseDownLink
:
Function
;
var
state
:
int
;
var
oldState
:
int
;
var
newState
:
int
;
static
var
virtType
=
"emulab-vnode"
;
...
...
@@ -203,9 +248,9 @@ package
public
static
var
CENTER_Y
:
int
=
Math
.
floor
(
HEIGHT
/
2
)
;
static
var
stateColor
=
new
Array
(
0xaaaaff
,
0xaaaaaa
,
0xaaffaa
,
0xaaffff
,
0xffaaaa
)
;
0xaaaaaa
)
;
// 0xffaaaa);
}
}
protogeni/demo/src/RequestSliverCreate.as
View file @
7b355473
...
...
@@ -36,6 +36,7 @@ package
{
if
(
cm
.
getTicket
(
cmIndex
)
==
null
)
{
nodes
.
changeState
(
cmIndex
,
ActiveNodes
.
PLANNED
,
ActiveNodes
.
CREATED
)
;
opName
=
"Getting Ticket"
;
op
.
reset
(
Geni
.
getTicket
)
;
op
.
addField
(
"credential"
,
credential
.
slice
)
;
...
...
@@ -68,21 +69,26 @@ package
}
else
{
nodes
.
c
hange
State
(
cmIndex
,
ActiveNodes
.
CREATED
)
;
nodes
.
c
ommit
State
(
cmIndex
)
;
credential
.
slivers
[
cmIndex
]
=
response
.
value
;
cm
.
setTicket
(
cmIndex
,
null
)
;
}
}
else
{
nodes
.
changeState
(
cmIndex
,
ActiveNodes
.
FAILED
)
;
if
(
cm
.
getTicket
(
cmIndex
)
!=
null
)
{
// TODO: DeleteTicket
}
nodes
.
revertState
(
cmIndex
)
;
}
return
result
;
}
override
public
function
fail
()
:
void
{
nodes
.
changeState
(
cmIndex
,
ActiveNodes
.
FAILED
)
;
// TODO: DeleteTicket
nodes
.
revertState
(
cmIndex
)
;
}
var
cmIndex
:
int
;
...
...
protogeni/demo/src/RequestSliverDestroy.as
View file @
7b355473
...
...
@@ -34,6 +34,8 @@ package
{
// TODO: Check to make sure that credential.slivers[cmIndex]
// exists and perform a no-op if it doesn't.
nodes
.
changeState
(
cmIndex
,
ActiveNodes
.
CREATED
,
ActiveNodes
.
PLANNED
)
;
nodes
.
changeState
(
cmIndex
,
ActiveNodes
.
BOOTED
,
ActiveNodes
.
PLANNED
)
;
opName
=
"Deleting Sliver"
;
op
.
reset
(
Geni
.
deleteSliver
)
;
op
.
addField
(
"credential"
,
credential
.
slivers
[
cmIndex
])
;
...
...
@@ -47,11 +49,11 @@ package
{
if
(
code
==
0
)
{
nodes
.
c
hange
State
(
cmIndex
,
ActiveNodes
.
PLANNED
)
;
nodes
.
c
ommit
State
(
cmIndex
)
;
}
else
{
nodes
.
change
State
(
cmIndex
,
ActiveNodes
.
FAILED
)
;
nodes
.
revert
State
(
cmIndex
)
;
}
credential
.
slivers
[
cmIndex
]
=
null
;
return
null
;
...
...
protogeni/demo/src/RequestSliverStart.as
View file @
7b355473
...
...
@@ -32,6 +32,7 @@ package
override
public
function
start
(
credential
:
Credential
)
:
Operation
{
nodes
.
changeState
(
cmIndex
,
ActiveNodes
.
CREATED
,
ActiveNodes
.
BOOTED
)
;
opName
=
"Booting Sliver"
;
op
.
reset
(
Geni
.
startSliver
)
;
op
.
addField
(
"credential"
,
credential
.
slivers
[
cmIndex
])
;
...
...
@@ -45,11 +46,11 @@ package
{
if
(
code
==
0
)
{
nodes
.
c
hange
State
(
cmIndex
,
ActiveNodes
.
BOOTED
)
;
nodes
.
c
ommit
State
(
cmIndex
)
;
}
else
{
nodes
.
change
State
(
cmIndex
,
ActiveNodes
.
FAILED
)
;
nodes
.
revert
State
(
cmIndex
)
;
}
return
null
;
}
...
...
protogeni/demo/src/RequestSliverUpdate.as
View file @
7b355473
...
...
@@ -34,6 +34,7 @@ package
override
public
function
start
(
credential
:
Credential
)
:
Operation
{
nodes
.
changeState
(
cmIndex
,
ActiveNodes
.
PLANNED
,
ActiveNodes
.
CREATED
)
;
opName
=
"Updating Sliver"
;
op
.
reset
(
Geni
.
updateSliver
)
;
op
.
addField
(
"credential"
,
credential
.
slivers
[
cmIndex
])
;
...
...
@@ -48,11 +49,11 @@ package
{
if
(
code
==
0
)
{
nodes
.
c
hange
State
(
cmIndex
,
ActiveNodes
.
CREATED
)
;
nodes
.
c
ommit
State
(
cmIndex
)
;
}
else
{
nodes
.
change
State
(
cmIndex
,
ActiveNodes
.
FAILED
)
;
nodes
.
revert
State
(
cmIndex
)
;
}
return
null
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment