Revision 63130429 gen-rspec.py

View differences:

gen-rspec.py
11 11

  
12 12
from const import AVAILABLE, COMPONENT_ID, COMPONENT_NAME, FOOTER_TEMPLATE, \
13 13
    HARDWARE_TYPE, HEADER_TEMPLATE, LOCATION, NAME, NODE, NODE_TEMPLATE, NOW, \
14
    TRUE, X, Y, Z
14
    TRUE, X, Y, Z, NETWORK_HEADER, NETWORK_FOOTER, NETWORK_TEMPLATE
15 15

  
16 16

  
17 17
def matches(name, filters, nodes):
......
50 50
    e = it.root
51 51

  
52 52
    t = __import__('%stemplates' % testbed, globals(), locals(),
53
                   [NODE_TEMPLATE, HEADER_TEMPLATE, FOOTER_TEMPLATE])
53
                   [NODE_TEMPLATE, HEADER_TEMPLATE, FOOTER_TEMPLATE, NETWORK_HEADER, NETWORK_FOOTER, NETWORK_TEMPLATE])
54 54
    h = 40
55 55
    w = 120
56 56
    xs = 100
57 57
    ys = 100
58 58

  
59 59
    xml = ""
60
    xmlnetwork = ""
60 61

  
61 62
    for node in e.findall(NODE):
62 63
        name = node.get(COMPONENT_NAME)
......
89 90
            domain = component_id.split("+")[1]
90 91
            hostname = "{}.{}".format(name, domain)
91 92
            xml += t.node_template % \
92
                (name, component_id, xs + col * w, ys + row * h, hw)
93
                (name, component_id, xs + col * w, ys + row * h, name, hw)
94
            xmlnetwork += t.network_template % (name)
93 95
            if dump_file != "":
94 96
                df.write("%s\n" % name)
95 97
            n += 1
96
    return n, xml
98
    return n, xml, xmlnetwork
97 99

  
98 100

  
99 101
parser = ArgumentParser()
......
145 147
dump_file = args.dump
146 148

  
147 149
t = __import__('%stemplates' % testbeds[0], globals(), locals(),
148
               [NODE_TEMPLATE, HEADER_TEMPLATE, FOOTER_TEMPLATE])
150
               [NODE_TEMPLATE, HEADER_TEMPLATE, FOOTER_TEMPLATE, NETWORK_HEADER, NETWORK_FOOTER, NETWORK_TEMPLATE])
149 151

  
150 152
df = None
151 153
if dump_file != "":
......
155 157

  
156 158
n = 0
157 159
for testbed in testbeds:
158
    n, xml = fetch_nodes(testbed, n, use_hardware, filters, nodes, hardware,
160
    n, xmlnode,xmlnetwork = fetch_nodes(testbed, n, use_hardware, filters, nodes, hardware,
159 161
                         dump_file, df)
160
    print(xml)
162
    print(xmlnode)
163
    print(t.network_header)
164
    print(xmlnetwork)
165
    print(t.network_footer)
161 166

  
162 167
print(t.footer_template)
163 168

  

Also available in: Unified diff