disk.tcl 2.12 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- tcl -*-
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# All rights reserved.
#

######################################################################
# disk.tcl
#
# This defines the local disk agent.
#
######################################################################

Class Disk -superclass NSObject

namespace eval GLOBALS {
    set new_classes(Disk) {}
    variable all_programs {}
}

Program instproc init {s} {
    global ::GLOBALS::last_class
    global ::GLOBALS::all_programs

    if {$all_programs == {}} {
27
	# Create a default event group to hold all disk agents.
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
	set foo [uplevel \#0 "set __all_programs [new EventGroup $s]"]
	set all_programs $foo
    }
    $all_programs add $self

    $self set sim $s
    $self set node {}
    $self set name {}
    $self set type {}
    $self set mountpoint {}
    $self set params {}

    # Link simulator to this new object.
    $s add_program $self

    set ::GLOBALS::last_class $self
}

Program instproc rename {old new} {
    global ::GLOBALS::all_programs
    $self instvar sim

    $sim rename_program $old $new
    $all_programs rename-agent $old $new
}

# updatedb DB
# This adds rows to the virt_trafgens table corresponding to this agent.
Program instproc updatedb {DB} {
    var_import ::GLOBALS::pid
    var_import ::GLOBALS::eid
    var_import ::TBCOMPAT::objtypes
    $self instvar node
    $self instvar name 
    $self instvar type 
    $self instvar mountpoint 
    $self instvar params 
    $self instvar sim

    if {$node == {}} {
	perror "\[updatedb] $self has no node."
	return
    }
    set progvnode $node

    #
    # if the attached node is a simulated one, we attach the
    # program to the physical node on which the simulation runs
    #
    if {$progvnode != "ops"} {
	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 ]

    $sim spitxml_data "virt_agents" [list "vnode" "vname" "objecttype" ] [list $progvnode $self $objtypes(DISK) ]
}