lOMoARcPSD|37612454
UNIT-V
IoT Physical Servers and Cloud Offerings
Introduction to Cloud Storage Models and Communication APIs
Cloud computing is a transformative paradigm that involves delivering applications and services
over the internet.
Cloud computing is a model for enabling ubiquitous, on-demand network access to a shared pool
of configurable computing services.
WAMP-AutoBahn for IoT
Web Application Messaging Protocol(WAMP) is a sub-protocol of websocket which provides
publish-subscribe and Remote Procedural Call(RPC) messaging protocol. WAMP enables
distributed application architectures where application components are distributed on multiple
nodes and communicate with messaging patterns provided by WAMP.
Key concepts of WAMP:
Transport: Transport is a channel that connects two peers. The default transport for WAMP is
WebSocket.
Session: Session is a conversation between two peers that runs over transport.
Client: Clients are peers that can have one or more roles. In publish-subscribe model client can
have following roles:
- Publisher: Publisher publishes events to the topic maintained by broker.
- Subscriber: Subscriber subscribes to the topics and receives the events including the
payload.
In RPC model client can have following roles:
- Caller: Caller issues calls to the remote procedures along with call arguments.
- Callee: Callee executes the procedure to which the calls are issued by the caller and
returns the results back to the caller.
Router: Routers are peers that can perform generic call and event routing. I publish-subscribe
model router has role of a broker:
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
- Broker: Broker acts ad a router and routes messages published to a topic to all subscribed
to the topic.
In RPC model router has the role of a broker:
- Dealer: Dealer acts as a router and routes RPC calls from caller ro the calee and routes
results from Callee to caller
Application code: Application code runs on the clients(Publisher,Subscriber,Callee or caller).
Figure shows a WAMP session between Client and Router, established over a Transport.
Figure shows WAMP protocol interactions between peers. The WAMP transport used is
WenSocket. WAMP sessions are established over WebSocket transport within the lifetime of
WebSocket transport.
Following figure shows the communication between various components of a typical WAMP-
AutoBahn deployment. The client (in publisher role) runs a WAMP application component that
publishes messages to the router. The router (in broker role) runs on the server and routes
messages to the subscribers. The router (in broker role) decouples the publisher from the
subscribers. The communication between Publisher-Broker and Broker-Subscribers happens
over a WAMP-WebSocket session.
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Commands for installing AutoBahn:
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Xively cloud for IoT
Xively is a commercial platform-as-a-service that can be used for creating solutions for IoT.
With xively cloud, IoT developers can focus on front-end infrastructure and devices for IoT,
while the backend data collection infrastructure is managed by xively.
Xively platform comprises of a message bus for real-time message management and routing.
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
To start using xively, you have to register for developer account. You can then create
development devices for xively. Xively automatically creates a Feed-ID and API key to connect
to the device. Each device has a unique Feed-ID. Feed-ID is a collection of channels for meta-
data. API keys are used to provide different levels of permissions. The default API key has read,
update, create and delete permissions.
Xively devices have one or more channels. Each channel enables bi-directional communication
between the IoT devices and xively cloud. IoT devices can send data to a channel using the
xively APIs. For each channel, you can create one or more triggers.
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Python Web Application Framework-Django
Django is an open source web application framework for developing web applications in python.
A “web application framework” in general is a collection of solutions, packages and best
practices that allows development of web applications and dynamic websites. Django is based on
well-known Model-template-View architecture and provides a separation of the data model from
business rules and user interface.
Django architecture:
Django is a Model-Template-View(MTV) framework wherein the roles of model, template and
view, respectively.
Model: The model acts as a definition of some stored data and handles the interactions with the
database. In a web application, the data can be stored in a relational database, non-relational
database, an XMLfile, etc.
Template: In a typical Django web application, the template is simply an HTML page with a few
extra placeholders.
View: The view ties model to template. The view is where you write code that actually generates
the web pages.
Starting Development with Django
Creating a Django project and App
Commands for creating a Django project and an application within a project.
__init__.py: This file tells that this folder is a python package.
Manage.py: This file contains an array of functions for managing the site.
Settings.py: This file contains the website’s settings
Urls.py: This file contains the URL patters that map URLs to pages.
When a new application is created a new directory for the application is also created which has a
number of files including:
Model.py: This file contains the description of the models for the application.
Views.py: This file contains the application views.
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Configuring the database:
Django supports various non-relational databases such as MySQL, PostgreSQL, Oracle and
SQLite3. Support for non-relational databases such as MongoDB can be added by installing
additional engines.
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Defining a Model
A model acts as a definition of the data in the database.
Syncdb command: when this command is run for the first time, it creates all the tables defined in
Django model in the configured database.
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Django admin site
Django provides an administration system that allows you to manage website without writing
additional code. This “admin” system reads the Django model and provides an interface that can
be used to add content to the site.
Defining a View
The view contains the logic that glues the model to template. The view determines the data to be
displayed in the template, retrieves the data from the database and passes it to the template.
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Defining a template
A django is typically an HTML file. Django templates allows separation of the presentation of
data from actual data by using placeholders and associated logic.
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Defining URL patterns
URL patterns are a way of mapping the URLs to the view that should handle URL requests. The
URLs requested by the user are matched with URL patterns and the view corresponding to the
pattern that matches the URL is used to handle request.
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
With the models, views, templates and URL patterns defined for Django project, the application
is finally run with the following commands.
Designing a RESTful Web API
Django REST framework can be installed as follows:
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Example:
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)
lOMoARcPSD|37612454
Downloaded by Rajendra Palaparthi (palaparthirajendra83@gmail.com)