Find out how you can easily create or manageyour On-premise or Multi Cloud servers/applications – all from one place: yourcustom platform
Nowadays, the cloud services offer is increasing from day to day, trying to match the consumers' needs. There are 3 cloud providers that are the most used: Amazon Web Services, Azure Cloud and Google Cloud Services. All these cloud providers are offering both Public and Private Cloud services.
Also, there are a lot of companies that, for complying to the privacy and security regulations, they need to run their applications and store their data in an on-premises infrastructure.
For more and more of these companies, as they grow up, their needs become more complex in terms of IT infrastructure and improving the development and deployment processes for their applications. So it will become a harder and harder job to maintain multiple platforms, to setup users and groups for each one, to generate reports from each one etc.
Here it comes the question: what would we need to simplify things and get rid of a lot of time-consuming tasks? I'm sure that one of the reliable answers is to use a single platform that will manage all the servers and applications that run on different cloud solutions, even on-premises cloud.
Let's say you also have identified the same answer as correct. If so, the next question will come into your mind for certain: How could we easily develop such a platform? What technologies should we use in order to achieve this? Well, it is a certitude that this question can have a bunch of answers, but I think one of the valid ones could be: Django Web Framework.
So, what is Django? As it is also stated on the official website, “Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and opensource.” What we can conclude from this description is that Django is exactly what we need in order to develop our cloud platform.
Django framework follows the Model-View-Controller architecture. MVC is an architectural design pattern that divides an application into three main logical components: the model, the view and the controller.
A Model reflects real-world things, you could think of it as of a class, a definition of an object. For example, in case of a cloud platform, probably Server would be the first model that you can think of. In case of a to-do app, Task could be a model. And soon…
A View is a Python function that takes a web request and returns a web response. Usually, this response is the HTML content of a web page, but it can be an image, a redirect, almost anything. It is used for all the UI logic of the application. It will include the UI components like dropdowns, text boxes etc.
A Controller is the interface between Model and View components, it processes all the incoming requests, it manipulates date using the Model component and it renders the final output using the View.
So what are Django’s strengths? First of all, Django is a complete solution: everything you need is part of one product and it works seamlessly together.
Another feature is its versatility in terms of the platform that it can be installed and run on. It can run on almost any platform. You just need to install it along with all its required dependencies.
Also, the security is one of the Django’s strengths. It provides a secure way to manage users accounts and passwords ,avoiding common mistakes in terms of security (SQL Injection, XSS, CSRF, directly storing the passwords, putting session information in cookies etc.).
Django can be installed very easily. As a prerequisite, you first need to install python, pip and postgresql. After that, you just need to install python-django package using pip.
However, the recommended way to install Django framework is by using virtualenv (pip install virtualenv). Onceyou have installed virtualenv, run bin/activate script to activate theenvironment and then install Django (pip install django).
And that’s it, you are now ready to spin-upyour new Django project using virtualenv startproject command. This command will generate the directories structure and all the files needed to run a Django project.
One of the best tools for developing Django projects, that will make your life easier, is JetBrains PyCharm, one of the most popular Python IDE. It will help you be more productive, it provides advanced code completion, error detection, smart code navigation and so on. Also, you can run the virtualenv commands right from the PyCharmTerminal.
So the first step you need to take after you created the project is to create a Postgresql database, along with a user and required privileges. Then you will have to update the settings.py file with the database details.
Now you should define the Servers model in the models.py file, along with its properties: server_name, size,image, ip, port, username, password, location etc. The location property could be used to specify where the server is going to be provisioned (AWS, Azure, on-premise etc.). After defining the model, if you run the makemigrations and migrate commands, you should see there have been created a new table in the database, which will be used to keep information about the provisioned servers.
Next, you need to create another Model for defining the cloud providers. Its id will act as a foreign key for the Server’s location property.
Then it’s time to create the first App within the Django project: the Manager app. The Manager app will be used to manage users, cloud endpoints and other administration tasks.
After that, we need a couple of Views for the Servers model: one for showing the list of existing servers and one for creating/updating/deleting servers. Each View, besides the functions for getting information about the servers and for rendering the templates that will be displayed in the web page, will also contain a function that will create/update/delete cloud servers by making API calls to the cloud providers or to the on-premise virtualization hypervisors.
Here I talked briefly about a light version of a cloud platform, but there could be added a lot more complex features. If I piqued your interest and you want to learn more about Django, please check the official website, where you will find a lot of useful resources: https://www.djangoproject.com/