コード例 #1
0
ファイル: openvim.py プロジェクト: AdamIsrael/openvim
def setup_images_folder():
    status_set("maintenance", "Setting up VM images folder")
    mkdir('/opt/VNF', owner='openvim', group='openvim', perms=0o775, force=False)
    symlink('/var/lib/libvirt/images', '/opt/VNF/images')
    chownr('/opt/VNF', owner='openvim', group='openvim', follow_links=False, chowntopdir=True)
    chownr('/var/lib/libvirt/images', owner='root', group='openvim', follow_links=False, chowntopdir=True)
    chmod('/var/lib/libvirt/images', 0o775)
コード例 #2
0
def setup_images_folder():
    status_set("maintenance", "Setting up VM images folder")
    mkdir('/opt/VNF', owner='openvim', group='openvim', perms=0o775, force=False)
    symlink('/var/lib/libvirt/images', '/opt/VNF/images')
    chownr('/opt/VNF', owner='openvim', group='openvim', follow_links=False, chowntopdir=True)
    chownr('/var/lib/libvirt/images', owner='root', group='openvim', follow_links=False, chowntopdir=True)
    chmod('/var/lib/libvirt/images', 0o775)
コード例 #3
0
ファイル: ceph_rgw.py プロジェクト: jardon/charm-ceph-radosgw
def import_radosgw_key(key, name=None):
    if name:
        keyring_path = os.path.join(CEPH_RADOSGW_DIR, 'ceph-{}'.format(name),
                                    'keyring')
        link_path = os.path.join(CEPH_DIR,
                                 'ceph.client.{}.keyring'.format(name))
        owner = group = 'ceph'
    else:
        keyring_path = os.path.join(CEPH_DIR, _radosgw_keyring)
        link_path = None
        owner = group = 'root'

    if not os.path.exists(keyring_path):
        mkdir(path=os.path.dirname(keyring_path),
              owner=owner,
              group=group,
              perms=0o750)
        cmd = [
            'ceph-authtool', keyring_path, '--create-keyring',
            '--name=client.{}'.format(name or 'radosgw.gateway'),
            '--add-key={}'.format(key)
        ]
        subprocess.check_call(cmd)
        cmd = ['chown', '{}:{}'.format(owner, group), keyring_path]
        subprocess.check_call(cmd)
        # NOTE: add a link to the keyring in /var/lib/ceph
        # to /etc/ceph so we can use it for radosgw-admin
        # operations for multi-site configuration
        if link_path:
            symlink(keyring_path, link_path)
        return True

    return False
コード例 #4
0
    def test_creates_a_symlink(self, log, check_call):
        source = '/from/this/path/foo'
        destination = '/to/this/path/bar'

        host.symlink(source, destination)

        check_call.assert_called_with(
            ['ln', '-sf', '/from/this/path/foo', '/to/this/path/bar'])
コード例 #5
0
def add_users():
    """
    Adding passwordless sudo access to nova user and adding to required groups
    """
    usr = config('tvault-datamover-ext-usr')
    source = '/usr/lib'
    destination = '/usr/lib64'
    try:
        # Adding nova user to system groups
        add_user_to_group(usr, 'kvm')
        add_user_to_group(usr, 'disk')

        # create symlink /usr/lib64/
        symlink(source, destination)
    except Exception as e:
        log("Failed while adding user with msg: {}".format(e))
        return False

    return True
コード例 #6
0
def import_radosgw_key(key, name=None):
    if name:
        keyring_path = os.path.join(CEPH_RADOSGW_DIR,
                                    'ceph-{}'.format(name),
                                    'keyring')
        link_path = os.path.join(CEPH_DIR,
                                 'ceph.client.{}.keyring'.format(name))
        owner = group = 'ceph'
    else:
        keyring_path = os.path.join(CEPH_DIR, _radosgw_keyring)
        link_path = None
        owner = group = 'root'

    if not os.path.exists(keyring_path):
        mkdir(path=os.path.dirname(keyring_path),
              owner=owner, group=group, perms=0o750)
        cmd = [
            'ceph-authtool',
            keyring_path,
            '--create-keyring',
            '--name=client.{}'.format(
                name or 'radosgw.gateway'
            ),
            '--add-key={}'.format(key)
        ]
        subprocess.check_call(cmd)
        cmd = [
            'chown',
            '{}:{}'.format(owner, group),
            keyring_path
        ]
        subprocess.check_call(cmd)
        # NOTE: add a link to the keyring in /var/lib/ceph
        # to /etc/ceph so we can use it for radosgw-admin
        # operations for multi-site configuration
        if link_path:
            symlink(keyring_path, link_path)
        return True

    return False
コード例 #7
0
def add_users():
    """
    Adding passwordless sudo access to nova user and adding to required groups
    """
    usr = config('tvault-datamover-ext-usr')
    path = '/etc/sudoers.d/tvault-nova'
    source = '/usr/lib'
    destination = '/usr/lib64'
    content = '{} ALL=(ALL) NOPASSWD: ALL'.format(usr)
    try:
        write_file(path, content, owner='root', group='root', perms=501)

        # Adding nova user to system groups
        add_user_to_group(usr, 'kvm')
        add_user_to_group(usr, 'disk')

        # create symlink /usr/lib64/
        symlink(source, destination)
    except Exception as e:
        log("Failed while adding user with msg: {}".format(e))
        return False

    return True
コード例 #8
0
def add_openvim_to_path():
    status_set("maintenance", "adding openvim to path")
    symlink(
        '/opt/openmano/scripts/service-openmano.sh',
        '/usr/bin/service-openmano')
    symlink('/opt/openmano/openvim/openvim', '/usr/bin/openvim')
コード例 #9
0
def create_virt_env():
    """
    Checks if latest version is installed or else imports the new virtual env
    And installs the Datamover package.
    """
    usr = DM_EXT_USR
    grp = DM_EXT_GRP
    path = TVAULT_HOME
    venv_path = TVAULT_VIRTENV_PATH
    tv_ip = config('triliovault-ip')
    dm_ver = None
    # create virtenv dir(/home/tvault) if it does not exist
    mkdir(path, owner=usr, group=grp, perms=501, force=True)

    latest_dm_ver = get_new_version('tvault-contego')
    if dm_ver == latest_dm_ver:
        log("Latest TrilioVault DataMover package is already installed,"
            " exiting")
        return True

    # Create virtual environment for DataMover
    handler = archiveurl.ArchiveUrlFetchHandler()
    try:
        # remove old venv if it exists
        shutil.rmtree(venv_path)
        venv_src = 'http://{}:8081/packages/queens_ubuntu'\
                   '/tvault-contego-virtenv.tar.gz'.format(tv_ip)
        venv_dest = path
        handler.install(venv_src, venv_dest)
        log("Virtual Environment installed successfully")
    except Exception as e:
        log("Failed to install Virtual Environment")
        status_set('blocked', 'Failed while Creating Virtual Env')
        return False

    # Get dependent libraries paths
    try:
        cmd = ['/usr/bin/python', 'files/trilio/get_pkgs.py']
        sym_link_paths = \
            subprocess.check_output(cmd).decode('utf-8').strip().split('\n')
    except Exception as e:
        log("Failed to get the dependent packages--{}".format(e))
        return False

    # Install TrilioVault Datamover package
    if not install_plugin(tv_ip, latest_dm_ver, '/usr'):
        return False

    # Create symlinks of the dependent libraries
    venv_pkg_path = '{}/lib/python2.7/site-packages/'.format(venv_path)
    shutil.rmtree('{}/cryptography'.format(venv_pkg_path))
    shutil.rmtree('{}/cffi'.format(venv_pkg_path))

    symlink(sym_link_paths[0], '{}/cryptography'.format(venv_pkg_path))
    symlink(sym_link_paths[2], '{}/cffi'.format(venv_pkg_path))

    shutil.copy(sym_link_paths[1], '{}/libvirtmod.so'.format(venv_pkg_path))
    shutil.copy(sym_link_paths[3], '{}/_cffi_backend.so'.format(venv_pkg_path))

    # change virtenv dir(/home/tvault) users to nova
    chownr(path, usr, grp)

    # Copy Trilio sudoers and filters files
    shutil.copy('files/trilio/trilio_sudoers', '/etc/sudoers.d/')
    shutil.copy('files/trilio/trilio.filters', '/etc/nova/rootwrap.d/')

    return True
コード例 #10
0
ファイル: openvim.py プロジェクト: AdamIsrael/openvim
def setup_qemu_binary():
    status_set("maintenance", "Setting up qemu-kvm binary")
    mkdir('/usr/libexec', owner='root', group='root', perms=0o775, force=False)
    symlink('/usr/bin/kvm', '/usr/libexec/qemu-kvm')
コード例 #11
0
def setup_qemu_binary():
    status_set("maintenance", "setting up qemu-kvm binary")
    mkdir('/usr/libexec', owner='root', group='root', perms=0o775, force=False)
    symlink('/usr/bin/kvm', '/usr/libexec/qemu-kvm')
コード例 #12
0
def create_virt_env():
    """
    Checks if latest version is installed or else imports the new virtual env
    And installs the Datamover package.
    """
    usr = config('tvault-datamover-ext-usr')
    grp = config('tvault-datamover-ext-group')
    path = config('tvault-datamover-virtenv')
    venv_path = config('tvault-datamover-virtenv-path')
    tv_ip = config('triliovault-ip')
    dm_ver = None
    # create virtenv dir(/home/tvault) if it does not exist
    mkdir(path, owner=usr, group=grp, perms=501, force=True)

    latest_dm_ver = get_new_version('tvault-contego')
    if dm_ver == latest_dm_ver:
        log("Latest TrilioVault DataMover package is already installed,"
            " exiting")
        return True

    # Create virtual environment for DataMover
    handler = ArchiveUrlFetchHandler()
    try:
        # remove old venv if it exists
        os.system('rm -rf {}'.format(venv_path))
        venv_src = 'http://{}:8081/packages/queens_ubuntu'\
                   '/tvault-contego-virtenv.tar.gz'.format(tv_ip)
        venv_dest = path
        handler.install(venv_src, venv_dest)
        log("Virtual Environment installed successfully")
    except Exception as e:
        log("Failed to install Virtual Environment")
        return False

    # Get dependent libraries paths
    try:
        cmd = ['/usr/bin/python', 'files/trilio/get_pkgs.py']
        sym_link_paths = check_output(cmd).decode('utf-8').strip().split('\n')
    except Exception as e:
        log("Failed to get the dependent packages--{}".format(e))
        return False

    # Install TrilioVault Datamover package
    if not install_plugin(tv_ip, latest_dm_ver, '/usr'):
        return False

    # Create symlinks of the dependent libraries
    venv_pkg_path = '{}/lib/python2.7/site-packages/'.format(venv_path)
    os.system('rm -rf {}/cryptography'.format(venv_pkg_path))
    os.system('rm -rf {}/cffi'.format(venv_pkg_path))

    symlink(sym_link_paths[0], '{}/cryptography'.format(venv_pkg_path))
    symlink(sym_link_paths[2], '{}/cffi'.format(venv_pkg_path))

    os.system(
        'cp {} {}/libvirtmod.so'.format(sym_link_paths[1], venv_pkg_path))
    os.system(
        'cp {} {}/_cffi_backend.so'.format(sym_link_paths[3], venv_pkg_path))

    # change virtenv dir(/home/tvault) users to nova
    chownr(path, usr, grp)

    return True