Example #1
0
def extend_with_root_redirects(patterns_obj, filled_services, service_type,
                               base_path):
    """
    Append additional redirect url entries for `/` and `/<base_path>` paths.

    `/` redirects to `/<base_path>` and `/<base_path>` to the resolved service
    type url.

    This is used in synnefo components root urlpatterns to append sane default
    redirects to the chosen service url.

    """
    service_url = get_public_endpoint(filled_services, service_type)
    root_url_entry = None
    if base_path and base_path != '/':
        # redirect slash to /<base_path>/
        root_url_entry = url(
            '^$', 'redirect_to',
            {'url': join_urls('/', base_path.rstrip('/'), '/')})

    base_path_pattern = prefix_pattern(base_path) + '$'
    base_path_pattern_no_slash = prefix_pattern(base_path).rstrip('/') + '$'

    # redirect /<base_path> and /<base_path>/ to service_url public endpoint
    base_url_entry = url(base_path_pattern, 'redirect_to',
                         {'url': service_url})
    base_url_entry_no_slash = url(base_path_pattern_no_slash, 'redirect_to',
                                  {'url': service_url})
    # urls order matter. Setting base_url_entry first allows us to avoid
    # redirect loops when base_path is empty or `/`
    patterns_obj += patterns('django.views.generic.simple', base_url_entry,
                             base_url_entry_no_slash)
    if root_url_entry:
        # register root entry only for non root base_path deployments
        patterns_obj += patterns('django.views.generic.simple', root_url_entry)
Example #2
0
def extend_with_root_redirects(patterns_obj,
                               filled_services,
                               service_type,
                               base_path,
                               with_slash=True):
    """
    Append additional redirect url entries for `/` and `/<base_path>` paths.

    `/` redirects to `/<base_path>` and `/<base_path>` to the resolved service
    type url.

    This is used in synnefo components root urlpatterns to append sane default
    redirects to the chosen service url.

    """
    service_path = get_service_path(filled_services, service_type)
    if with_slash:
        service_path = service_path.rstrip('/') + '/'

    root_url_entry = None
    if base_path and base_path != '/':
        # redirect slash to /<base_path>/
        joined_url = join_urls('/', base_path.rstrip('/'), '/')
        root_url_entry = url('^$', RedirectView.as_view(url=joined_url))

    base_path_pattern = prefix_pattern(base_path) + '$'
    base_path_pattern_no_slash = prefix_pattern(base_path).rstrip('/') + '$'

    # redirect /<base_path> and /<base_path>/ to service_path public endpoint
    base_url_entry = url(base_path_pattern,
                         RedirectView.as_view(url=service_path))
    base_url_entry_no_slash = url(base_path_pattern_no_slash,
                                  RedirectView.as_view(url=service_path))
    # urls order matter. Setting base_url_entry first allows us to avoid
    # redirect loops when base_path is empty or `/`
    patterns_obj += patterns('', base_url_entry, base_url_entry_no_slash)
    if root_url_entry:
        # register root entry only for non root base_path deployments
        patterns_obj += patterns('', root_url_entry)
Example #3
0
def extend_with_root_redirects(patterns_obj, filled_services, service_type,
                               base_path, with_slash=True):
    """
    Append additional redirect url entries for `/` and `/<base_path>` paths.

    `/` redirects to `/<base_path>` and `/<base_path>` to the resolved service
    type url.

    This is used in synnefo components root urlpatterns to append sane default
    redirects to the chosen service url.

    """
    service_path = get_service_path(filled_services, service_type)
    if with_slash:
        service_path = service_path.rstrip('/') + '/'

    root_url_entry = None
    if base_path and base_path != '/':
        # redirect slash to /<base_path>/
        root_url_entry = url('^$', 'redirect_to',
                             {'url': join_urls('/', base_path.rstrip('/'),
                                               '/')})

    base_path_pattern = prefix_pattern(base_path) + '$'
    base_path_pattern_no_slash = prefix_pattern(base_path).rstrip('/') + '$'

    # redirect /<base_path> and /<base_path>/ to service_path public endpoint
    base_url_entry = url(base_path_pattern, 'redirect_to', {'url':
                                                            service_path})
    base_url_entry_no_slash = url(base_path_pattern_no_slash,
                                  'redirect_to', {'url': service_path})
    # urls order matter. Setting base_url_entry first allows us to avoid
    # redirect loops when base_path is empty or `/`
    patterns_obj += patterns('django.views.generic.simple',
                             base_url_entry, base_url_entry_no_slash)
    if root_url_entry:
        # register root entry only for non root base_path deployments
        patterns_obj += patterns('django.views.generic.simple', root_url_entry)
Example #4
0
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.

from django.conf.urls.defaults import include, patterns
from synnefo.lib import join_urls
from astakos.im.settings import (BASE_PATH, ACCOUNTS_PREFIX, VIEWS_PREFIX,
                                 KEYSTONE_PREFIX, WEBLOGIN_PREFIX)
from snf_django.lib.api.utils import prefix_pattern
from snf_django.utils.urls import extend_with_root_redirects
from astakos.im import settings

astakos_patterns = patterns(
    '',
    (prefix_pattern(VIEWS_PREFIX), include('astakos.im.urls')),
    (prefix_pattern(ACCOUNTS_PREFIX), include('astakos.api.urls')),
    (prefix_pattern(KEYSTONE_PREFIX), include('astakos.api.keystone_urls')),
    (prefix_pattern(WEBLOGIN_PREFIX), include('astakos.im.weblogin_urls')),
)

urlpatterns = patterns(
    '',
    (prefix_pattern(BASE_PATH), include(astakos_patterns)),
)

# set utility redirects
extend_with_root_redirects(urlpatterns, settings.astakos_services,
                           'astakos_ui', BASE_PATH)
Example #5
0
def extend_path_with_slash(patterns_obj, path):
    if not path.endswith('/'):
        pattern = prefix_pattern(path, append_slash=False) + '$'
        entry = url(pattern, 'redirect_to', {'url': path + '/'})
        patterns_obj += patterns('django.views.generic.simple', entry)
Example #6
0
from snf_django.lib.api import api_endpoint_not_found
from snf_django.utils.urls import extend_path_with_slash

from synnefo_ui.ui_settings import BASE_URL, ASTAKOS_IDENTITY_PROXY_PATH, \
    ASTAKOS_IDENTITY_BASE_URL, ASTAKOS_ACCOUNT_PROXY_PATH, \
    ASTAKOS_ACCOUNT_BASE_URL

proxy_patterns = patterns('')

if ASTAKOS_IDENTITY_PROXY_PATH:
    identity_proxy = \
            partial(proxy, proxy_base=ASTAKOS_IDENTITY_PROXY_PATH,
                                target_base=ASTAKOS_IDENTITY_BASE_URL)
    proxy_patterns += api_patterns(
        '',
        (prefix_pattern(ASTAKOS_IDENTITY_PROXY_PATH), identity_proxy))

if ASTAKOS_ACCOUNT_PROXY_PATH:
    account_proxy = \
            partial(proxy, proxy_base=ASTAKOS_ACCOUNT_PROXY_PATH,
                                target_base=ASTAKOS_ACCOUNT_BASE_URL)
    proxy_patterns += api_patterns(
        '',
        (prefix_pattern(ASTAKOS_ACCOUNT_PROXY_PATH), account_proxy))


ui_patterns = patterns(
    'synnefo_ui.views',
    url(r'^(?P<path>(?!view).*$)', 'app', name='ui-app'),
)
Example #7
0
# Copyright (C) 2010-2014 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
This file can be used as ROOT_URLCONF for Admin-only installations. The Admin
path (BASE_PATH) is constructed from the ADMIN_BASE_URL setting.
"""

from django.conf.urls import patterns, include
from snf_django.utils.urls import extend_path_with_slash
from snf_django.lib.api.utils import prefix_pattern
from synnefo_admin.admin_settings import BASE_PATH

urlpatterns = patterns(
    '',
    (prefix_pattern(BASE_PATH), include('synnefo_admin.admin.urls')),
)

extend_path_with_slash(urlpatterns, BASE_PATH)
Example #8
0
from synnefo.cyclades_settings import (
    BASE_URL, BASE_HOST, BASE_PATH, COMPUTE_PREFIX, VMAPI_PREFIX,
    PLANKTON_PREFIX, HELPDESK_PREFIX, UI_PREFIX, ASTAKOS_BASE_URL,
    USERDATA_PREFIX, ADMIN_PREFIX, ASTAKOS_BASE_PATH, BASE_ASTAKOS_PROXY_PATH,
    ASTAKOS_ACCOUNTS_PREFIX, ASTAKOS_VIEWS_PREFIX, PROXY_USER_SERVICES,
    cyclades_services)

from functools import partial

astakos_proxy = partial(proxy,
                        proxy_base=BASE_ASTAKOS_PROXY_PATH,
                        target_base=ASTAKOS_BASE_URL)

cyclades_patterns = api_patterns(
    '',
    (prefix_pattern(VMAPI_PREFIX), include('synnefo.vmapi.urls')),
    (prefix_pattern(PLANKTON_PREFIX), include('synnefo.plankton.urls')),
    (prefix_pattern(COMPUTE_PREFIX), include('synnefo.api.urls')),
    (prefix_pattern(USERDATA_PREFIX), include('synnefo.userdata.urls')),
    (prefix_pattern(ADMIN_PREFIX), include('synnefo.admin.urls')),
)

cyclades_patterns += patterns(
    '',
    (prefix_pattern(UI_PREFIX), include('synnefo.ui.urls')),
    (prefix_pattern(HELPDESK_PREFIX), include('synnefo.helpdesk.urls')),
)

urlpatterns = patterns(
    '',
    (prefix_pattern(BASE_PATH), include(cyclades_patterns)),
Example #9
0
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""
This file can be used as ROOT_URLCONF for Admin-only installations. The Admin
path (BASE_PATH) is constructed from the ADMIN_BASE_URL setting.
"""

from django.conf.urls import patterns, include
from snf_django.utils.urls import extend_path_with_slash
from snf_django.lib.api.utils import prefix_pattern
from synnefo_admin.admin_settings import BASE_PATH

urlpatterns = patterns(
    '',
    (prefix_pattern(BASE_PATH), include('synnefo_admin.admin.urls')),
)

extend_path_with_slash(urlpatterns, BASE_PATH)
Example #10
0
from snf_django.lib.api.urls import api_patterns
from synnefo.cyclades_settings import (
    BASE_URL, BASE_HOST, BASE_PATH, COMPUTE_PREFIX, VMAPI_PREFIX,
    PLANKTON_PREFIX, HELPDESK_PREFIX, UI_PREFIX, ASTAKOS_BASE_URL,
    USERDATA_PREFIX, ADMIN_PREFIX, ASTAKOS_BASE_PATH, BASE_ASTAKOS_PROXY_PATH,
    ASTAKOS_ACCOUNTS_PREFIX, ASTAKOS_VIEWS_PREFIX, PROXY_USER_SERVICES,
    cyclades_services)

from functools import partial


astakos_proxy = partial(proxy, proxy_base=BASE_ASTAKOS_PROXY_PATH,
                        target_base=ASTAKOS_BASE_URL)

cyclades_patterns = api_patterns('',
    (prefix_pattern(VMAPI_PREFIX), include('synnefo.vmapi.urls')),
    (prefix_pattern(PLANKTON_PREFIX), include('synnefo.plankton.urls')),
    (prefix_pattern(COMPUTE_PREFIX), include('synnefo.api.urls')),
    (prefix_pattern(USERDATA_PREFIX), include('synnefo.userdata.urls')),
    (prefix_pattern(ADMIN_PREFIX), include('synnefo.admin.urls')),
)

cyclades_patterns += patterns('',
    (prefix_pattern(UI_PREFIX), include('synnefo.ui.urls')),
    (prefix_pattern(HELPDESK_PREFIX), include('synnefo.helpdesk.urls')),
)

urlpatterns = patterns(
    '',
    (prefix_pattern(BASE_PATH), include(cyclades_patterns)),
)
Example #11
0
def extend_path_with_slash(patterns_obj, path):
    if not path.endswith('/'):
        pattern = prefix_pattern(path, append_slash=False) + '$'
        entry = url(pattern, 'redirect_to', {'url': path + '/'})
        patterns_obj += patterns('django.views.generic.simple', entry)
Example #12
0
    'pithos.api.functions',
    (r'^$', 'top_demux'),
    (r'^(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$',
    'object_demux'),
    (r'^(?P<v_account>.+?)/(?P<v_container>.+?)/?$',
    'container_demux'),
    (r'^(?P<v_account>.+?)/?$', 'account_demux'))

pithos_view_patterns = patterns(
    'pithos.api.views',
    (r'^view/(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$',
    'object_read'))

pithos_patterns = patterns(
    '',
    (r'{0}v1/'.format(prefix_pattern(PITHOS_PREFIX)),
        include(pithos_api_patterns)),
    (r'{0}.*'.format(prefix_pattern(PITHOS_PREFIX)),
        api_endpoint_not_found),
    (r'{0}(?P<v_public>.+?)/?$'.format(prefix_pattern(PUBLIC_PREFIX)),
        'pithos.api.public.public_demux'),
    (r'{0}'.format(prefix_pattern(UI_PREFIX)),
        include(pithos_view_patterns)))

urlpatterns = patterns(
    '',
    (prefix_pattern(BASE_PATH), include(pithos_patterns)),
)

if PROXY_USER_SERVICES:
    astakos_proxy = partial(proxy, proxy_base=BASE_ASTAKOS_PROXY_PATH,
Example #13
0
from snf_django.lib.api.urls import api_patterns
from snf_django.lib.api import api_endpoint_not_found
from snf_django.utils.urls import extend_path_with_slash

from synnefo_ui.ui_settings import BASE_URL, ASTAKOS_IDENTITY_PROXY_PATH, \
    ASTAKOS_IDENTITY_BASE_URL, ASTAKOS_ACCOUNT_PROXY_PATH, \
    ASTAKOS_ACCOUNT_BASE_URL

proxy_patterns = patterns('')

if ASTAKOS_IDENTITY_PROXY_PATH:
    identity_proxy = \
            partial(proxy, proxy_base=ASTAKOS_IDENTITY_PROXY_PATH,
                                target_base=ASTAKOS_IDENTITY_BASE_URL)
    proxy_patterns += api_patterns(
        '', (prefix_pattern(ASTAKOS_IDENTITY_PROXY_PATH), identity_proxy))

if ASTAKOS_ACCOUNT_PROXY_PATH:
    account_proxy = \
            partial(proxy, proxy_base=ASTAKOS_ACCOUNT_PROXY_PATH,
                                target_base=ASTAKOS_ACCOUNT_BASE_URL)
    proxy_patterns += api_patterns(
        '', (prefix_pattern(ASTAKOS_ACCOUNT_PROXY_PATH), account_proxy))

ui_patterns = patterns(
    'synnefo_ui.views',
    url(r'^(?P<path>(?!view).*$)', 'app', name='ui-app'),
)

urlpatterns = proxy_patterns
urlpatterns += patterns('', (prefix_pattern(BASE_URL), include(ui_patterns)))
Example #14
0
File: urls.py Project: vcgato29/pwc
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.

try:
    from django.conf.urls import include, patterns
except ImportError:  # Django 1.2
    from django.conf.urls.defaults import include, patterns

from pithos_webclient import settings
from snf_django.lib.api.utils import prefix_pattern
from snf_django.utils.urls import extend_with_root_redirects
from synnefo.lib import join_urls

urlpatterns = patterns(
    '',
    (prefix_pattern(join_urls(settings.BASE_PATH, settings.UI_PREFIX)) + '$',
     'pithos_webclient.views.index'),
)

# set utility redirects
extend_with_root_redirects(urlpatterns, settings.pithos_services, 'pithos_ui',
                           settings.BASE_PATH)
Example #15
0
from astakos.im.settings import (
    BASE_PATH, ACCOUNTS_PREFIX, VIEWS_PREFIX, KEYSTONE_PREFIX, WEBLOGIN_PREFIX)
from snf_django.lib.api.utils import prefix_pattern
from snf_django.utils.urls import \
    extend_with_root_redirects, extend_endpoint_with_slash
from astakos.im.settings import astakos_services

urlpatterns = []

# Redirects should be first, otherwise they may get overridden by wildcards
extend_endpoint_with_slash(urlpatterns, astakos_services, 'astakos_ui')
extend_endpoint_with_slash(urlpatterns, astakos_services, 'astakos_weblogin')

astakos_patterns = patterns(
    '',
    (prefix_pattern(VIEWS_PREFIX), include('astakos.im.urls')),
    (prefix_pattern(ACCOUNTS_PREFIX), include('astakos.api.urls')),
    (prefix_pattern(KEYSTONE_PREFIX), include('astakos.api.keystone_urls')),
    (prefix_pattern(WEBLOGIN_PREFIX), include('astakos.im.weblogin_urls')),
)


urlpatterns += patterns(
    '',
    (prefix_pattern(BASE_PATH), include(astakos_patterns)),
)

# set utility redirects
extend_with_root_redirects(urlpatterns, astakos_services,
                           'astakos_ui', BASE_PATH)
Example #16
0
def extend_path_with_slash(patterns_obj, path):
    if not path.endswith('/'):
        pattern = prefix_pattern(path, append_slash=False) + '$'
        entry = url(pattern, RedirectView.as_view(url=path + '/'))
        patterns_obj += patterns('', entry)
Example #17
0
# TODO: This only works when in this order.
pithos_api_patterns = api_patterns(
    'pithos.api.functions', (r'^$', 'top_demux'),
    (r'^(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$',
     'object_demux'),
    (r'^(?P<v_account>.+?)/(?P<v_container>.+?)/?$', 'container_demux'),
    (r'^(?P<v_account>.+?)/?$', 'account_demux'))

pithos_view_patterns = patterns(
    'pithos.api.views',
    (r'^view/(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$',
     'object_read'))

pithos_patterns = patterns(
    '', (r'{0}v1/'.format(
        prefix_pattern(PITHOS_PREFIX)), include(pithos_api_patterns)),
    (r'{0}.*'.format(prefix_pattern(PITHOS_PREFIX)), api_endpoint_not_found),
    (r'{0}(?P<v_public>.+?)/?$'.format(
        prefix_pattern(PUBLIC_PREFIX)), 'pithos.api.public.public_demux'),
    (r'{0}'.format(prefix_pattern(UI_PREFIX)), include(pithos_view_patterns)))

urlpatterns = patterns(
    '',
    (prefix_pattern(BASE_PATH), include(pithos_patterns)),
)

if PROXY_USER_SERVICES:
    astakos_proxy = partial(proxy,
                            proxy_base=BASE_ASTAKOS_PROXY_PATH,
                            target_base=ASTAKOS_BASE_URL)
Example #18
0
    cyclades_services)

from functools import partial


urlpatterns = []

# Redirects should be first, otherwise they may get overridden by wildcards
extend_endpoint_with_slash(urlpatterns, cyclades_services, 'cyclades_ui')
extend_endpoint_with_slash(urlpatterns, cyclades_services, 'cyclades_helpdesk')
extend_endpoint_with_slash(urlpatterns, cyclades_services, 'admin')
extend_endpoint_with_slash(urlpatterns, cyclades_services, 'cyclades_userdata')

cyclades_patterns = api_patterns(
    '',
    (prefix_pattern(VMAPI_PREFIX), include('synnefo.vmapi.urls')),
    (prefix_pattern(PLANKTON_PREFIX), include('synnefo.plankton.urls')),
    (prefix_pattern(COMPUTE_PREFIX), include('synnefo.api.compute_urls')),
    (prefix_pattern(NETWORK_PREFIX), include('synnefo.api.network_urls')),
    (prefix_pattern(USERDATA_PREFIX), include('synnefo.userdata.urls')),
    (prefix_pattern(ADMIN_PREFIX), include('synnefo.admin.urls')),
    (prefix_pattern(VOLUME_PREFIX), include('synnefo.volume.urls')),
)

cyclades_patterns += patterns(
    '',
    (prefix_pattern(UI_PREFIX), include('synnefo.ui.urls')),
)

cyclades_patterns += api_patterns(
    '',
Example #19
0
    (r'^$', 'top_demux'),
    (r'^(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$',
     'object_demux'),
    (r'^(?P<v_account>.+?)/(?P<v_container>.+?)/?$',
     'container_demux'),
    (r'^(?P<v_account>.+?)/?$', 'account_demux'))

pithos_view_patterns = patterns(
    'pithos.api.views',
    (r'^(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$',
     'object_read'))

pithos_patterns = []
pithos_patterns += patterns(
    '',
    (r'{0}v1/'.format(prefix_pattern(PITHOS_PREFIX)),
        include(pithos_api_patterns)),
    (r'{0}.*'.format(prefix_pattern(PITHOS_PREFIX)),
        api_endpoint_not_found),
    (r'{0}(?P<v_public>.+?)/?$'.format(prefix_pattern(PUBLIC_PREFIX)),
        'pithos.api.public.public_demux'),
)

pithos_patterns += patterns(
    '',
    (r'{0}'.format(prefix_pattern(VIEW_PREFIX)),
        include(pithos_view_patterns)))

urlpatterns += patterns(
    '',
    (prefix_pattern(BASE_PATH), include(pithos_patterns)),
Example #20
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from django.conf.urls import patterns, include

from snf_django.lib.api.utils import prefix_pattern
from snf_django.lib.api import api_endpoint_not_found

from synnefo_stats.stats_settings import BASE_PATH
from synnefo_stats.grapher import grapher

graph_types_re = '((cpu|net)-(bar|(ts(-w)?)))'
stats_v1_patterns = patterns(
    '',
    (r'^(?P<graph_type>%s)/(?P<hostname>[^ /]+)$' % graph_types_re, grapher),
)

stats_patterns = patterns(
    '',
    (r'^v1.0/', include(stats_v1_patterns)),
    (r'^.*', api_endpoint_not_found),
)

urlpatterns = patterns(
    '',
    (prefix_pattern(BASE_PATH), include(stats_patterns)),
)
Example #21
0
def extend_path_with_slash(patterns_obj, path):
    if not path.endswith('/'):
        pattern = prefix_pattern(path, append_slash=False) + '$'
        entry = url(pattern, RedirectView.as_view(url=path + '/'))
        patterns_obj += patterns('', entry)