Index: fedd/fedd_client.py
===================================================================
--- fedd/fedd_client.py	(revision 5f6c3afc72d2405ddde8d347f99c23c616705beb)
+++ fedd/fedd_client.py	(revision eab6ae177968e0b9b2cbcb7f6e5e2700df9b1a32)
@@ -916,162 +916,4 @@
             sys.exit("Bad response. %s" % e.message)
 
-class ns_image(image):
-    def __init__(self): 
-        """
-        Null constructor
-        """
-
-        image.__init__(self)
-
-    def generate_topo_dict(self, splitout):
-        class topo_parse:
-            """
-            Parse the topology XML and create the dats structure.  This class
-            is copied from federation.experiment_control.
-            """
-            def __init__(self):
-                # Typing of the subelements for data conversion
-                self.str_subelements = ('vname', 'vnode', 'ips', 'ip', 'member')
-                self.int_subelements = ( 'bandwidth',)
-                self.float_subelements = ( 'delay',)
-                # The final data structure
-                self.nodes = [ ]
-                self.lans =  [ ]
-                self.topo = { \
-                        'node': self.nodes,\
-                        'lan' : self.lans,\
-                    }
-                self.element = { }  # Current element being created
-                self.chars = ""     # Last text seen
-
-            def end_element(self, name):
-                # After each sub element the contents is added to the current
-                # element or to the appropriate list.
-                if name == 'node':
-                    self.nodes.append(self.element)
-                    self.element = { }
-                elif name == 'lan':
-                    self.lans.append(self.element)
-                    self.element = { }
-                elif name in self.str_subelements:
-                    self.element[name] = self.chars
-                    self.chars = ""
-                elif name in self.int_subelements:
-                    self.element[name] = int(self.chars)
-                    self.chars = ""
-                elif name in self.float_subelements:
-                    self.element[name] = float(self.chars)
-                    self.chars = ""
-
-            def found_chars(self, data):
-                self.chars += data.rstrip()
-
-
-        tp = topo_parse();
-        parser = xml.parsers.expat.ParserCreate()
-        parser.EndElementHandler = tp.end_element
-        parser.CharacterDataHandler = tp.found_chars
-
-        m = re.search('^#\s+Begin\s+Vtopo\s*$(.*)^#\s+End\s+Vtopo', splitout, 
-                re.MULTILINE | re.DOTALL)
-        if m:
-            str = m.group(1)
-        else:
-            sys.exit("Badly formatted split")
-
-        parser.Parse(str)
-
-        return tp.topo
-
-    def __call__(self):
-        """
-        The control flow.  Compose the request and print the response.
-        """
-        # Process the options using the customized option parser defined above
-        parser = fedd_ns_image_opts()
-
-        (opts, args) = parser.parse_args()
-
-        if opts.trusted:
-            if ( not os.access(opts.trusted, os.R_OK) ) :
-                sys.exit("Cannot read trusted certificates (%s)" % opts.trusted)
-
-        if opts.debug > 0: opts.tracefile=sys.stderr
-
-        (user, cert) = self.get_user_info()
-
-        if opts.cert != None: cert = opts.cert
-
-        if cert == None:
-            sys.exit("No certificate given (--cert) or found")
-
-        if os.access(cert, os.R_OK):
-            fid = fedid(file=cert)
-        else:
-            sys.exit("Cannot read certificate (%s)" % cert)
-
-        if opts.file:
-            exp_desc = ""
-            try:
-                f = open(opts.file, 'r')
-                for line in f:
-                    exp_desc += line
-                f.close()
-            except IOError:
-                sys.exit("Cannot read description file (%s)" %opts.file)
-        else:
-            sys.exit("Must specify an experiment description (--file)")
-
-        if not opts.master:
-            opts.master="dummy"
-
-
-        req = {
-                'description': { 'ns2description': exp_desc },
-                'master': opts.master,
-                'include_fedkit': opts.fedkit,
-                'include_gatewaykit': opts.gatewaykit,
-                }
-
-
-        if opts.format and opts.outfile:
-            fmt = opts.format
-            file = opts.outfile
-        elif not opts.format and opts.outfile:
-            fmt = opts.outfile[-3:]
-            if fmt not in ("png", "jpg", "dot", "svg"):
-                sys.exit("Unexpected file type and no format specified")
-            file = opts.outfile
-        elif opts.format and not opts.outfile:
-            fmt = opts.format
-            file = None
-        else:
-            fmt="dot"
-            file = None
-
-        try:
-            resp_dict = self.do_rpc(req,
-                    opts.url, opts.transport, cert, opts.trusted, 
-                    serialize_only=opts.serialize_only,
-                    tracefile=opts.tracefile,
-		    caller=self.caller('Ns2Split'))
-        except self.RPCException, e:
-            exit_with_fault(\
-                    {'desc': e.desc, 'errstr': e.errstr, 'code': e.code})
-        except RuntimeError, e:
-            sys.exit("Error processing RPC: %s" % e)
-
-
-        if resp_dict.has_key('output'):
-            if len(resp_dict['output']) < 1:
-                sys.exit("Bad response: could not split")
-            topo = self.generate_topo_dict(resp_dict['output'])
-            self.gen_image(topo, len(topo.get('node', [])), file, fmt,
-                    opts.neato, opts.labels, opts.pixels)
-	elif opts.serialze_only:
-	    sys.exit(0)
-        else:
-            sys.exit("Bad response. %s" % e.message)
-
 class topdl_image(image):
     def __init__(self): 
@@ -1181,4 +1023,97 @@
         self.gen_image(top, len(top.elements), file, fmt, opts.neato, 
                 opts.labels, opts.pixels)
+
+class ns_image(topdl_image):
+    def __init__(self): 
+        """
+        Null constructor
+        """
+
+        topdl_image.__init__(self)
+
+    def __call__(self):
+        """
+        The control flow.  Compose the request and print the response.
+        """
+        # Process the options using the customized option parser defined above
+        parser = fedd_ns_image_opts()
+
+        (opts, args) = parser.parse_args()
+
+        if opts.trusted:
+            if ( not os.access(opts.trusted, os.R_OK) ) :
+                sys.exit("Cannot read trusted certificates (%s)" % opts.trusted)
+
+        if opts.debug > 0: opts.tracefile=sys.stderr
+
+        (user, cert) = self.get_user_info()
+
+        if opts.cert != None: cert = opts.cert
+
+        if cert == None:
+            sys.exit("No certificate given (--cert) or found")
+
+        if os.access(cert, os.R_OK):
+            fid = fedid(file=cert)
+        else:
+            sys.exit("Cannot read certificate (%s)" % cert)
+
+        if opts.file:
+            exp_desc = ""
+            try:
+                f = open(opts.file, 'r')
+                for line in f:
+                    exp_desc += line
+                f.close()
+            except IOError:
+                sys.exit("Cannot read description file (%s)" %opts.file)
+        else:
+            sys.exit("Must specify an experiment description (--file)")
+
+        if not opts.master:
+            opts.master="dummy"
+
+        req = { 'description': { 'ns2description': exp_desc }, }
+
+        if opts.format and opts.outfile:
+            fmt = opts.format
+            file = opts.outfile
+        elif not opts.format and opts.outfile:
+            fmt = opts.outfile[-3:]
+            if fmt not in ("png", "jpg", "dot", "svg"):
+                sys.exit("Unexpected file type and no format specified")
+            file = opts.outfile
+        elif opts.format and not opts.outfile:
+            fmt = opts.format
+            file = None
+        else:
+            fmt="dot"
+            file = None
+
+        try:
+            resp_dict = self.do_rpc(req,
+                    opts.url, opts.transport, cert, opts.trusted, 
+                    serialize_only=opts.serialize_only,
+                    tracefile=opts.tracefile,
+		    caller=self.caller('Ns2Topdl'))
+        except self.RPCException, e:
+            exit_with_fault(\
+                    {'desc': e.desc, 'errstr': e.errstr, 'code': e.code})
+        except RuntimeError, e:
+            sys.exit("Error processing RPC: %s" % e)
+
+
+        if 'experimentdescription' in resp_dict:
+	    if 'topdldescription' in resp_dict['experimentdescription']:
+		exp = resp_dict['experimentdescription']['topdldescription']
+		top = topdl.Topology(**exp)
+		self.gen_image(top, len(top.elements), file, fmt, opts.neato, 
+			opts.labels, opts.pixels)
+	    else:
+                sys.exit("Bad response: could not translate")
+	elif opts.serialze_only:
+	    sys.exit(0)
+        else:
+            sys.exit("Bad response. %s" % e.message)
 
 class terminate(fedd_rpc):
