33
44from juju .client ._definitions import *
55
6- from juju .client import _client2 , _client1 , _client3 , _client4 , _client5 , _client8 , _client7 , _client9 , _client10 , _client6 , _client12 , _client11 , _client13 , _client15 , _client16 , _client17 , _client18
6+ from juju .client .old_clients import _client2 as _2_9_client2
7+ from juju .client .old_clients import _client1 as _2_9_client1
8+ from juju .client .old_clients import _client3 as _2_9_client3
9+ from juju .client .old_clients import _client4 as _2_9_client4
10+ from juju .client .old_clients import _client5 as _2_9_client5
11+ from juju .client .old_clients import _client8 as _2_9_client8
12+ from juju .client .old_clients import _client7 as _2_9_client7
13+ from juju .client .old_clients import _client9 as _2_9_client9
14+ from juju .client .old_clients import _client10 as _2_9_client10
15+ from juju .client .old_clients import _client6 as _2_9_client6
16+ from juju .client .old_clients import _client12 as _2_9_client12
17+ from juju .client .old_clients import _client11 as _2_9_client11
18+ from juju .client .old_clients import _client13 as _2_9_client13
19+ from juju .client .old_clients import _client15 as _2_9_client15
20+ from juju .client .old_clients import _client16 as _2_9_client16
21+ from juju .client .old_clients import _client17 as _2_9_client17
22+ from juju .client .old_clients import _client18 as _2_9_client18
23+ from juju .client .old_clients import _client14 as _2_9_client14
24+
25+ from juju .client import _client2 , _client1 , _client3 , _client4 , _client5 , _client8 , _client7 , _client9 , _client10 , _client6 , _client12 , _client11 , _client13 , _client15 , _client16 , _client17 , _client18 , _client14
726
827
928CLIENTS = {
2342 "15" : _client15 ,
2443 "16" : _client16 ,
2544 "17" : _client17 ,
26- "18" : _client18
45+ "18" : _client18 ,
46+ "14" : _client14
2747}
2848
2949
50+ OLD_CLIENTS = {
51+ "2" : _2_9_client2 ,
52+ "1" : _2_9_client1 ,
53+ "3" : _2_9_client3 ,
54+ "4" : _2_9_client4 ,
55+ "5" : _2_9_client5 ,
56+ "8" : _2_9_client8 ,
57+ "7" : _2_9_client7 ,
58+ "9" : _2_9_client9 ,
59+ "10" : _2_9_client10 ,
60+ "6" : _2_9_client6 ,
61+ "12" : _2_9_client12 ,
62+ "11" : _2_9_client11 ,
63+ "13" : _2_9_client13 ,
64+ "15" : _2_9_client15 ,
65+ "16" : _2_9_client16 ,
66+ "17" : _2_9_client17 ,
67+ "18" : _2_9_client18 ,
68+ "14" : _2_9_client14
69+ }
70+
3071
31- def lookup_facade (name , version ):
72+ def lookup_facade (name , version , is_2_9 = False ):
3273 """
3374 Given a facade name and version, attempt to pull that facade out
3475 of the correct client<version>.py file.
3576
3677 """
3778 for _version in range (int (version ), 0 , - 1 ):
3879 try :
39- facade = getattr (CLIENTS [str (_version )], name )
80+ client_directory = OLD_CLIENTS if is_2_9 else CLIENTS
81+ facade = getattr (client_directory [str (_version )], name )
4082 return facade
4183 except (KeyError , AttributeError ):
4284 continue
@@ -45,7 +87,6 @@ def lookup_facade(name, version):
4587 "{}" .format (name ))
4688
4789
48-
4990class TypeFactory :
5091 @classmethod
5192 def from_connection (cls , connection ):
@@ -66,7 +107,8 @@ def from_connection(cls, connection):
66107 raise Exception ('No facade {} in facades {}' .format (facade_name ,
67108 connection .facades ))
68109
69- c = lookup_facade (cls .__name__ , version )
110+ server_version = connection .info ['server-version' ]
111+ c = lookup_facade (cls .__name__ , version , server_version .startswith ('2.9' ))
70112 c = c ()
71113 c .connect (connection )
72114
0 commit comments