Posts

Showing posts from October, 2017

OpenStack - Kolla-Ansible prechecks error "Hostname has to resolve to IP address of api_interface"

Following the OpenStack Kolla Ansible documentation I was trying to check my kolla ansible environment by running this command: sudo kolla-ansible prechecks And I got this error: TASK [rabbitmq : fail] ***************************************************************************************************************************************fatal: [localhost]: FAILED! => {"failed": true, "msg": "The conditional check 'item.stdout.find(hostvars[item['item']]['ansible_' ~ hostvars[item['item']]['api_interface']]['ipv4']['address']) == -1' failed. The error was: error while evaluating conditional (item.stdout.find(hostvars[item['item']]['ansible_' ~ hostvars[item['item']]['api_interface']]['ipv4']['address']) == -1): 'dict object' has no attribute 'api_interface' \n\nThe error appears to have been in '/usr/local/share/kolla-ansible/ansibl

Open edX - Course about page not found on LMS and how to fix

If you click on a course from the LMS and it says " Page not foun d", your properly should check this variable in /edx/app/edxapp/lms.env.json and cms.env.json: PREVIEW_LMS_BASE It should not be the same with LMS_BASE . For example: your LMS_BASE is "yourdomain.com", so the CMS_BASE should be something like "preview.yourdomain.com" not "yourdomain.com". So check and change the variable if you got page not found error, then restart your stack, everything will be back to normal.

To install VMWare Workstation 12 Pro on Ubuntu 16.04.3 successfully

In order to successfully install VMmare Workstation 12 Pro on Ubuntu 16.04.3 you have to use at least version 12.5.3. That release of VMware Workstation has fixed the kernel (4.10) incompatibility issue in Ubuntu 16.04.3. Download link:  https://my.vmware.com/web/vmware/details?downloadGroup=WKST-1257-LX&productId=524&rPId=17068 Reference: http://rglinuxtech.com/?p=1937

"ip_proto" parameter in Tacker VNF Forwarding Graph TOSCA template

Here are the list of the available values of the "ip_proto"  (IP Protocol number) in the TOSCA template for the Tacker VNF Forwarding Graph: Decimal Keyword Protocol IPv6 Extension Header Reference 0 HOPOPT IPv6 Hop-by-Hop Option Y [ RFC8200 ] 1 ICMP Internet Control Message [ RFC792 ] 2 IGMP Internet Group Management [ RFC1112 ] 3 GGP Gateway-to-Gateway [ RFC823 ] 4 IPv4 IPv4 encapsulation [ RFC2003 ] 5 ST Stream [ R

Push all the images from a local registry to DockerHub in one go

The other day, I wanted to push all the images from my local Docker registry to the Docker Hub but I didn't want to do it manually so I wrote this bash shell script: What the script's doing basically: 1. Get all the images in the local registry, assuming the image's name is in  this form:  local.registry.domain/branch/image_name:my-tag 2. For each image, create a new tag that match DockerHub's requirement which is: docker_hub_username/my-tag 3. Then push that image into Docker Hub Here is my Docker Hub repositories after finish the PUSH, you can have a look: https://hub.docker.com/u/dangtrinhnt/ Profit!

Check rabbitmq user's credential

This is pretty helpful when you want to check if the user's password of rabbitmq is correct: $ curl -i -u <theuser>:<thepassword> http://<rabitmq-host>:15672/api/whoami

Change rabbitmq user password

Run this command # rabbitmqctl change_password theuser thenewpassword

Pulling all images from a private docker registry

I couldn't find any command that help pulling all the docker images from a private registry so I wrote it myself: Modify the script with your information and run: $ bash pull_all_from_private_docker_registry.sh

How to delete a port with fixed IP address on an OpenStack Pike instance (deployed by Kolla-Ansible)

You cannot delete a network from the dashboard interface if it's attached to a port with fixed IP address on OpenStack (I'm running Pike). So what you have to do is to delete the port directly from the database: 1. Go to the mariadb docker instance: $ docker exec -it <id or name of the nova docker instance> /bin/bash 2. Login to mariadb console using the password in /etc/kolla/passwords.yml $ mysql -u root -p 3. Run these commands to delete the port (you may need to delete all of its relationship, for example from sfc_flow_classifiers table first) use neutron; select id from sfc_flow_classifiers; # get the id of the classifier that linked to the port delete from sfc_flow_classifiers where id='<the id you get from the previous command>'; delete from ports where id='<the port id you get from the dashboard>'; 4. Then you can delete the network.

Openstack Pike (deployed by Kolla-Ansible) can not delete instance from dashboard and how to fix

I's trying to delete an compute instance in an OpenStack environment deployed using Kolla-Ansible from the dashboard but helpless. The instance kept saying error... Then I have to do this workaround to delete it: directly from the database (MariaDB) 1. First login to the bash shell of the nova-compute instance: $ docker exec -it <id or name of the nova docker instance> /bin/bash 2. Go to mariadb console using the password generated when I ran kolla-ansible (/etc/kolla/passwords.yml): $ mysql -u root -p 3. Run these command to delete the instance: use nova; update instances set deleted_at = updated_at,  deleted = id,  power_state = 0,  vm_state = "deleted",  terminated_at = updated_at,  root_device_name = NULL,  task_state = NULL  where  deleted = 0; update instance_info_caches set deleted_at = updated_at, deleted = id where deleted = 0;

Checking to see if one array's elements are in another array in PHP

So you have 2 arrays: $a = array("a", "b", "c", "d"); $b = array("x", "y", "z", "b", "o"); And you want to check if one of the array a's item are in the b array, here is how: if( !empty(array_intersect($a, $b))) {       echo "Gotcha!"; };

How to list all the images on a Docker Registry

Pretty easy: * Normally with a insecure private Docker Registry you would do: curl http://<the domain>:<the port if not 80, usually it's 5000>/v2/_catalog * In a secure private Docker Registry: curl https://<user_name>:<password>@<the domain>/v2/_catalog The result will be something like: {"repositories":["anda/centos-source-aodh-api","anda/centos-source-aodh-base","anda/centos-source-aodh-evaluator","anda/centos-source-aodh-expirer","anda/centos-source-aodh-listener","anda/centos-source-aodh-notifier","anda/centos-source-barbican-api","anda/centos-source-barbican-base","anda/centos-source-barbican-keystone-listener","anda/centos-source-barbican-worker","anda/centos-source-base","anda/centos-source-bifrost-base","anda/centos-source-bifrost-deploy","anda/centos-source-blazar-api","anda/cen

Calculate the date difference between 2 dates in PHP

You can use the diff method  to calculate the dates difference between two DateTime object, for example: $date1 = DateTime::createFromFormat('d-m-Y', '05-09-2017'); $now = new DateTime("now"); $diff = $now->diff($date1); echo "Date difference: " . $diff->format('%a') ; The result will be: Date difference: 30

To use WordPress's wp_delete_user function in your theme or plugin

Just add this line before calling wp_delete_user function: require_once(ABSPATH.'wp-admin/includes/user.php'); wp_delete_user($user->ID);

How to fix "Uncaught TypeError: $(…).owlCarousel is not a function" err

Ok, jQuery included, Owl Carousel included, checked checked checked, still doesn't work. The error kept showing up: Uncaught TypeError: $(…).owlCarousel is not a function What the hell is going on? Then I realized that the jQuery library was included twice by some of the plugins. So I'm using this following technique to get rid of the error: (function($) { $(document).ready(function(){ $("#owl-demo").owlCarousel({ ...  }); }); }) (jQuery);