Commit a87350b4 authored by Yathindra Naik's avatar Yathindra Naik
Browse files

Fixed few bugs and removed custom agent

parent add9774a
......@@ -15,12 +15,12 @@ SUBDIR = tbsetup/ns2ir
include $(OBJDIR)/Makeconf
LIB_STUFF = lanlink.tcl node.tcl sim.tcl tb_compat.tcl null.tcl \
nsobject.tcl traffic.tcl vtype.tcl parse.tcl program.tcl \
nsenode.tcl nstb_compat.tcl event.tcl firewall.tcl \
elabinelab.ns elabinelab-withfsnode.ns elabinelab-opsvm.ns \
fw.ns timeline.tcl sequence.tcl elabinelab-xen.ns \
topography.tcl console.tcl path.tcl \
disk.tcl custom.tcl
nsobject.tcl traffic.tcl vtype.tcl parse.tcl program.tcl \
nsenode.tcl nstb_compat.tcl event.tcl firewall.tcl \
elabinelab.ns elabinelab-withfsnode.ns elabinelab-opsvm.ns \
fw.ns timeline.tcl sequence.tcl \
topography.tcl console.tcl path.tcl \
disk.tcl
BOSSLIBEXEC = parse-ns
USERLIBEXEC = parse.proxy
......
......@@ -27,6 +27,7 @@ Disk instproc init {s} {
$self set type {}
$self set mountpoint {}
$self set params {}
$self set cmd {}
# Link simulator to this new object.
$s add_disk $self
......@@ -52,10 +53,11 @@ Disk instproc updatedb {DB} {
$self instvar mountpoint
$self instvar params
$self instvar sim
$self instvar cmd
if {$node == {}} {
perror "\[updatedb] $self has no node."
return
perror "\[updatedb] $self has no node."
return
}
set progvnode $node
......@@ -64,13 +66,13 @@ Disk instproc updatedb {DB} {
# program to the physical node on which the simulation runs
#
if {$progvnode != "ops"} {
if { [$node set simulated] == 1 } {
set progvnode [$node set nsenode]
}
if { [$node set simulated] == 1 } {
set progvnode [$node set nsenode]
}
}
# Update the DB
spitxml_data "virt_disk" [list "vnode" "vname" "name" "type" "mountpoint" "params"] [list $progvnode $self $name $type $mountpoint $params ]
spitxml_data "virt_disk" [list "vnode" "vname" "name" "type" "mountpoint" "params" "cmd"] [list $progvnode $self $name $type $mountpoint $params $cmd]
$sim spitxml_data "virt_agents" [list "vnode" "vname" "objecttype" ] [list $progvnode $self $objtypes(DISK) ]
}
......
......@@ -708,38 +708,21 @@ Node instproc program-agent {args} {
Node instproc disk-agent {args} {
set curdisk [new Disk [$self set sim]]
if {$(-name) == {} && $(-type) == {} && $(-mountpoint) == {} && $(-params) == {}} {
return $curdisk
}
::GLOBALS::named-args $args {
-name {} -type {} -mountpoint {} -params {}
-name {} -type {} -mountpoint {} -params {} -cmd {}
}
set curdisk [new Disk [$self set sim]]
$curdisk set node $self
$curdisk set name $(-name)
$curdisk set type $(-type)
$curdisk set mountpoint "{$(-mountpoint)}"
$curdisk set params "{$(-params)}"
$curdisk set mountpoint $(-mountpoint)
$curdisk set params $(-params)
$curdisk set cmd $(-cmd)
return $curdisk
}
Node instproc custom-agent {args} {
::GLOBALS::named-args $args {
-name {}
}
set customagent [new Custom [$self set sim]]
$customagent set node $self
$customagent set name $(-name)
return $customagent
}
Node instproc topography {topo} {
var_import ::TBCOMPAT::location_info
$self instvar sim
......
......@@ -377,7 +377,6 @@ source ${GLOBALS::libdir}/sequence.tcl
source ${GLOBALS::libdir}/console.tcl
source ${GLOBALS::libdir}/topography.tcl
source ${GLOBALS::libdir}/disk.tcl
source ${GLOBALS::libdir}/custom.tcl
##################################################
# Redifing Assignment
......
......@@ -24,7 +24,6 @@
Class Simulator
Class Program -superclass NSObject
Class Disk -superclass NSObject
Class Custom -superclass NSObject
Class EventGroup -superclass NSObject
Class Firewall -superclass NSObject
......@@ -74,10 +73,6 @@ Simulator instproc init {args} {
$self instvar disk_list;
array set disk_list {}
#Custom list.
$self instvar custom_list;
array set custom_list {}
# EventGroup list.
$self instvar eventgroup_list;
array set eventgroup_list {}
......@@ -406,7 +401,6 @@ Simulator instproc run {} {
$self instvar event_list
$self instvar prog_list
$self instvar disk_list
$self instvar custom_list
$self instvar eventgroup_list
$self instvar firewall_list
$self instvar timeline_list
......@@ -631,9 +625,6 @@ Simulator instproc run {} {
foreach disk [array names disk_list] {
$disk updatedb "sql"
}
foreach custom [array names custom_list] {
$custom updatedb "sql"
}
foreach egroup [array names eventgroup_list] {
$egroup updatedb "sql"
}
......@@ -1037,12 +1028,6 @@ Simulator instproc rename_disk {old new} {
set disk_list($new) {}
}
Simulator instproc rename_custom {old new} {
$self instvar custom_list
unset custom_list($old)
set custom_list($new) {}
}
Simulator instproc rename_eventgroup {old new} {
$self instvar eventgroup_list
unset eventgroup_list($old)
......@@ -1247,13 +1232,6 @@ Simulator instproc add_disk {disk} {
set disk_list($disk) {}
}
# add_custom
# Link to a new custom object.
Simulator instproc add_custom {custom} {
$self instvar custom_list
set custom_list($custom) {}
}
# add_eventgroup
# Link to a EventGroup object.
Simulator instproc add_eventgroup {group} {
......@@ -1752,89 +1730,76 @@ Simulator instproc make_event {outer event} {
}
}
}
"Disk" {
set otype DISK
set vname $obj
set vnode [$obj set node]
"Disk" {
set otype DISK
set vname $obj
set vnode [$obj set node]
switch -- $cmd {
"set" -
"run" -
"start" {
switch -- $cmd {
"set" -
"run" -
"start" {
switch -- $cmd {
"set" {
set etype START
}
"run" {
set etype RUN
}
"start" {
set etype START
}
}
::GLOBALS::named-args $evargs [list \
-name {} \
-type {} \
-mountpoint {} \
-params {} \
]
if {$(-name) == {} || $(-type) == {} || $(-mountpoint) == {}} {
perror "Improper argument: at $(-name) or $(-type) or $(-mountpoint)"
return
}
if {$(-name) != {}} {
set args "NAME={$(-name)} "
}
if {$(-type) != {}} {
set args "${args}TYPE=$(-type) "
}
if {$(-mountpoint) != {}} {
set args "${args}MOUNTPOINT=$(-mountpoint) "
}
if {$(-params) != {}} {
set args "${args}PARAMS=$(-params)"
}
}
"set" {
set etype START
}
"run" {
set etype RUN
}
"start" {
set etype START
}
}
#The initial arguments for disk-agent through NS
set default_name [$obj set name]
set default_type [$obj set type]
set default_mountpoint [$obj set mountpoint]
set default_params [$obj set params]
::GLOBALS::named-args $evargs [list \
-name $default_name \
-type $default_type \
-mountpoint $default_mountpoint \
-params $default_params \
]
if {$(-name) != {}} {
set args "NAME=$(-name) "
}
if {$(-type) != {}} {
set args "${args}TYPE=$(-type) "
}
if {$(-mountpoint) != {}} {
set args "${args}MOUNTPOINT=$(-mountpoint) "
}
if {$(-params) != {}} {
set args "${args}PARAMS=$(-params)"
}
#DEBUG
puts stdout "$args"
}
"create" {
if {[llength $event] < 6} {
perror "Wrong number of arguments: at $time $event"
return
}
set args [lindex $event 2]
set etype CREATE
}
set default_cmd [$obj set cmd]
set args $default_cmd
#DEBUG
puts stdout "$args"
set etype CREATE
}
"modify" {
if {[llength $event] < 6} {
perror "Wrong number of arguments: at $time $event"
return
}
set args [lindex $event 2]
set default_cmd [$obj set cmd]
set args $default_cmd
#DEBUG
puts stdout "$args"
set etype MODIFY
}
unknown {
punsup "$obj $cmd $args"
return
}
}
}
"Custom" {
set otype CUSTOM
set vname $obj
switch -- $cmd {
"start" {
set etype START
set args [lindex $event 2]
}
"stop" {
set etype STOP
if {[llength $event] < 3} {
perror "Wrong number of arguments: $obj $cmd $evargs"
return
}
set args [lindex $event 2]
}
}
}
unknown {
punsup "$obj $cmd $args"
return
}
}
}
"Console" {
set otype CONSOLE
set vname $obj
......
Supports Markdown
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