本文整理汇总了Python中synnefo.lib.services.get_service_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_service_path函数的具体用法?Python get_service_path怎么用?Python get_service_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_service_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.flavor1 = FlavorFactory()
self.flavor2 = FlavorFactory(deleted=True)
self.flavor3 = FlavorFactory()
self.project1 = 'project1'
self.project2 = 'project2'
self.project3 = 'project3'
self.projects = [self.project1, self.project2]
self.flavor4 = FlavorFactory(public=False)
self.flavor5 = FlavorFactory(public=False)
self.flavor6 = FlavorFactory(public=False)
self.flavor7 = FlavorFactory(public=False)
self.flavor8 = FlavorFactory()
self.flavoraccess1 = FlavorAccessFactory(project=self.project1,
flavor=self.flavor4)
self.flavoraccess2 = FlavorAccessFactory(project=self.project1,
flavor=self.flavor5)
self.flavoraccess3 = FlavorAccessFactory(project=self.project2,
flavor=self.flavor6)
self.flavoraccess4 = FlavorAccessFactory(project=self.project3,
flavor=self.flavor7)
self.flavoraccess5 = FlavorAccessFactory(project=self.project1,
flavor=self.flavor8)
self.compute_path = get_service_path(cyclades_services, 'compute',
version='v2.0')
示例2: test_not_allowed
def test_not_allowed(self):
self.view_path = join_urls(get_service_path(
pithos_settings.pithos_services, 'pithos_ui'), 'view')
self.view_url = join_urls(self.view_path, self.user, get_random_name(),
get_random_name())
r = self.delete(self.view_url)
self.assertEqual(r.status_code, 405)
self.assertTrue('Allow' in r)
self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD'])
r = self.post(self.view_url)
self.assertEqual(r.status_code, 405)
self.assertTrue('Allow' in r)
self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD'])
r = self.put(self.view_url)
self.assertEqual(r.status_code, 405)
self.assertTrue('Allow' in r)
self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD'])
r = self.copy(self.view_url)
self.assertEqual(r.status_code, 405)
self.assertTrue('Allow' in r)
self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD'])
r = self.move(self.view_url)
self.assertEqual(r.status_code, 405)
self.assertTrue('Allow' in r)
self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD'])
示例3: test_catch_wrong_identity_paths
def test_catch_wrong_identity_paths(self, *args):
path = get_service_path(astakos_services, 'identity', 'v2.0')
path = join_urls(BASE_HOST, path, 'nonexistent')
response = self.client.get(path)
self.assertEqual(response.status_code, 400)
try:
error = json.loads(response.content)
except ValueError:
self.assertTrue(False)
示例4: test_catch_wrong_account_paths
def test_catch_wrong_account_paths(self, *args):
path = get_service_path(astakos_services, "account", "v1.0")
path = join_urls(BASE_HOST, path, "nonexistent")
response = self.client.get(path)
self.assertEqual(response.status_code, 400)
try:
error = json.loads(response.content)
except ValueError:
self.assertTrue(False)
示例5: test_catch_wrong_api_paths
def test_catch_wrong_api_paths(self, *args):
path = get_service_path(cyclades_services,
'compute', version='v2.0')
response = self.client.get(join_urls(path, 'nonexistent'))
self.assertEqual(response.status_code, 400)
try:
error = json.loads(response.content)
except ValueError:
self.assertTrue(False)
示例6: test_api_version
def test_api_version(self):
"""Check API version."""
path = get_service_path(cyclades_services,
'compute', version='v2.0')
with astakos_user('user'):
response = self.client.get(path.rstrip('/') + '/')
self.assertEqual(response.status_code, 200)
api_version = json.loads(response.content)['version']
self.assertEqual(api_version['id'], 'v2.0')
self.assertEqual(api_version['status'], 'CURRENT')
示例7: setUp
def setUp(self):
PithosAPITest.setUp(self)
self.cname = self.create_container()[0]
self.oname, self.odata = self.upload_object(self.cname,
'φωτογραφία.JPG')[:-1]
self.view_path = join_urls(get_service_path(
pithos_settings.pithos_services, 'pithos_ui'), 'view')
self.view_url = join_urls(self.view_path, self.user, self.cname,
self.oname)
self.api_url = join_urls(self.pithos_path, self.user, self.cname,
self.oname)
示例8: setUp
def setUp(self):
self.volumes_path = get_service_path(cyclades_services, 'volume',
version='v2.0') + '/volumes'
self.snapshots_path = get_service_path(cyclades_services, 'volume',
version='v2.0') + '/snapshots'
# Volume types
self.archip_vt = mf.VolumeTypeFactory(name="archipelago",
disk_template="ext_archipelago")
self.file_vt = mf.VolumeTypeFactory(name="file", disk_template="file")
# Common arguments
self.userid = "test_user"
self.size = 1
self.kwargs = {"user_id": self.userid, }
# VMs
self.archip_vm = mf.VirtualMachineFactory(
userid=self.userid, flavor__volume_type=self.archip_vt)
self.file_vm = mf.VirtualMachineFactory(
userid=self.userid, flavor__volume_type=self.file_vt)
示例9: setUp
def setUp(self):
self.client = PithosTestClient()
# Override default block size to spead up tests
pithos_settings.BACKEND_BLOCK_SIZE = TEST_BLOCK_SIZE
pithos_settings.BACKEND_HASH_ALGORITHM = TEST_HASH_ALGORITHM
self.user = 'user'
self.pithos_path = join_urls(get_service_path(
pithos_settings.pithos_services, 'object-store'))
# patch astakosclient.AstakosClient.validate_token
mock_validate_token = self.create_patch(
'astakosclient.AstakosClient.validate_token')
mock_validate_token.return_value = {
'access': {
'user': {'id': smart_unicode(self.user, encoding='utf-8')}}}
# patch astakosclient.AstakosClient.get_token
mock_get_token = self.create_patch(
'astakosclient.AstakosClient.get_token')
mock_get_token.return_value = {'access_token': 'valid_token'}
# patch astakosclient.AstakosClient.api_oa2_auth
mock_api_oauth2_auth = self.create_patch(
'astakosclient.AstakosClient.oauth2_url',
new_callable=PropertyMock)
mock_api_oauth2_auth.return_value = '/astakos/oauth2/'
mock_service_get_quotas = self.create_patch(
'astakosclient.AstakosClient.service_get_quotas')
mock_service_get_quotas.return_value = {
self.user: {
"system": {
"pithos.diskspace": {
"usage": 0,
"limit": 1073741824, # 1GB
"pending": 0}}}}
示例10: extend_with_root_redirects
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)
示例11: setUp
def setUp(self):
self.flavor1 = FlavorFactory()
self.flavor2 = FlavorFactory(deleted=True)
self.flavor3 = FlavorFactory()
self.compute_path = get_service_path(cyclades_services, 'compute',
version='v2.0')
示例12: get_service_path
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
from snf_django.lib.api import faults
from snf_django.utils.testing import BaseAPITest
from synnefo.lib.services import get_service_path
from synnefo.cyclades_settings import cyclades_services
from synnefo.lib import join_urls
from mock import patch
from functools import wraps
compute_path = get_service_path(cyclades_services, 'compute',
version='v2.0')
IMAGES_URL = join_urls(compute_path, "images/")
def assert_backend_closed(func):
"""Decorator for ensuring that PlanktonBackend is returned to pool."""
@wraps(func)
def wrapper(self, backend):
result = func(self, backend)
if backend.called is True:
backend.return_value.close.asssert_called
return result
return wrapper
@patch('synnefo.plankton.backend.PlanktonBackend')
示例13: __init__
def __init__(self, *args, **kwargs):
super(ComputeAPITest, self).__init__(*args, **kwargs)
self.compute_path = get_service_path(cyclades_services, 'compute',
version='v2.0')
示例14: setUp
def setUp(self, *args, **kwargs):
super(VMAPITest, self).setUp(*args, **kwargs)
self.api_path = get_service_path(cyclades_services, 'vmapi',
version='v1.0')
示例15: import
from synnefo.db.models import (Flavor, VirtualMachine, VirtualMachineMetadata,
Network, BackendNetwork, NetworkInterface,
BridgePoolTable, MacPrefixPoolTable, Backend)
from synnefo.db.pools import EmptyPool
from snf_django.lib.astakos import get_user
from synnefo.plankton.utils import image_backend
from synnefo.settings import MAX_CIDR_BLOCK
from synnefo.cyclades_settings import cyclades_services, BASE_HOST
from synnefo.lib.services import get_service_path
from synnefo.lib import join_urls
COMPUTE_URL = \
join_urls(BASE_HOST,
get_service_path(cyclades_services, "compute", version="v2.0"))
SERVERS_URL = join_urls(COMPUTE_URL, "servers/")
NETWORKS_URL = join_urls(COMPUTE_URL, "networks/")
FLAVORS_URL = join_urls(COMPUTE_URL, "flavors/")
IMAGES_URL = join_urls(COMPUTE_URL, "images/")
PLANKTON_URL = \
join_urls(BASE_HOST,
get_service_path(cyclades_services, "image", version="v1.0"))
IMAGES_PLANKTON_URL = join_urls(PLANKTON_URL, "images/")
log = getLogger('synnefo.api')
def random_password():
"""Generates a random password