Skip to main content

Posts

Showing posts from July, 2018

Bridging and assign the network interface

1) Install the bridge-utils packages 2) Edit the following file: /etc/network/interfaces auto lo iface lo inet loopback auto eno1 iface eno1 inet manual auto br-eth0 iface br-eth0 inet dhcp bridge_ports eno1 3) stop the network manager, if its running          systemctl stop NetworkManager-wait-online.service           systemctl  disable NetworkManager.service 4) Restart the networking script

Python Multithreading Example

import requests import threading count = 0 fcount = 0 nreach = 0 def myWorker():     global nreach     try:          r  = requests.get("http://10.184.36.38:8088/")          print "Thread Name ", threading.current_thread().name          if r.status_code == 200:              global count              count = count +1          else:              global fcount              fcount = fcount + 1          print "%d   %d" %(count, fcount)           except requests.ConnectionError:         print "%s No Connection " %(threading.current_thread().name)         nreach=nreach+1         print "Not ...

Delete Instance entry from Databases Openstack

First take a dump of sql for any inconvenience happened during the delete entries           mysqldump -u root -p --all-databases > xxxxx.sql Now do the following procedure to remove the entry from the databases,  Use nova; 1) SELECT id, uuid, vm_state, deleted, power_state FROM instances WHERE vm_state = "error"; If you change the flag of deleted field to 1, then it will not display on the dashboard of openstack. But the entry persist in the database only.     mysql> update instances set deleted=1 where uuid='698b67f0-6904-4090-ad4d-a9bf79ae5920'; 2) Check the security groups table security_group_instance_association, any value assosicated with particular uuid     mysql> select * from security_group_instance_association ; 3) Check with block_device_mapping table, any devices attached to particular uuid.    mysql> select * from block_device_mapping where instance_uuid='698b67f0-6904-4090...

Read Mail Inbox - Easy coding with python

Install email and imaplib package from pip install. Continue the following programme. import email import imaplib def read_email():       try:         mail = imaplib.IMAP4_SSL("imap.gmail.com")         mail.login("xxxxx@gmail.com", "xxxxxx") #        mail.select('"[Gmail]/Sent Mail"', readonly=True)         mail.select('INBOX', readonly=True)         type, data = mail.search(None, 'ALL')         mail_ids = data[0]         id_list = mail_ids.split()         first_email_id = int(id_list[0])         latest_email_id = int(id_list[-1])         for i in range(latest_email_id, first_email_id-1, -1):             typ, data = mail.fetch(i, '(RFC822)')             for response_part in data:   ...

JAVA AES-256 Encryption and Decryption

By default java support 128 bit symmetric key encryption. If you want extended policy of 256 bit key, you have to download the extended policy jar and install into jre/lib/security folder. AES - 256 Encryption and Decryption import java.security.MessageDigest; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; import org.springframework.stereotype.Service; import javax.xml.bind.DatatypeConverter; public class AESAlgorithmService { private String _secretPass = "MyPr!vateKEy"; private SecretKeySpec keyGeneration(String secret) throws Exception { MessageDigest sha = MessageDigest.getInstance("SHA-256"); byte[] digest = sha.digest(secret.getBytes("UTF-8")); SecretKeySpec secretKey = new SecretKeySpec(digest, "AES"); return secretKey; } public byte[] encrypt(String sSrc) throws Exception { SecretKeySpec _secretKey = keyGeneration(_secretPass); Cipher cipher = Cipher.getInstance("AES/E...

Problem in STS IDE Navigation Menu

Tips ===== 1) When you open the STS IDE (Spring Tool Suite), the Navigation menu not coming properly due to work bench problem, So remove the following file and restart the eclipse it will work               sudo rm .metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi