19
1 OpenShift Workshop – Python for the impatient Steven Citron-Pousty @TheSteve0 (TheSteve0 IRC) PaaS Dust Spreader, Red Hat Sign up code: PyConWorkshop

Workshop For pycon13

Embed Size (px)

Citation preview

Page 1: Workshop For pycon13

1

OpenShift Workshop – Python for the impatient

Steven Citron-Pousty@TheSteve0 (TheSteve0 IRC)PaaS Dust Spreader, Red Hat

Sign up code: PyConWorkshop

Page 2: Workshop For pycon13

2

Agenda• Start with PaaS intro• Show you OpenShift• What does development look like• Do some development – from here on hands on

• Signup code: PyconWorkshop

Page 3: Workshop For pycon13

3

1) You know some Mongo

2) You know or can read some Python

3) You prefer to write code and apps over managing servers or you prefer managing servers rather than dealing with annoying developer requests

Assumptions

Page 4: Workshop For pycon13

4

What is OpenShift?

Red Hat's free, auto-scaling Platform as a Service (PaaS) for applications in the cloud.

Page 5: Workshop For pycon13

5

Kind of like Amazon, right? Nope.

Page 6: Workshop For pycon13

6

What’s supported?

Page 7: Workshop For pycon13

7

What else do I get and what is the catch?

• The Catch is we are in developer preview right now • OpenShift is free-as-in-beer & free-as-in-freedom • Three gears – each one is half a gig of RAM, and 1 gig

of disk (always free)• Need more resources, just ask!

Page 8: Workshop For pycon13

8

Cook24v on Flickr

Page 9: Workshop For pycon13

9

1. Create an application using the command line tools with a DB (python)

2. Create a Wordpress app from the web console

3. Before I start everyone should start installing the command line tools if they haven’t already

Demo

Page 10: Workshop For pycon13

10

Some terminology for today

1. Application – your web code and any data store. Has to be on 1 or more gears

2. Gear – is like a server. It can have only 1 language for the web programming.

3. Cartridge – it adds a language, a data store, or other functionality

4. Git – used for version control and managing code between server and your development machine

5. Ssh – command line tool to connect to your gear

Page 11: Workshop For pycon13

11

GIT

Distributed Version controlA local repository – on your laptop A remote repository – on some other machine, usually a

server

Good place to start - http://sixrevisions.com/resources/git-tutorials-beginners/

Page 12: Workshop For pycon13

12

OK Now it’s your turn

1. Create a python application at the command line1. Modify the source and push it back up

2. Add mongo to your application

Page 13: Workshop For pycon13

13

Mongo Next steps

1. We look at the National Park data together2. We use the code from this github repo :

https://github.com/openshift/openshift-mongo-flask-example

3. We import the national park data into our MongoDB database

4. Look at the code together.5. Write a few of the functions and maybe one of your

own

Page 14: Workshop For pycon13

14

Flask - a microframework for Python

A quick way to add code to handle specific URLs – typical in REST web services – it also does A LOT more

http://flask.pocoo.org/

from flask import Flask

app = Flask(__name__)

@app.route("/") #this is an annotationdef hello():

return "Hello World!"

if __name__ == "__main__": app.run()

Page 15: Workshop For pycon13

15

1. Openshift makes life great for you

2. Lot’s of Python choices

3. The tools are easy to use

4. You should be ready to write services

5. Almost anything you need on a server

6. Did I mention – Free

Conclusion

Page 16: Workshop For pycon13

16

What usually happens on local

Borrowed from: http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository

Page 17: Workshop For pycon13

17

What you do with Remote repositories

Clone – take a remote repository and bring it local

Push – push your local changes back up to a remote

Page 18: Workshop For pycon13

18

You need to understand at least 3 commands in Git

1. Git add . (means add all news files as being tracked in the local repository)

2. Git commit –am “your message” (means commit all my changes to the local repository with this message)

3. Git push (means push from your local repository to the repository on your OpenShift gear)

Page 19: Workshop For pycon13

19

Github

Publically hosted git repositores (can be private if you pay for it)

http://www.github.com

You care about it because:1)We have quickstarts

there2)You can put your

projects there for backup