{"action":"created","issue":{"url":"https://api.github.com/repos/ubuntudesign/developer.ubuntu.com/issues/6","repository_url":"https://api.github.com/repos/ubuntudesign/developer.ubuntu.com","labels_url":"https://api.github.com/repos/ubuntudesign/developer.ubuntu.com/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/ubuntudesign/developer.ubuntu.com/issues/6/comments","events_url":"https://api.github.com/repos/ubuntudesign/developer.ubuntu.com/issues/6/events","html_url":"https://github.com/ubuntudesign/developer.ubuntu.com/pull/6","id":165138584,"number":6,"title":"Store CMS media in Swift","user":{"login":"nottrobin","id":519935,"avatar_url":"https://avatars.githubusercontent.com/u/519935?v=3","gravatar_id":"","url":"https://api.github.com/users/nottrobin","html_url":"https://github.com/nottrobin","followers_url":"https://api.github.com/users/nottrobin/followers","following_url":"https://api.github.com/users/nottrobin/following{/other_user}","gists_url":"https://api.github.com/users/nottrobin/gists{/gist_id}","starred_url":"https://api.github.com/users/nottrobin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nottrobin/subscriptions","organizations_url":"https://api.github.com/users/nottrobin/orgs","repos_url":"https://api.github.com/users/nottrobin/repos","events_url":"https://api.github.com/users/nottrobin/events{/privacy}","received_events_url":"https://api.github.com/users/nottrobin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-12T17:48:40Z","updated_at":"2016-07-12T17:50:09Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ubuntudesign/developer.ubuntu.com/pulls/6","html_url":"https://github.com/ubuntudesign/developer.ubuntu.com/pull/6","diff_url":"https://github.com/ubuntudesign/developer.ubuntu.com/pull/6.diff","patch_url":"https://github.com/ubuntudesign/developer.ubuntu.com/pull/6.patch"},"body":"- Add settings to store CMS media assets under `/media`\r\n- If `OS_TENANT_NAME`, `OS_AUTH_URL`, `OS_USERNAME`, `OS_PASSWORD` and `OS_REGION_NAME` are provided, use these to connect to swift\r\n- If swift credentials are missing, throw an error, unless in debug mode\r\n- If in debug mode and no swift creds are provided, use local `media` directory\r\n\r\nQA\r\n---\r\n\r\n### Debug on\r\n\r\n```\r\nmake run\r\n```\r\n\r\nYou should see \"No swift credentials found. Using local `media` directory for CMS media.\"\r\n\r\n### Debug off, no swift\r\n\r\n```\r\nDJANGO_DEBUG=false make run\r\n```\r\n\r\nYou should see \"EnvironmentError: [ERROR]: No swift credentials found - required for CMS media.\"\r\n\r\n### Swift\r\n\r\nFind your swift credentials in `novarc` in your [canonistack credentials](https://enigma.admin.canonical.com/user/+me/canonistack-credentials.zip).\r\n\r\nNow add the `OS_` environment variables from the `novarc` file to the `.env` file inside developer.ubuntu.com, and remove any `\"` quotation marks, so it looks like this:\r\n\r\n``` bash\r\nPORT=8017\r\nDB=true\r\nOS_USERNAME=robin\r\nOS_TENANT_NAME=robin_project\r\nOS_PASSWORD=xxxxxxxx\r\nOS_AUTH_URL=https://keystone.canonistack.canonical.com:443/v2.0/\r\nOS_REGION_NAME=lcy01\r\n```\r\n\r\nNow get inside the Django container:\r\n\r\n``` bash\r\nmake \"docker-compose run --service-ports --entrypoint /bin/bash webapp\"\r\n```\r\n\r\nNow import all docs data:\r\n\r\n``` bash\r\n./update_apidocs.sh\r\n```\r\n\r\nLet it run for about 30 seconds then cancel it. Quit the image, and run:\r\n\r\n``` bash\r\nrm -rf media  # Delete any local media to make sure its definitely using swift\r\nmake run      # Run the server\r\n```\r\n\r\nCheck you see \"Swift credentials found\".\r\n\r\nWhen the server starts up again, visit http://127.0.0.1:8017/media/api/apps/qml/sdk-15.04.5/QtQml.Qt/images/declarative-rect_tint.png and check it exists."},"comment":{"url":"https://api.github.com/repos/ubuntudesign/developer.ubuntu.com/issues/comments/232124776","html_url":"https://github.com/ubuntudesign/developer.ubuntu.com/pull/6#issuecomment-232124776","issue_url":"https://api.github.com/repos/ubuntudesign/developer.ubuntu.com/issues/6","id":232124776,"user":{"login":"nottrobin","id":519935,"avatar_url":"https://avatars.githubusercontent.com/u/519935?v=3","gravatar_id":"","url":"https://api.github.com/users/nottrobin","html_url":"https://github.com/nottrobin","followers_url":"https://api.github.com/users/nottrobin/followers","following_url":"https://api.github.com/users/nottrobin/following{/other_user}","gists_url":"https://api.github.com/users/nottrobin/gists{/gist_id}","starred_url":"https://api.github.com/users/nottrobin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nottrobin/subscriptions","organizations_url":"https://api.github.com/users/nottrobin/orgs","repos_url":"https://api.github.com/users/nottrobin/repos","events_url":"https://api.github.com/users/nottrobin/events{/privacy}","received_events_url":"https://api.github.com/users/nottrobin/received_events","type":"User","site_admin":false},"created_at":"2016-07-12T17:50:09Z","updated_at":"2016-07-12T17:50:09Z","body":"<a href=\"https:&#x2F;&#x2F;trello.com&#x2F;c&#x2F;tqrOoZp1&#x2F;1374-mojo-spec-use-swift-account-for-cms-media-storage\"><img src=\"https:&#x2F;&#x2F;github.trello.services&#x2F;images&#x2F;trello-icon.png\" width=\"12\" height=\"12\"> Mojo spec: Use swift account for CMS media storage</a>"}}
{"actor":{"display_login":"nottrobin"}}