setup.py
author Jens Kasten <jens@kasten-edv.de>
Sat, 24 Aug 2013 14:45:02 +0200
changeset 128 dcbcfd2a5421
parent 127 8eb957db5ee1
permissions -rw-r--r--
Added tag version 0.1.7.8 for changeset 8eb957db5ee1
23
06bcb6cf751c add hgignore; move kvm-admin to bin/kvm-admin and do small fixes; add setup.py for installation
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     1
#!/usr/bin/env python
52
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
     2
#
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
     3
# Setup routine
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
     4
#
23
06bcb6cf751c add hgignore; move kvm-admin to bin/kvm-admin and do small fixes; add setup.py for installation
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
     5
52
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
     6
"""
127
8eb957db5ee1 fix bridge name with score or underscore
Jens Kasten <jens@kasten-edv.de>
parents: 124
diff changeset
     7
(c) 2011-2013 Jens Kasten <jens@kasten-edv.de>
8eb957db5ee1 fix bridge name with score or underscore
Jens Kasten <jens@kasten-edv.de>
parents: 124
diff changeset
     8
8eb957db5ee1 fix bridge name with score or underscore
Jens Kasten <jens@kasten-edv.de>
parents: 124
diff changeset
     9
last modified: 20130823
52
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
    10
"""
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
    11
105
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    12
from distutils.core import setup
99
6d18a01818cd modify setup.py script
Jens Kasten <jens@kasten-edv.de>
parents: 90
diff changeset
    13
import os
6d18a01818cd modify setup.py script
Jens Kasten <jens@kasten-edv.de>
parents: 90
diff changeset
    14
import sys
55
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 52
diff changeset
    15
from shutil import copytree, copy, rmtree
79
d8c812880133 add a call to generate-kvm-option when setup.py is executing
Jens Kasten <jens@kasten-edv.de>
parents: 68
diff changeset
    16
from subprocess import call
55
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 52
diff changeset
    17
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 52
diff changeset
    18
from kvmtools.header import Header
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 52
diff changeset
    19
105
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    20
55
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 52
diff changeset
    21
def copy_configs():
105
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    22
    path = Header()
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    23
    example = os.path.join(path.kvm_domains_dir, "example")
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    24
    if os.path.isdir(path.kvm_scripts_dir):
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    25
        rmtree(path.kvm_scripts_dir)
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    26
    copytree("scripts", path.kvm_scripts_dir)
90
0f3a912559a4 fix setup.py, now after chmod +x to all network scripts otherwise guest won't boot
Jens Kasten <jens@kasten-edv.de>
parents: 79
diff changeset
    27
    # make the network script executable
105
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    28
    for i in os.listdir(path.kvm_scripts_dir):
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    29
        if os.path.isfile(os.path.join(path.kvm_scripts_dir, i)):
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    30
            os.chmod(os.path.join(path.kvm_scripts_dir, i), 0755)
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    31
    if os.path.isdir(path.kvm_config_dir):
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    32
        rmtree(path.kvm_config_dir)
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    33
    copytree("config", path.kvm_config_dir)
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    34
    os.chmod(path.kvm_config_dir, 0755)
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    35
    if not os.path.isdir(path.kvm_domains_dir):
127
8eb957db5ee1 fix bridge name with score or underscore
Jens Kasten <jens@kasten-edv.de>
parents: 124
diff changeset
    36
        os.mkdir(path.kvm_domains_dir)
105
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    37
    os.chmod(path.kvm_domains_dir, 0755)
55
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 52
diff changeset
    38
    copy("domains/example", example)
105
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    39
    if not os.path.isdir(path.kvm_auto_dir):
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    40
        os.mkdir(path.kvm_auto_dir)
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    41
    os.chmod(path.kvm_auto_dir, 0755)
23
06bcb6cf751c add hgignore; move kvm-admin to bin/kvm-admin and do small fixes; add setup.py for installation
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    42
99
6d18a01818cd modify setup.py script
Jens Kasten <jens@kasten-edv.de>
parents: 90
diff changeset
    43
if os.getuid() != 0:
6d18a01818cd modify setup.py script
Jens Kasten <jens@kasten-edv.de>
parents: 90
diff changeset
    44
    print "Script need root user rights to install."
6d18a01818cd modify setup.py script
Jens Kasten <jens@kasten-edv.de>
parents: 90
diff changeset
    45
    print "Change user to root user or use sudo."
6d18a01818cd modify setup.py script
Jens Kasten <jens@kasten-edv.de>
parents: 90
diff changeset
    46
    sys.exit(1)
23
06bcb6cf751c add hgignore; move kvm-admin to bin/kvm-admin and do small fixes; add setup.py for installation
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    47
105
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    48
files = [os.path.join("bin", i) for i in os.listdir("bin")]
938d696a213e restructe:
Jens Kasten <jens@kasten-edv.de>
parents: 99
diff changeset
    49
dirs = [os.path.join("kvmtools", i) for i in os.listdir("kvmtools") if os.path.isdir(os.path.join("kvmtools",i))]
52
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
    50
dirs.append("kvmtools")
23
06bcb6cf751c add hgignore; move kvm-admin to bin/kvm-admin and do small fixes; add setup.py for installation
Jens Kasten <jens@kasten-edv.de>
parents:
diff changeset
    51
40
90ae907ef8be modify setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 30
diff changeset
    52
setup(
52
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
    53
    name = "kvmtools",
127
8eb957db5ee1 fix bridge name with score or underscore
Jens Kasten <jens@kasten-edv.de>
parents: 124
diff changeset
    54
    version = "0.1.7.8",
52
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
    55
    keywords = ["kvm-admin", "kvmtools"],
40
90ae907ef8be modify setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 30
diff changeset
    56
    author = "Jens Kasten",
90ae907ef8be modify setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 30
diff changeset
    57
    author_email = "jens@kasten-edv.de",
52
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
    58
    description = ("Tools to manage kvm guests on commandline."),
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
    59
    license = "GPL2",
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
    60
    packages = dirs,
cd1da09ac278 update setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 40
diff changeset
    61
    scripts = files
40
90ae907ef8be modify setup.py
Jens Kasten <jens@kasten-edv.de>
parents: 30
diff changeset
    62
)    
55
1d4c061d1502 update and fixes for new structur
Jens Kasten <jens@kasten-edv.de>
parents: 52
diff changeset
    63
copy_configs()
79
d8c812880133 add a call to generate-kvm-option when setup.py is executing
Jens Kasten <jens@kasten-edv.de>
parents: 68
diff changeset
    64
# generate qemu-kvm options
99
6d18a01818cd modify setup.py script
Jens Kasten <jens@kasten-edv.de>
parents: 90
diff changeset
    65
try:
6d18a01818cd modify setup.py script
Jens Kasten <jens@kasten-edv.de>
parents: 90
diff changeset
    66
    call(["generate-kvm-options", "-g"])
6d18a01818cd modify setup.py script
Jens Kasten <jens@kasten-edv.de>
parents: 90
diff changeset
    67
except KeyboardInterrupt:
6d18a01818cd modify setup.py script
Jens Kasten <jens@kasten-edv.de>
parents: 90
diff changeset
    68
    sys.exit(0)