Posts

Deploy OpenStack on a single Ubuntu16.04 server using conjure-up

Image
I'm sure that you heard a lot about the greatness of Canonical's conjure-up tool and how easy it is to deploy cloud platforms e.g. Kubernete, OpenStack etc... According to the conjure-up and Ubuntu websites, it's straightforward to have those big stack installed:

[0] https://conjure-up.io/
[1] https://www.ubuntu.com/download/cloud/try-openstack

$ sudo snap install conjure-up --classic
$ conjure-up

That's all they says. But, seriously, when I tried to deploy the Openstack NovaLXD (deploy OpenStack's components into LXD containers) using conjure-up in Ubuntu 16.04, it's pain in the ass. I spent almost 3 days to make it work. Let me explain what happened:

In Ubuntu 16.04, you can only use conjure-up installed through snappy not through apt:

$ sudo snap install conjure-up

That's not much of a deal as you can see. The problem is that conjure-up cannot communicate with the default LXD (network bridge interfaces, storage pools) shipped with Ubuntu 16.04. I felt super c…

Simple real time search and filter using jQuery

Let's say you have a list of HTML elements (div) and you want to implement the search and filter functionality. Here is dead simple example:

Assuming your HTML block looks like the following:

<div>
<input type="text" id="search" placeholder="Type to search">
<button id="search-btn">Search</button>
</div>

<div class="list-partner">
<div class="partner-item">...</div>
        <div class="partner-item">...</div>
        <div class="partner-item">...</div>
</div>

And this javascript snippet will add the magic:

<script>
var rows = jQuery('.list-partner .partner-item');
jQuery('#search-btn').click(function() {
var val = jQuery.trim(jQuery('#search').val()).replace(/ +/g, ' ').toLowerCase();

rows.each(function(){
var itemtxt = jQuery(this).text().replace(/\s+/g, ' ').toLowerCase();
if(itemtxt.indexOf(va…

Reset the containerized OpenStack Dashboard admin's password using JuJu

If you're running a containerized OpenStack's architecture (e.g. conjure-up will deploy OpenStack this way), you must have a tool to orchestrate all the containers. I'm using Ubuntu's JuJu and really love it. For example, in order to reset the OpenStack Dashboard admin's password, I don't have to directly go into the keystone service to do that, I just run this from the host machine:
1. Find the machine's number and ip address on which the keystone installed
$ juju machines
For example, the machine number is 9, ip address is 10.232.45.216
2. Reset the admin's password to 12345678 (the default user is admin): 
$ juju run "sudo keystone --os-auth-url=http://10.232.45.216:35357/v2.0 --os-endpoint=http://10.232.45.216:35357/v2.0 --os-token=48FM7htnHkxxHkNT2RmMNxwpYRRcnmp8dbghtwMYWcg2BRRs9qmcMMtRww8tTCZ4 user-password-update --pass 12345678 admin" --machine=9

How to access OpenStack Dashboard installed in a headless Ubuntu server using conjure-up

After I finished installing OpenStack using Ubuntu's conjure-up on a single machine, I found myself struggle to access the dashboard. The only machine that can access the OpenStack Dashboard is the host server which is a headless Ubuntu server. It's because conjure-up installs OpenStack by deploy its components to multiple containers with a virtual private network that connects those services. So in order to access the dashboard from outside, I had to create an iptable rule that NAT the OpenStack Dashboard container's http port (443 or 80) to a host server's port (443 properly). Here is an example:

sudo iptables -t nat -A PREROUTING -p tcp -d <ip of the host server> --dport 443 -j DNAT --to-destination <internal ip of the openstack dashboard service, usually 10.x.x.x>:443

After that, I was able to access the OpenStack web interface from other machines.

Get url parameter using javascript

This is pretty neat javascript snippet to get the URL's parameters:


var getUrlParameter = function getUrlParameter(sParam) {
    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : sParameterName[1];
        }
    }
};