Posts

Showing posts with the label local

How to dev a new Horizon dashboard without devstack/fullstack OpenStack

Everybody knows the easiest way to build a new Horizon dashboard is to use devstack. But, devstack requires a number of resources (16GB of RAM for a workable devstack in my experience). So what can you do if you only have a laptop with 4-8GB RAM? Easy, easy, follow these setups: 1. Install keystone (the minimum requirement of Horizon): Follow this official instruction:  https://docs.openstack.org/keystone/latest/install/keystone-install-ubuntu.html Read these blog posts to fix some issues: http://www.dangtrinh.com/2018/03/fix-error-attributeerror-module-object.html http://www.dangtrinh.com/2018/03/fix-importerror-cannot-import-name.html http://www.dangtrinh.com/2018/03/how-to-fix-index-column-size-too-large.html 2. Install Horizon: Follow this official instruction to install Horizon on your computer:  https://docs.openstack.org/horizon/latest/contributor/quickstart.html#quickstart 3. Building your own dashboard: Using this document:  https...

How to dev and test python libs on your OpenStack's devstack

In OpenStack Devstack, the python packages/libs such as python-tackerclient, tacker-horizon are not easy to dev because normally they will be installed under python's site-packages. So, to make it easier for us to developing these libs, follow the instructions below: 1. Clone the python packages that you want, for example: tacker-horizon: cd /opt/stack/ git clone git://git.openstack.org/openstack/tacker-horizon 2. Go inside the cloned directory and install it using pip : cd tacker-horizon sudo pip install -U -e . 3. Make the changes and enjoy Note:  if you work with tacker-horizon, you may have to restart apache2 server: sudo systemctl restart apache2

Install a python package from a local directory with pip

Normally you will use pip to install a python package from pypi. But, actually you can do it from a local directory using the "-e" parameter: pip install -e /local/directory

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!

Force git pull from remote

If you want to discard the commits you've made locally, i.e. never have them in the history again, you can just do a hard reset: # fetch from the default remote, origin git fetch # reset your current branch (master) to origin's master git reset --hard origin/master

How to make rabbitmq runs on localhost only

If you don't care about rabbitmq clustering like I do, you can setup rabbitmq to listen connections from localhost only: $ sudo nano /etc/rabbitmq/rabbitmq-env.conf RABBITMQ_NODE_PORT=5672 RABBITMQ_NODE_IP_ADDRESS=127.0.0.1 RABBITMQ_NODENAME=rabbit@myhostname (RabbitMQ 3.3.4) References:  [0] http://serverfault.com/questions/235669/how-do-i-make-rabbitmq-listen-only-to-localhost [1]  http://gigisayfan.blogspot.com/2012/06/rabbit-mq-clustering-python-fabric.html

Google App Engine SDK for Python - Using datastore query at local for testing

When I tried to do some test of datastore query in the python console: query = MyModel.all() query.filter("username =", "myusername") result = query.get( ) I got this error" BadArgumentError: app must not be empty. After googling around, I found this solution: before execute the query, run these following commands: import os os.environ['APPLICATION_ID'] = 'dangtrinhnt'                                datastore_file = '/dev/null' from google.appengine.api import apiproxy_stub_map,datastore_file_stub apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap() stub = datastore_file_stub.DatastoreFileStub('dangtrinhnt', datastore_file, '/') apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub) Then, execute any query I want, for example the query at the beginning of this blog post (the blue lines). Refere...

Django + Heroku - Local and Heroku database environement settings

I deployed a Django app in Heroku following these instructions: https://devcenter.heroku.com/articles/getting-started-with-django I could push source code to Heroku and the app ran successfully in that environment. But, when I run " ./manage syncdb " command locally, the console told me that I had an improperly DATABASE setting. I figured out that the setting line of Heroku is the problem: DATABASES['default'] =  dj_database_url.config() It overrode the default database setting of Django which was right above this line. Only Heroku will understand and use a specific setting for its environment. So, I used the following method to help Django to figure out the DB engine: DATABASES = {} import dj_database_url import socket if socket.gethostname() not in ['trinh-pc']:     DATABASES['default'] =  dj_database_url.config() else:     DATABASES['default'] =  dj_database_url.config(default='postgres://myuser:mypwd@localhost/mydb...

Shell - Copying file from remote server to local machine

Sometime you want to copy something (files) from your remote server to your local machine. The thing is, the remote server is the only one that has ssh, so you can only push file to it (remote one) through scp command. I found the rsync command that solves the problem: (type this in your local machine's terminal) rsync -chavzP --stats user@remote.host:/path/to/copy /path/to/local/storage