22 June 2017

Python PyPi mirror in virtualenv (bandersnatch)

First of all PEP381 is no longer supported and won't work. Use bandersnatch instead.
For customized mirrors with whitelists, etc use devpi.

Example:
Python 2.7
Virtualenv path:  /data/pypi_mirror/
Mirror path: /data/pypi_mirror/data/
Url: local-pypi.local.com

Create and activate virtualenv
cd /data/
mkdir /pypi_mirror
mkdir /pypi_mirror/data
virtualenv pypi_mirror
source ./pypi_mirror/bin/activate

Install packages
sudo pip install bandersnatch
sudo pip install configparser
sudo pip install --upgrade future
sudo pip install --upgrade websocket
sudo pip install --upgrade urllib3

Allow Apache to access files:
cd /pypi_mirror
sudo chown -R apache:apache data

Configure Bandersnatch:

sudo vi /etc/bandersnatch.conf

[mirror]
directory = /data/pypi_mirror/data/
master = https://pypi.python.org
timeout = 10
workers = 3
stop-on-error = false
delete-packages = true

Enable Virtual Host in Apache:

Create virtual host:
cd /etc/httpd/sites-available/
vi webapps_pypi.conf    :

NameVirtualHost <SERVER IP>:80
<VirtualHost <SERVER IP>:443>
        SSLEngine               on
        SSLCertificateFile         *****
        SSLCertificateKeyFile   *****
        SSLProtocol             all -SSLv3
        ServerName              local-pypi.local.com
        ServerAlias             local-pypi
        DocumentRoot            /data/pypi_mirror/data/web/
        SetEnv                  /data/pypi_mirror/data/
        ErrorLog                /data/pypi_mirror/pypi.error.log
        CustomLog               /data/pypi_mirror/pypi.custom.log combined
</VirtualHost>
<VirtualHost <SERVER IP>:80>
        ServerName              local-pypi.local.com
        DocumentRoot            /data/pypi_mirror/data/web/
        Redirect permanent /    https://local-pypi.local.com/
</VirtualHost>

Enable the Virtual Host and restart Apache:
cd /etc/httpd/sites-enabled/
sudo ln -s ../sites-available/webapps_pypi.conf webapps_pypi.conf

sudo /usr/sbin/apachectl restart

Run mirror synchronization
sudo bandersnatch mirror



Execution Errors:
Cannot find parse module in urllib.parse 

sudo vi /lib/python2.7/site-packages/bandersnatch/package.py

Replace line:
from urllib.parse import urlparse, unquote 
With:
 try:
    from urllib.parse import urlparse, unquote
except ImportError:
     from urlparse import urlparse, unquote

Errors  encoding parameter not supported:
sudo vi /lib/python2.7/site-packages/bandersnatch/mirror.py

Search for:
with open(
Remove parameter:
*, encoding="..." )



25 June 2016

Cisco 3750 mixed stack

Today I was able to do some testing on a  mixed stack of C3750, C3750G and C3750X.
It is not a secret that C3750X with lan-base license can only stack with other lan-base 3750X. In make case it was ip-base, but I needed to upgrade all stack to ip-services, which it was using before 3750X was added. So have a note, that below works fine (as long as stack master will be another  older switch with ip-services):
C3750 - ipservices
C3750G - ipservices *master
C3750X - universal

Also played with SDM profile. Even though desktop-routing allows up to 11K prefixes, in reality with about 8K CPU gets up to 40% with almost no usage and easily reaches 100% when more traffic appears.

03 June 2016

ManG - Bulk ping tool (python)


ManG - tiny program that resolves and pings a list or IP addresses or ranges.
You need to run this program as administrator (uses native python ping with sockets).
 

Python 2.7
PyQt
Tested on: Ubuntu, Windows 7
Windows binary
Source
Also on GitHub: ManG

Windows dependencies:
MSVCP90.dll library is not included. You may need to download and install "Microsoft Visual C++ 2008 Redistributable Package"

This program is distributed under GNU CPL