Monthly Archives: February 2014

python随机密码生成/password generator – 试试代码高亮

import string
import random

def pwdgen(size = 8):
    if size < 6:
        return 'Length must be at least 6'
    lchars = string.ascii_lowercase
    uchars = string.ascii_uppercase
    digits = string.digits

    schars = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
#    schars = ''
#    for i in range(33,48):
#        schars += chr(i)
#    for i in range(58,65):
#        schars += chr(i)
#    for i in range(91,97):
#        schars += chr(i)
#    for i in range(123,127):
#        schars += chr(i)

    allchars = schars + lchars + uchars + digits

    pwd = []
    pwd.extend([random.choice(schars) for i in range(random.randint(1,2))])
    pwd.extend([random.choice(lchars) for i in range(random.randint(1,2))])
    pwd.extend([random.choice(uchars) for i in range(random.randint(1,2))])
    pwd.extend([random.choice(digits) for i in range(random.randint(1,2))])
    csize = len(pwd)
    pwd.extend([random.choice(allchars) for i in range(size - csize)])

    random.shuffle(pwd)
    return "".join(pwd)

if __name__ == '__main__':
    size = 8
    print pwdgen(size)

#print newpwd

openstack manual installation troubleshootings

1. [root@controller ~]# nova network-create vmnet –fixed-range-v4=10.0.0.0/24 –bridge-interface=br100 –multi-host=T
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500) (Request-ID: req-bb23e78d-5c1e-4c20-a1c4-c789877604c0)

My reason: compute note cannot reach the mysql of controller node….

2. libvirtError: internal error no supported architecture for os type ‘hvm’
Reason: I’m installing openstack on a vm
Solution: set libvirt_type=qemu in /etc/nova/nova.conf

3. dashboard login failure
[error] DeprecationWarning: Translations in the project directory aren’t supported anymore. Use the LOCALE_PATHS setting instead.DeprecationWarning: Authentication backends without a `supports_inactive_user` attribute are deprecated. Please define it in <class ‘openstack_auth.backend.KeystoneBackend’>.DeprecationWarning: BaseException.message has been deprecated as of Python 2.6Login failed for user “admin”.
Solution: edit /etc/openstack-dashboard/local_settings to set:
OPENSTACK_KEYSTONE_DEFAULT_ROLE = “admin”

Another possible reason: disable selinux please…