openconnect: Fix connect-vpn and plugin indentation
[framework/connectivity/connman.git] / test / connect-vpn
1 #!/usr/bin/python
2
3 import sys
4 import dbus
5
6 if (len(sys.argv) < 4):
7         print "Usage: %s <type> ... " % (sys.argv[0])
8         print "  type: openconnect"
9         print "      <name> <host> <domain> <cookie> [servercert]"
10         print "  type: openvpn"
11         print "      <name> <host> <domain> <cafile> <certfile> <keyfile>"
12         sys.exit(1)
13
14 bus = dbus.SystemBus()
15
16 manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
17                                         "org.moblin.connman.Manager")
18
19 print "Attempting to connect service %s" % (sys.argv[3])
20
21 if sys.argv[1] == "openconnect":
22         if (len(sys.argv) > 6):
23                 path = manager.ConnectProvider(({ "Type": "openconnect",
24                                         "Name": sys.argv[2],
25                                         "Host": sys.argv[3],
26                                         "VPN.Domain": sys.argv[4],
27                                         "OpenConnect.Cookie": sys.argv[5],
28                                         "OpenConnect.ServerCert": sys.argv[6]}))
29         else:
30                 path = manager.ConnectProvider(({ "Type": "openconnect",
31                                         "Name": sys.argv[2],
32                                         "Host": sys.argv[3],
33                                         "VPN.Domain": sys.argv[4],
34                                         "OpenConnect.Cookie": sys.argv[5]}))
35 elif sys.argv[1] == "openvpn":
36         path = manager.ConnectProvider(({ "Type": "openvpn",
37                                         "Name": sys.argv[2],
38                                         "Host": sys.argv[3],
39                                         "VPN.Domain": sys.argv[4],
40                                         "OpenVPN.CACert": sys.argv[5],
41                                         "OpenVPN.Cert": sys.argv[6],
42                                         "OpenVPN.Key": sys.argv[7]}))
43 else:
44         print "Unknown VPN type"
45         sys.exit(1)
46
47 print "VPN service path is %s" %(path)