@ -11,7 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from keystone client import exceptions
from keystone auth1 import exceptions as ks_ exceptions
from heat . common import exception
from heat . engine . clients import client_plugin
@ -20,7 +20,7 @@ from heat.engine.clients.os.keystone import heat_keystoneclient as hkc
class KeystoneClientPlugin ( client_plugin . ClientPlugin ) :
exceptions_module = exceptions
exceptions_module = [ ks_ exceptions, exception ]
service_types = [ IDENTITY ] = [ ' identity ' ]
@ -28,19 +28,20 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
return hkc . KeystoneClient ( self . context )
def is_not_found ( self , ex ) :
return isinstance ( ex , exceptions . NotFound )
return isinstance ( ex , ( ks_exceptions . NotFound ,
exception . EntityNotFound ) )
def is_over_limit ( self , ex ) :
return isinstance ( ex , exceptions. RequestEntityTooLarge )
return isinstance ( ex , ks_ exceptions. RequestEntityTooLarge )
def is_conflict ( self , ex ) :
return isinstance ( ex , exceptions. Conflict )
return isinstance ( ex , ks_ exceptions. Conflict )
def get_role_id ( self , role ) :
try :
role_obj = self . client ( ) . client . roles . get ( role )
return role_obj . id
except exceptions. NotFound :
except ks_ exceptions. NotFound :
role_list = self . client ( ) . client . roles . list ( name = role )
for role_obj in role_list :
if role_obj . name == role :
@ -54,7 +55,7 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
try :
project_obj = self . client ( ) . client . projects . get ( project )
return project_obj . id
except exceptions. NotFound :
except ks_ exceptions. NotFound :
project_list = self . client ( ) . client . projects . list ( name = project )
for project_obj in project_list :
if project_obj . name == project :
@ -69,7 +70,7 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
try :
domain_obj = self . client ( ) . client . domains . get ( domain )
return domain_obj . id
except exceptions. NotFound :
except ks_ exceptions. NotFound :
domain_list = self . client ( ) . client . domains . list ( name = domain )
for domain_obj in domain_list :
if domain_obj . name == domain :
@ -83,7 +84,7 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
try :
group_obj = self . client ( ) . client . groups . get ( group )
return group_obj . id
except exceptions. NotFound :
except ks_ exceptions. NotFound :
group_list = self . client ( ) . client . groups . list ( name = group )
for group_obj in group_list :
if group_obj . name == group :
@ -97,7 +98,7 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
try :
service_obj = self . client ( ) . client . services . get ( service )
return service_obj . id
except exceptions. NotFound :
except ks_ exceptions. NotFound :
service_list = self . client ( ) . client . services . list ( name = service )
if len ( service_list ) == 1 :
@ -114,7 +115,7 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
try :
user_obj = self . client ( ) . client . users . get ( user )
return user_obj . id
except exceptions. NotFound :
except ks_ exceptions. NotFound :
user_list = self . client ( ) . client . users . list ( name = user )
for user_obj in user_list :
if user_obj . name == user :
@ -126,6 +127,6 @@ class KeystoneClientPlugin(client_plugin.ClientPlugin):
try :
region_obj = self . client ( ) . client . regions . get ( region )
return region_obj . id
except exceptions. NotFound :
except ks_ exceptions. NotFound :
raise exception . EntityNotFound ( entity = ' KeystoneRegion ' ,
name = region )