Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2164 from eucalyptus/GUI-2839
Browse files Browse the repository at this point in the history
GUI-2839: Allow broken cookie to be cleared (following console restart) when GovCloud region is mistakenly enabled
  • Loading branch information
dkavanagh authored Jan 31, 2017
2 parents 78ef10a + d555058 commit 64b796a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
9 changes: 3 additions & 6 deletions eucaconsole/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,10 @@ def __init__(self, context, request):
self.has_regions = True
self.default_region = ''
if self.cloud_type == 'aws':
self.regions = AWS_REGIONS
if asbool(request.registry.settings.get('aws.govcloud.enabled', 'false')):
self.regions.append(dict(
name='us-gov-west-1',
label='US GovCloud',
))
self.default_region = request.registry.settings.get('aws.default.region', 'us-east-1')
self.regions = list(AWS_REGIONS)
if asbool(request.registry.settings.get('aws.govcloud.enabled', 'false')):
self.regions.append(dict(name='us-gov-west-1', label='US GovCloud'))
else:
if self.access_id:
host = self.request.registry.settings.get('ufshost')
Expand Down
7 changes: 7 additions & 0 deletions eucaconsole/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"""
import simplejson as json

from pyramid.httpexceptions import HTTPFound
from pyramid.security import forget
from pyramid.view import view_config
from boto.exception import BotoServerError

Expand Down Expand Up @@ -69,6 +71,11 @@ def __init__(self, request):

@view_config(route_name='dashboard', request_method='GET', renderer='../templates/dashboard.pt')
def dashboard_home(self):
if self.conn is None:
# Handle broken connection case (e.g. configured AWS GovCloud region without proper access)
forget(self.request)
self.request.session.delete()
return HTTPFound(location=self.request.route_path('login'))
with boto_error_handler(self.request):
availability_zones = ChoicesManager(self.conn).get_availability_zones(self.conn.host)
alarms_triggered = self.get_connection(conn_type='cloudwatch').describe_alarms(state_value="ALARM")
Expand Down
8 changes: 7 additions & 1 deletion eucaconsole/views/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import logging
from boto.exception import BotoServerError
from pyramid.httpexceptions import HTTPFound
from pyramid.security import forget
from pyramid.view import view_config

from . import BaseView
Expand All @@ -54,9 +55,14 @@ def select_region(self):
session = self.request.session
session['region'] = region
try:
conn = self.get_connection(conn_type='vpc')
if conn is None:
# Handle broken connection case (e.g. configured AWS GovCloud region without proper access)
forget(self.request)
self.request.session.delete()
return HTTPFound(location=self.request.route_path('login'))
session['supported_platforms'] = self.get_account_attributes(['supported-platforms'])
session['default_vpc'] = self.get_account_attributes(['default-vpc'])
conn = self.get_connection(conn_type='vpc')
vpcs = conn.get_all_vpcs()
if not vpcs or len(vpcs) == 0:
# remove vpc from supported-platforms
Expand Down

0 comments on commit 64b796a

Please sign in to comment.