2014-02-16

Step #07 : Install And check GSpread

Description

Our purpose with this video series is to demonstrate how to set up a cloud-based, permanent, yet part-time, cloud control workstation.  One we can depend on to be there when we activate it, but switched off 95% of the time: casual DevOps if you will.

Our goal with the particular use-case example is to install and use the Google spreadsheets to OpenERP data pump.  That tool needs GSpread to connect to Google.

In this video we show how to use the Salt state stack we created for installing GSpread and the GData_OpenERP_Data_Pump.

We want our connection to Google to use OAuth.  That way, our username and password do not get left lying around by accident. 

Most of the following video is about preparing our Salt "pillar" file with the first phase of OAuth credentials before we run it.  Under the covers, our Salt state patches a JSON file with those data items and deposits it in GSpread's tests directory.  For the second phase of OAuth -- obtaining access and refresh tokens -- we use the tool get_google_oauth2_creds.py from the same directory.

The tool does several useful things:

  1. Guides you through authorizing GSpread to use your GMail for sending email.
  2. Sends email to a 3rd party requesting permission for GSpread to access their spreadsheets.
  3. Generates files in several formats containing the resulting access and refresh tokens.  One of those is qiktest.py; a quick check that the connection works.
Once we have these tokens, checked with qiktest.py, we can move on to the next step


Here's the video:


Tasks performed

  1. With GateOne as our SSH entry point, we no longer need SSH terminal windows in our work station
  2. Create two SSH windows in GateOne logged into the Salt master machine and become to root in one of them with sudo -sHu root
  3. As root, re-point Salt's symbolic link /srv to point to SaltStackToolSet/gdata_oerp_pump/srv
  4. Open the APIs and Auth >> Credentials sub-menu of our project in Google's API Console
  5. Edit the pillar file init.sls, providing values for redirect_uri, client_secret and client_id obtained from the API console
  6. Run Salt state.sls against the master's own minion to install just GSpread.  (We'll do the same for gdata_oerp_pump in the next video)
  7. In the tests subdirectory of the temporary gspread build directory, run get_google_oauth2_creds.py
  8. Pick the 2nd method and provide the project Google ID and the ID of the 3rd party whose spreadsheets are to be worked on
  9. Authorize the project's GMail account to be used for SMTP by obtaining the verification code and pasting it back into get_google_oauth2_creds.py
  10. Run a quick test to be sure we are connecting correctly.
An overview of all the steps is available here:

No comments:

Post a Comment