PyCharm professional에서 원격 디버깅 설정하기

(참조 : https://www.jetbrains.com/help/pycharm/remote-debugging-with-product.html)

  1. Download openstackclient

    github python-openstackclient 저장소에서 openstackclient 소스코드를 다운.

    github repository url: https://github.com/openstack/python-openstackclient

    [somedirpath]$ git clone [<https://github.com/openstack/python-openstackclient.git>](<https://github.com/openstack/python-openstackclient.git>)
    

여기서부터 시작함.

  1. PyCharm 원격 interpreter 설정

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e16d4272-fbea-4ff4-9fbd-c0ba1f7b87f4/Untitled.png

    프로젝트 이름을 정함.

    원격에 존재하는 python3 인터프리터를 사용할 것이니 Existing interpreter를 선택!

    오른쪽에 ... 클릭하면

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/de3da957-f2a6-4ad9-88f4-c27af59cddb8/Untitled.png

    SSH Interpreter 설정을 해줄것임.

    Host : cafe24 server host

    Username : root (*root를 사용해 인증하려면 리모트 서버의 .ssh/authorized_keys 파일을 수정해야함, 뒤에 나옴)

    Key pair 선택

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/da649cd2-e56e-44e7-91b4-c043e4806062/removed.png

    cafe24에서 받은 SSH Key pair 선택

    디폴트로 python2가 설정되어 있지만 python3으로 변경(3만 붙여주면 됨!)

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a662625d-fc6e-4ea9-a55f-4dcaceeb7b13/Untitled.png

    Remote project location은 openstackclient가 설치된 path로 설정

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/1802e121-69f7-44f0-ad51-3a457f71e1bf/removed2.png

    Remote project location: /usr/local/lib/python3.6/dist-packages/openstackclient

    root사용자로 인증 진행 하려면 remote 서버(183.x.x.x)에서 /.ssh/authorized_keys를 수정해야 함

    $ sudo su
    root@:~# vim ~/.ssh/authorized_keys
    
    ssh-rsa 앞 까지 주석을 지워주면 됨
    ---
    ssh-rsa AAAA 
    ...
    +n Generated-by-Nova
    ---
    
  2. 실행/디버그 환경설정

    Add configurations을 클릭

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c7f831cb-fae9-4ec3-96ab-8f9c95acd765/Untitled.png

    Python 환경 추가

    openstack server list를 실행하는 환경을 구성할 것임.

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/66e8cd37-064f-465e-acbc-6ec4e9d2ff27/removed3.png

    OS_AUTH_URL은 http://127.0.0.1/identity로 채우면 됨.

     ![<https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e2194d17-0523-446c-8f98-09cd54f2de8b/image.png>](<https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e2194d17-0523-446c-8f98-09cd54f2de8b/image.png>)
     
     ![<https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e8340581-edc2-42ea-9876-e4164429341c/image_(1).png>](<https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e8340581-edc2-42ea-9876-e4164429341c/image_(1).png>)
    
  3. run 실행하면 openstack server list가 실행되고 결과가 출력

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/205a8e20-9395-4061-9b12-2d0a68da2110/Untitled.png