- Timestamp:
- May 17, 2010 5:39:01 AM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 2e0a952
- Parents:
- eab6ae1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_client.py
reab6ae1 rf00fb7d 220 220 self.add_option("--file", dest="file", 221 221 help="experiment description file") 222 223 class fedd_ns_topdl_opts(fedd_client_opts): 224 def __init__(self): 225 fedd_client_opts.__init__(self) 226 self.add_option("--file", dest="file", 227 help="experiment description file") 228 self.add_option("--output", dest="outfile", type="string", 229 help="output topdl file") 222 230 223 231 def exit_with_fault(dict, out=sys.stderr): … … 1844 1852 print resp_dict 1845 1853 1854 class ns_topdl(fedd_rpc): 1855 def __init__(self): 1856 fedd_rpc.__init__(self) 1857 def __call__(self): 1858 # Process the options using the customized option parser defined above 1859 parser = fedd_ns_topdl_opts() 1860 1861 (opts, args) = parser.parse_args() 1862 1863 if opts.trusted: 1864 if ( not os.access(opts.trusted, os.R_OK) ) : 1865 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 1866 1867 if opts.debug > 0: opts.tracefile=sys.stderr 1868 1869 (user, cert) = self.get_user_info() 1870 1871 if opts.cert != None: cert = opts.cert 1872 1873 if cert == None: 1874 sys.exit("No certificate given (--cert) or found") 1875 1876 if os.access(cert, os.R_OK): 1877 fid = fedid(file=cert) 1878 else: 1879 sys.exit("Cannot read certificate (%s)" % cert) 1880 1881 if opts.file: 1882 try: 1883 f = open(opts.file,"r") 1884 contents = "".join(f) 1885 f.close() 1886 except EnvironmentError, e: 1887 sys.exit("Can't read %s: %s" % (opts.file, e)) 1888 else: 1889 sys.exit("Must specify an experiment description (--file)") 1890 1891 msg = { 'description': { 'ns2description': contents }, } 1892 1893 if opts.debug > 1: print >>sys.stderr, msg 1894 1895 try: 1896 resp_dict = self.do_rpc(msg, 1897 opts.url, opts.transport, cert, opts.trusted, 1898 serialize_only=opts.serialize_only, 1899 tracefile=opts.tracefile, 1900 caller=self.caller('Ns2Topdl')) 1901 except self.RPCException, e: 1902 exit_with_fault(\ 1903 {'desc': e.desc, 'errstr': e.errstr, 'code': e.code}) 1904 except RuntimeError, e: 1905 sys.exit("Error processing RPC: %s" % e) 1906 1907 if 'experimentdescription' in resp_dict: 1908 if 'topdldescription' in resp_dict['experimentdescription']: 1909 exp = resp_dict['experimentdescription']['topdldescription'] 1910 top = topdl.Topology(**exp) 1911 else: 1912 sys.exit("Bad response: could not translate") 1913 elif opts.serialze_only: 1914 sys.exit(0) 1915 else: 1916 sys.exit("Bad response. %s" % e.message) 1917 1918 if opts.outfile: 1919 try: 1920 f = open(opts.outfile, "w") 1921 print >>f, topdl.topology_to_xml(top, top="experiment") 1922 f.close() 1923 except EnvironmentError, e: 1924 sys.exit("Can't write to %s: %s" % (opts.outfile, e)) 1925 else: 1926 print topdl.topology_to_xml(top, top="experiment") 1927 1846 1928 cmds = {\ 1847 1929 'new': new(),\ … … 1863 1945 'start_segment': start_segment(),\ 1864 1946 'terminate_segment': terminate_segment(),\ 1947 'ns_topdl': ns_topdl(),\ 1865 1948 } 1866 1949 if len(sys.argv) > 1:
Note: See TracChangeset
for help on using the changeset viewer.