本文整理汇总了Python中synnefo.lib.services.get_service_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_service_path函数的具体用法?Python get_service_path怎么用?Python get_service_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_service_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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')
开发者ID:grnet,项目名称:synnefo,代码行数:25,代码来源:flavors.py
示例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'])
开发者ID:apyrgio,项目名称:synnefo,代码行数:30,代码来源:views.py
示例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)
开发者ID:cstavr,项目名称:synnefo,代码行数:9,代码来源:api.py
示例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)
开发者ID:jbd,项目名称:synnefo,代码行数:9,代码来源:api.py
示例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)
开发者ID:grnet,项目名称:synnefo,代码行数:9,代码来源:versions.py
示例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')
开发者ID:grnet,项目名称:synnefo,代码行数:10,代码来源:versions.py
示例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)
开发者ID:apyrgio,项目名称:synnefo,代码行数:12,代码来源:views.py
示例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)
开发者ID:gvsurenderreddy,项目名称:synnefo-1,代码行数:22,代码来源:volumes.py
示例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}}}}
开发者ID:gvsurenderreddy,项目名称:synnefo-1,代码行数:38,代码来源:__init__.py
示例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)
开发者ID:AthinaB,项目名称:synnefo,代码行数:38,代码来源:urls.py
示例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')
开发者ID:mpastyl,项目名称:websocket-console,代码行数:6,代码来源:flavors.py
示例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')
开发者ID:AthinaB,项目名称:synnefo,代码行数:32,代码来源:images.py
示例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')
开发者ID:Erethon,项目名称:synnefo,代码行数:4,代码来源:servers.py
示例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')
开发者ID:AthinaB,项目名称:synnefo,代码行数:4,代码来源:tests.py
示例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
开发者ID:mpastyl,项目名称:websocket-console,代码行数:31,代码来源:util.py
示例16: 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
import urllib
from mock import patch
from functools import wraps
from copy import deepcopy
from decimal import Decimal
from snf_django.utils.testing import BaseAPITest
from synnefo.cyclades_settings import cyclades_services
from synnefo.lib.services import get_service_path
from synnefo.lib import join_urls
PLANKTON_URL = get_service_path(cyclades_services, 'image',
version='v1.0')
IMAGES_URL = join_urls(PLANKTON_URL, "images/")
def assert_backend_closed(func):
@wraps(func)
def wrapper(self, backend):
result = func(self, backend)
if backend.called is True:
backend.return_value.close.assert_called_once_with()
return result
return wrapper
@patch("synnefo.plankton.backend.get_pithos_backend")
class PlanktonTest(BaseAPITest):
开发者ID:AthinaB,项目名称:synnefo,代码行数:32,代码来源:tests.py
示例17: extend_endpoint_with_slash
def extend_endpoint_with_slash(patterns_obj, filled_services, service_type,
version=None):
path = get_service_path(filled_services, service_type, version)
extend_path_with_slash(patterns_obj, path)
开发者ID:AthinaB,项目名称:synnefo,代码行数:4,代码来源:urls.py
示例18: get_service_path
# 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 snf_django.utils.testing import BaseAPITest, override_settings
from django.utils import simplejson as json
from synnefo.cyclades_settings import cyclades_services
from synnefo.lib.services import get_service_path
from synnefo.lib import join_urls
import synnefo.db.models_factory as dbmf
from synnefo.db.models import Network, QuotaHolderSerial
from django.conf import settings
NETWORK_URL = get_service_path(cyclades_services, "network", version="v2.0")
NETWORKS_URL = join_urls(NETWORK_URL, "networks/")
class NetworkTest(BaseAPITest):
def test_list_networks(self):
response = self.get(NETWORKS_URL)
self.assertSuccess(response)
networks = json.loads(response.content)
self.assertEqual(networks, {"networks": []})
def test_invalid_create(self):
"""Test invalid flavor"""
request = {"network": {}}
response = self.post(NETWORKS_URL, "user1", params=json.dumps(request))
self.assertBadRequest(response)
开发者ID:konsP,项目名称:synnefo,代码行数:31,代码来源:networks.py
示例19: setUp
def setUp(self, *args, **kwargs):
super(PlanktonAPITest, self).setUp(*args, **kwargs)
self.api_path = get_service_path(cyclades_services, 'image',
version='v1.0')
开发者ID:antonis-m,项目名称:synnefo,代码行数:4,代码来源:tests.py
示例20: get_service_path
# 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/>.
import json
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
COMPUTE_URL = get_service_path(cyclades_services, 'compute',
version='v2.0')
EXTENSIONS_URL = join_urls(COMPUTE_URL, "extensions/")
class ExtensionsAPITest(BaseAPITest):
def test_list(self):
response = self.get(EXTENSIONS_URL, "user")
self.assertSuccess(response)
extensions = json.loads(response.content)["extensions"]
self.assertEqual(extensions, [])
def test_get(self):
response = self.get(join_urls(EXTENSIONS_URL, "SNF"), "user")
self.assertEqual(response.status_code, 404)
response = self.get(join_urls(EXTENSIONS_URL, "SNF_asfas_da"), "user")
self.assertEqual(response.status_code, 404)
开发者ID:AthinaB,项目名称:synnefo,代码行数:32,代码来源:extensions.py
注:本文中的synnefo.lib.services.get_service_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论