2017-11-15 11 views
0

내 가상 상자에 openstack에 로컬 설치가 있습니다. 내가 이미지 목록을 connnect하고 얻을 수있는 LIB 클라우드 API를 사용하는 것을 시도하고, 맛 등 아래 Openstack 나머지 API를 사용하여 연결할 수 없습니다

내가 내가 위의 코드를 실행하면

from libcloud.compute.types import Provider 
from libcloud.compute.providers import get_driver 

# Authentication information so you can authenticate to DreamCompute 
# copy the details from the OpenStack RC file 
# https://dashboard.dreamcompute.com/project/access_and_security/api_access/openrc/ 

auth_username = 'admin' 
auth_password = 'f882e2f4eaad434c' 
TENANT_NAME = 'admin' 
project_name = 'admin' 
auth_url = 'http://192.168.56.101:5000/v3/tokens' 
region_name = 'RegionOne' 

provider = get_driver(Provider.OPENSTACK) 
conn = provider(auth_username, 
       auth_password, 
       ex_force_auth_url=auth_url, 
       ex_force_auth_version='2.0_password', 
       ex_tenant_name=project_name, 
       ex_force_service_type='compute', 
       ex_force_service_name='compute', 
       ex_force_base_url='http://192.168.56.101:8774/v2.1/29a8949bc3a04bfead0654be8e552017') 


# Get the image that we want to use by its id 
# NOTE: the image_id may change. See the documentation to find 
# all the images available to your user 
image_id = '4525d442-e9f4-4d19-889f-49ab03be93df' 
image = conn.get_image(image_id) 

# Get the flavor that we want to use by its id 
flavor_id = '100' 
flavor = conn.ex_get_size(flavor_id) 

# Create the node with the name “PracticeInstance” 
# and the size and image we chose above 
instance = conn.create_node(name='PracticeInstance', image=image, size=flavor) 

을 실행하려고하고있는 코드는

C:\Python dev\website\music\openstack>python openstack.py 
Traceback (most recent call last): 
    File "openstack.py", line 30, in <module> 
    image = conn.get_image(image_id) 
    File "C:\Users\C5265680\AppData\Local\Programs\Python\Python36\lib\site-packages\libcloud\compute\drivers\openstack.py", line 2028, in get_image 
    '/images/%s' % (image_id,)).object['image']) 
    File "C:\Users\C5265680\AppData\Local\Programs\Python\Python36\lib\site-packages\libcloud\common\openstack.py", line 223, in request 
    raw=raw) 
    File "C:\Users\C5265680\AppData\Local\Programs\Python\Python36\lib\site-packages\libcloud\common\base.py", line 536, in request 
    action = self.morph_action_hook(action) 
    File "C:\Users\C5265680\AppData\Local\Programs\Python\Python36\lib\site-packages\libcloud\common\openstack.py", line 290, in morph_action_hook 
    self._populate_hosts_and_request_paths() 
    File "C:\Users\C5265680\AppData\Local\Programs\Python\Python36\lib\site-packages\libcloud\common\openstack.py", line 324, in _populate_hosts_and_request_paths 
    osa = osa.authenticate(**kwargs) # may throw InvalidCreds 
    File "C:\Users\C5265680\AppData\Local\Programs\Python\Python36\lib\site-packages\libcloud\common\openstack_identity.py", line 855, in authenticate 
    return self._authenticate_2_0_with_password() 
    File "C:\Users\C5265680\AppData\Local\Programs\Python\Python36\lib\site-packages\libcloud\common\openstack_identity.py", line 880, in _authenticate_2_0_with_password 
    return self._authenticate_2_0_with_body(reqbody) 
    File "C:\Users\C5265680\AppData\Local\Programs\Python\Python36\lib\site-packages\libcloud\common\openstack_identity.py", line 885, in _authenticate_2_0_with_body 
    method='POST') 
    File "C:\Users\C5265680\AppData\Local\Programs\Python\Python36\lib\site-packages\libcloud\common\base.py", line 637, in request 
    response = responseCls(**kwargs) 
    File "C:\Users\C5265680\AppData\Local\Programs\Python\Python36\lib\site-packages\libcloud\common\base.py", line 157, in __init__ 
    message=self.parse_error()) 
libcloud.common.exceptions.BaseHTTPError: {"error": {"message": "The resource could not be found.", "code": 404, "title": "Not Found"}} 

내가는/var/log/키스톤에서 내 서버에 로그를 확인하고 내가 로그인 할 수 있어요 추측하고 그래서 오류를 제공하지 않습니다 오류가 아래 점점.

또한 위의 단계를 수행 한 후에 이미지/맛/서버 목록을 가져올 수 있어야한다는 많은 사례가 있습니다.

왜 내가 연결할 수 없는지 잘 모르겠습니다. 누군가 나를 도와주세요.

답변

0

auth_url 및 제공자 인수를 수정해야한다고 생각합니다. 내 환경에서 다음 인수 집합이 작동합니다.

auth_username = 'admin' 
auth_password = 'f882e2f4eaad434c' 
TENANT_NAME = 'admin' 
project_name = 'admin' 
auth_url = 'http://192.168.56.101:5000' 
region_name = 'RegionOne' 

provider = get_driver(Provider.OPENSTACK) 
conn = provider(auth_username, 
       auth_password, 
       ex_force_auth_url=auth_url, 
       ex_force_auth_version='2.0_password', 
       ex_tenant_name=project_name) 

첫 번째 단서, The resource could not be found. 및 상태 code 404, 그 메시지와 상태 코드는 잘못된 나머지 API를 URL 형식의 대부분의 원인은 user8040338 귀하의 오류 메시지 @

2017년 11월 16일 업데이트되었습니다.

먼저 keystone v2.0 rest api format을 확인해야합니다. 동시에, 다시 확인하십시오 Libcloud reference. 예를 들어, 인수 ex_force_auth_version이 API 버전 2.0_password (v2)으로 지정되었지만 을 포함하여 auth_url 변수에 URL이 구성되어 있으면 사용자가 지정한 libcloud API 인수가있는 API의 버전과 사용법이 잘못되었습니다. auth_url은 API 사용의 기본 URL이어야합니다.

API의 각 인수에 대한 비슷한 프로세스가 문제를 해결할 때까지 반복적으로 수행되어야합니다.

+0

나는 여러 가지 조합을 시도했습니다. 아래는 귀하의 제안을 적극적으로 반영한 것입니다. 이전에도 시도해 보았습니다. – user8040338

+0

고마워요. 논증을 어떻게 알았고 인증 URL을 수정해야합니까? 나를 안내 할 수있는 참조 링크는 매우 유용 할 것입니다. – user8040338

+0

@ user8040338 추가 코멘트가 너무 길어 코멘트로 쓸 수 없으므로 참조를 포함하여 질문을 수정했습니다. – Daein