Showing posts with label Software. Show all posts
Showing posts with label Software. Show all posts

Wednesday, 12 March 2014

Openstack Grizzly slow API and timeouts

I have come across this issue a while ago on our Openstack testbed that as the amount of API calls increase, the delay when you do API calls increased.  Then I discovered that Openstack does not clean the expired tokens automatically when you are using a SQL backend.

https://bugs.launchpad.net/ubuntu/+source/keystone/+bug/1032633

To delete the expired tokens I have created a script so that I can automate this, by creating a cron job.

You can find the script here on my github. Download the script and change the password to your mysql password.

Then create a cron job to periodically execute this script.

0 0 * * * /path/to/keystone_flush 2>&1 >> /path/to/log/keystone_flush.log

Above cron job will run ones everyday. You may change the timing of the job as you desire.

However this problem is solved in Openstack Havana release.

https://blueprints.launchpad.net/keystone/+spec/keystone-manage-token-flush



Friday, 16 December 2011

Install and configure trac on Linux/Ubuntu 11.10

In this blog post I am going to explain about how to install 'trac' on linux. 'trac' is a nice project management tool which is written in python, that can be used to track your projects. And it is open-source :D (Win)

I am using 'trac' with 'git' revision control system, for my project. In my next blog post I will be explain how to use 'trac' along with 'git', using the 'GitPlugin'

 Ok, now if you follow the following instructions hopefully you will have a working 'trac' site.

Install 'trac'
   
Make sure you have the latest version of python installed, otherwise apt will install an older version of 'trac'

      sudo apt-get install python python-babel trac
  



Yes, apt may ask you to install few dependencies including apache2. So please install all of them.

'trac' uses SQLite as its default data store. So if you have not already got it installed. Then do the following


     sudo apt-get install sqlite3


It is possible to get 'trac' working with other database systems. If you are interested, click on the following URL.
http://trac.edgewall.org/

Upgrade python packages
   
There are two ways you can do this

With easy_install
 
 easy_install Babel

 easy_install Trac

or

With 'pip'
 
 pip install --upgrade Babel

 pip install --upgrade Trac


If you have not got pip installed, install pip as follows. Please skip this step if you were successfully able to do the previous step.

 sudo apt-get install python-pip

   
Now you have successfully installed all the software that you need to run 'trac'.
   
Configuration

  Change the directory locations as desired.

 Create a directory for 'trac'
 Then change it's access permissions.

sudo mkdir -p /var/local/trac && chown www-data: /var/local/trac
   
Initialise the 'trac' environment
 
 sudo trac-admin /var/local/trac initenv

   
Now create the configuration file using your favourite text editor. I use emacs.
 
 sudo emacs /etc/apache2/sites-available/trac

   
Paste the following code in to it.
       
<VirtualHost *:80>
 ServerName trac.local
        <Location />
           SetHandler mod_python
           PythonInterpreter main_interpreter
           PythonHandler trac.web.modpython_frontend
           PythonOption TracEnv /var/local/trac
           PythonOption TracEnvParentDir /var/local/trac
           PythonOption TracUriRoot /
           PythonOption TracEnv /var/local/trac
            # PythonOption TracEnvIndexTemplate /var/local/trac/templates/index-template.html
           PythonOption TracLocale en_US.UTF8
           PythonOption PYTHON_EGG_CACHE /tmp
           Order allow,deny
           Allow from all
        </Location>
        <Location /login>
          AuthType Basic
          AuthName "myproject"
          AuthUserFile /var/local/trac/.htpasswd
          Require valid-user
        </Location>
      </VirtualHost>


 Now you should have a working 'trac' instance. So check if it works.
 
      sudo tracd -p 8080 /var/local/trac

[-p] flag specifies the port that this particular 'trac' instance belongs to.
   
Note: the flag [-p] is same as [-port]

And then go to:

      http://localhost:8080/

Now you should see the 'trac' instance running.

Adding Authentication
   
Basic Authorisation

In this case we are going to authorise the 'trac' site with a .htpasswd file.

You have to have 'fcrypt' package installed to decode '.htpasswd'

Creating the '.htpasswd'

 sudo htpasswd -c /var/local/trac/.htpasswd admin

To add more users:
 sudo htpasswd -c /var/local/trac/.htpasswd admin

    
'htpasswd' creates the flat-file with the username and password that you are given.
[-c]  =  create the password file in the given path.

Start tracd:

 sudo -p 8080 --basic-auth="projectdirectory,path/to/the/.htpasswd,mname" /path/to/the/environment/directory


 In my case, it is

 sudo -p 8080 --basic-auth="trac,/var/local/trac/.htpasswd, admin" path/to/the/environment/directory

   
 Digest Authentication
   
 'htdigest' will be used to create the digest file.

 sudo htdigest -c /var/local/trac/.htdigest admin admin
   
  Now start 'trac' with 'tracd':

 sudo -p 8080 --auth="projectdirectory,path/to/the/.htpasswd, admin" /path/to/the/environment/directory

  So it will be,


 sudo -p 8080 --auth="trac,/var/local/trac/.htpasswd, admin" /var/local/trac


  If you have just one project in 'trac', then use the [-s] flag with the 'tracd', so it will skip the environment list when it starts.
      eg: sudo tracd -s ...........

There we go, we are done :D

Trouble Shooting Errors


If you get following error. It is most likely because of permission issues. So make sure you have given root access when you start your 'trac' instance.


Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/trac/web/api.py", line 440, in send_error
    data, 'text/html')
  File "/usr/lib/python2.7/dist-packages/trac/web/chrome.py", line 827, in render_template
    message = req.session.pop('chrome.%s.%d' % (type_, i))
  File "/usr/lib/python2.7/dist-packages/trac/web/api.py", line 216, in __getattr__
    value = self.callbacks[name](self)
  File "/usr/lib/python2.7/dist-packages/trac/web/main.py", line 300, in _get_session
    return Session(self.env, req)
  File "/usr/lib/python2.7/dist-packages/trac/web/session.py", line 198, in __init__
    self.get_session(sid)
  File "/usr/lib/python2.7/dist-packages/trac/web/session.py", line 219, in get_session
    super(Session, self).get_session(sid, authenticated)
  File "/usr/lib/python2.7/dist-packages/trac/web/session.py", line 61, in get_session
    db = self.env.get_db_cnx()
  File "/usr/lib/python2.7/dist-packages/trac/env.py", line 328, in get_db_cnx
    return get_read_db(self)
  File "/usr/lib/python2.7/dist-packages/trac/db/api.py", line 90, in get_read_db
    return _transaction_local.db or DatabaseManager(env).get_connection()
  File "/usr/lib/python2.7/dist-packages/trac/db/api.py", line 152, in get_connection
    return self._cnx_pool.get_cnx(self.timeout or None)
  File "/usr/lib/python2.7/dist-packages/trac/db/pool.py", line 226, in get_cnx
    return _backend.get_cnx(self._connector, self._kwargs, timeout)
  File "/usr/lib/python2.7/dist-packages/trac/db/pool.py", line 146, in get_cnx
    raise TimeoutError(errmsg)
TimeoutError: Unable to get database connection within 0 seconds. (TracError(<babel.support.LazyProxy object at 0x22e47d0>,))


If you need more information, please go to http://trac.edgewall.org.

Tuesday, 12 April 2011

Text Encryption Application

Under the Computer Security module we did one last assignment at the end of the term, the assignment was to implement the substitute cypher and demonstrate how it can be broken by using Frequency Analysis. So I have written a code to encrypt some text using a key, which the user inputs to the application (Which the application assumes that the key is unique), and to Break the encryption using frequency analysis, using Java. It was required to leave the spaces and non alphabetic characters, and maintain the cases in the cipher text (which makes the cypher text weaker).

I have added another extra feature for the cipher breaking code called The "Advanced Frequency Analysis". Which means that, In frequency analysis it just analyses the frequencies of single characters. But if you turn on this feature if will analyse two and three character combinations as well as single characters, which makes the code breaker more strong.

You will probably wonder that why would I want to add extra code to make the encryption weak. As an example this program passes spaces, non alphabetical characters through to the cipher text. It is because that they are requirements of the assignments so students can write about it on the report and give explanations about how to make it more stronger.

Find the screen shots and examples of the program below.

Encryption

Plain Text:

Data centres use vast amounts of electricity to run their computer equipment and also to keep it cool.

Environmental group Greenpeace has estimated that their total global energy use will have reached 2 trillion kw/h by 2020.


Key:

qazxswedcvfrtgbnhyujmkiolp




Cipher Text:

Hjtj koetfor gro bjrt jwdgetr dl osoktfakaty td fge tqoaf kdwcgtof ovgacwoet jei jsrd td xooc at kdds.

Yebafdewoetjs pfdgc Jfooecojko qjr ortawjtoi tqjt tqoaf tdtjs psdmjs oeofpy gro nass qjbo fojkqoi 2 tfassade xn/q my 2020.


Decryption

Advanced Frequency Analysis = off


Decrypted plain text:


Kata lestier dre wart amodstr oq eheltinlntg to ids tueni lomc1dtei ezdnc1mest asf ahro to veec1 nt looh. Jswniosmestah yiodc1 Xieesc1eale uar ertnmatef tuat tueni totah yhopah eseiyg dre bnhh uawe iealuef 2 tinhhnos vb/u pg 2020.


Advanced Frequency Analysis = on



Decrypted plain text:

Kata lestier the wart amodstr in eheltinlntg of for tueni lomc1dtei ezdnc1mest and ahro of veec1 to looh. Jswniosmestah yiodc1 Xieesc1eale his ertnmatef tuat tueni totah yhopah eseiyg the bnhh uawe iealuef 2 tinhhnos vb/u it 2020.



My Example is just a simple demonstration. As you can see its hard to analyse and decrypt just by using an application/ Algorithm, without having any human help. But This algorithm works better as the plain text gets larger, as it gets more data to analyse so the accuracy of the analysis gets better.

Monday, 11 April 2011

My Tetris

'Tetris' is one of the most popular games of all time. For the last project of Application Programming module at the university, I got to develop this small Tetris game applet. As you can see its very basic and simple as I added more than requirements of the assignment, to the application itself. It would have had more functionalities but I moved on from it to the next assignment so I can finish my assignments and get it everything done way before the deadline. I will add more features to it if I get much time in the future, even though I tried ones and then I got busy with something else and then moved on.

To control the blocks You can use either keyboard or mouse or both.

Controls:

Mouse Controls:

Right-Mouse Button- Move right
Left-Mouse Button - Move Left

Key Board Controls:

Right Arrow key- Move Right
Left Arrow key - Move Left
'R' key - Rotate

If I develop it more further I will definitely post it on here. Like I have said it earlier its a very simple version of Tetris. But it plays according do all Tetris rules.


Wednesday, 7 July 2010

John Conway’s Game Of Life

  

    Game of life  is devised John Conway is a British mathematician John Horton Conway in 1970. As a part of my last Java assignment I re designed and added more components to the game under the Java lecturer Professor Simon M. Lucas’s guidance. I was really excited to make this application just after seeing Simon’s example of the Game Of Life.

 

Rules:

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbours, which are the cells that are directly horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

 

  1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  2. Any live cell with more than three live neighbours dies, as if by overcrowding.
  3. Any live cell with two or three live neighbours lives on to the next generation.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths happen simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the one before). The rules continue to be applied repeatedly to create further generations  

-Wikipedia-

 

 

 

             Untitsdfsledd

 

You can create your own rules by changing the bits on the bit editor in the right hand side. You can stop and Resume your game anytime by just pressing the Start/Stop button. By changing bits you can create really cool patterns on the game window. As an example the following picture shows one of the rules I have made

 

             Untitsdsdfdfsledd

I won’t talk about the Java code and the logics of this program but If you want to know or if you want to play this game,  just email me or leave a comment. I’ll send you more information

 

Thank you for visiting My blog

Scribble

 

   Scribble is a painting pad which enables you to draw really cool patterns on it. I made this peace of application as a part of the java assignment under the Java lecturer Professor Simon M. Lucas’s guidance. It’s been a great experience to make this application.  It was a great experience to make Scribble. I was quite excited to see the end product after seeing completed application in the Lectures. I have completed the whole assignment successfully before the dead line and I am glad that I have got quite high marks for it and I have got full marks for this part of the assignment Open-mouthed smile. I will soon post the other past of the assignment and it will be my next blog post.I have posted some random things I drew on it so you can get an Idea about what it looks like. Hope you will like it.

 

 

 

 

                       Untitsdfsledd

 

 

 

                        Untitsledd

 

 

                       Untitled

 

 

 

I wont post anything about the Java Codes of this application but if you want to know about it or if you want to try this application by yourself,  just email me or leave a comment.

 

Thank you for visiting my blog

 

-Chathura Mazz-

Saturday, 3 July 2010

My favourite Online Sync Software

                I have been looking for a good software and a service to store and back up my documents, pictures and songs. Then I did a lot of research about it and found two really cool softwares. Personally I like both of them and I use both of them. They are

 

Dropbox (Download here)

          and 

Gladinet (Download here)

 

                Dropbox uses their own service to service to store files.Once you have uploaded your files to your Box you can access it from anywhere. You can download its desktop client to synchronise your files on you Desktop Computer or Laptop, or you can download the mobile client to your ipad, iphone, Android device or to your Blackberry phone so you can access your synchronised files from your mobile device. and also if you want to access your files without installing anything you can access your files by just logging in to Dropbox website.  This is so Cool because you don’t have to carry your memory sticks or hard drives or anything if you want to transfer or carry your documents. You just have to put your files in to Dropbox so you can access it from anywhere and you can add files to the same Box from where ever you have logged in so it will synchronise your other devices you have installed the clients so then you can access them it from anywhere you want. I use my drop box to store my University course work so I don’t have to carry them in my laptop or in my hard drive. They now have a new Dropbox Chrome extension so you can access your files on your browser  It is very easy to use. You can quite easily share your files with your friends. The only draw back is that you just only get 2GB for free but you can buy more space if you want to.

Step 1 : Go to Drop Box Website or Click here

Step 2 : Download DropBox Client. its available for Windows, Mac and Linux users

Step 3: Register for a DropBox account

Step 4: Add Files to your Box which is in your Windows Documents By default

 

My DropBox

 

 

 

      The other cool software I’m going to review is Gladinet. It is free but you can buy the Professional version which has more capabilities. Gladinet lets you upload files to poplar could storage services such as Skydrive, Amazon S3,Google Docs and other could storage services. I use this service just to back up my documents because they give 25GB for free which other services doesn’t. You can access your files by logging in to your SkyDrive account.Of course you can share your files with friends by getting the URL of the file or put them into a public folder. The thing I like about the Gladinet is its Management Console. You have bunch of cool tools on there to mange to use. You can transfer up to 50Mb large files in a one go but if you want to upload bigger files it spits the file into many parts and uploads it, when ever you wants do download it Gladinet puts them back together automatically. I found it very useful as I have been baking up large files.After you create set it up it creates a virtual drive in your computer so you can easily access your drive and transfer your files in to it.

I am sorry this is not a How-To  tutorial  so I wont explain how to set it up but if you want me to just let me know so I can do a video or a blog post about it.

 

The Gladinet Management Console

 




    So yea those two are my favourite Syncing softwares at the moment. I will keep you guys posted if I find anything better.  Thanks.