示例#1
0
            def __getitem__(self, key):
                try:
                    if key not in self.support_console_types:
                        raise exceptions.UnsupportedConsoleType(key)
                    if key == 'webmks':
                        data = nc().servers.get_console_url(server, key)
                    else:
                        data = self.console_method(key)
                    console_data = data.get('remote_console',
                                            data.get('console'))
                    url = console_data['url']
                except exceptions.UnsupportedConsoleType as ex:
                    url = ex.message
                except Exception as e:
                    url = _('Cannot get console url: %s') % str(e)

                return url
示例#2
0
文件: nova.py 项目: aaratn/heat
            def __getitem__(self, key):
                try:
                    if key not in self.support_console_types:
                        raise exceptions.UnsupportedConsoleType(key)
                    if key == 'webmks':
                        data = nc(mks_version).servers.get_console_url(
                            server, key)
                    else:
                        data = self.console_method(key)
                    console_data = data.get(
                        'remote_console', data.get('console'))
                    url = console_data['url']
                except exceptions.UnsupportedConsoleType as ex:
                    url = ex.message
                except Exception as e:
                    url = _('Cannot get console url: %s') % six.text_type(e)

                return url
示例#3
0
文件: nova.py 项目: mhe5423914/heat
 def __getitem__(self, key):
     try:
         if key not in self.support_console_types:
             raise exceptions.UnsupportedConsoleType(key)
         if key == 'webmks':
             data = nc(mks_version).servers.get_console_url(
                 server, key)
         else:
             data = self.console_method(key)
         console_data = data.get('remote_console',
                                 data.get('console'))
         url = console_data['url']
     except (exceptions.BadRequest,
             exceptions.UnsupportedConsoleType) as e:
         unavailable = 'Unavailable console type'
         unsupport = 'Unsupported console_type'
         if unavailable in e.message or unsupport in e.message:
             url = e.message
         else:
             raise
     except exception.InvalidServiceVersion:
         url = _('Nova service version %s is '
                 'unavailable') % mks_version
     return url