@@ -29,13 +29,17 @@ class InvalidDomainException(Exception):
2929 pass
3030
3131
32+ class InvalidINSecureValue (Exception ):
33+ pass
34+
35+
3236class OpenstackResource (object ):
3337 service_type = None
3438 resource_type = None
3539
3640 def __init__ (self , client_config , resource_config = None , logger = None ):
3741 self .client_config = client_config
38- self .configure_ca_cert ()
42+ self .configure_ssl ()
3943 self .logger = logger
4044 self .connection = openstack .connect (** client_config )
4145 self .config = resource_config or {}
@@ -63,10 +67,28 @@ def validate_keystone_v3(self):
6367 pattern = pattern + '({0}, {1}),' .format (item [0 ], item [1 ])
6468 raise InvalidDomainException (message .format (pattern ))
6569
66- def configure_ca_cert (self ):
70+ def configure_ssl (self ):
71+ self ._configure_ca_cert ()
72+ self ._configure_insecure ()
73+
74+ def _configure_ca_cert (self ):
6775 if self .client_config .get ('ca_cert' ):
6876 self .client_config ['cacert' ] = self .client_config .pop ('ca_cert' )
6977
78+ def _configure_insecure (self ):
79+ insecure = self .client_config .get ('insecure' , False )
80+ bool_str = {
81+ 'True' : True ,
82+ 'False' : False ,
83+ }
84+ if isinstance (insecure , basestring ):
85+ insecure = bool_str .get (insecure .capitalize ())
86+ if not isinstance (insecure , bool ):
87+ raise InvalidINSecureValue (
88+ 'Invalid insecure value {0}.'
89+ 'It must be boolean' .format (insecure ))
90+ self .client_config ['insecure' ] = insecure
91+
7092 def get_project_id_by_name (self , project_name = None ):
7193 project_name = project_name or self .project_name
7294 project = self .connection .identity .find_project (project_name )
0 commit comments