Esempio n. 1
0
def install_puppet_agent():

    """ Install puppet-agent
    """

    # Download and install trusty puppet deb
    hookenv.status_set('maintenance', 
                       'Configuring trusty puppet apt sources')

    aufh = ArchiveUrlFetchHandler()
    aufh.download(TRUSTY_PUPPET_DEB_URL, TRUSTY_PUPPET_DEB_TEMP)
    dpkg_trusty_puppet_deb = 'dpkg -i %s' % TRUSTY_PUPPET_DEB_TEMP
    call(dpkg_trusty_puppet_deb.split(), shell=False)
    apt_update()
    #Clean up
    rm_trusty_puppet_deb = 'rm %s' % TRUSTY_PUPPET_DEB_TEMP
    call(rm_trusty_puppet_deb.split(), shell=False)

    # Install puppet-agent
    hookenv.status_set('maintenance', 
                       'Installing puppet-agent %s' % PUPPET_VERSION)

    apt_install(PUPPET_AGENT_PKGS)
    render_puppet_conf(PUPPET_CONF_CTXT)
    hookenv.status_set('active', 'Puppet-agent: %s installed.' % PUPPET_VERSION)
Esempio n. 2
0
def install_layer_opentsdb():
    status_set('maintenance', 'Installing OpenTSDB...')
    fetcher = ArchiveUrlFetchHandler()
    fetcher.download(
        'https://github.com/OpenTSDB/opentsdb/releases/download/v2.3.0/opentsdb-2.3.0_all.deb',
        '/opt/opentsdb-2.3.0_all.deb')
    subprocess.check_call(['dpkg', '-i', '/opt/opentsdb-2.3.0_all.deb'])
    set_state('layer-opentsdb.installed')
Esempio n. 3
0
def download_default_image():
    status_set("maintenance", "Downloading default image")
    fetcher = ArchiveUrlFetchHandler()
    fetcher.download(
        source="https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img",
        dest="/opt/VNF/images/ubuntu-16.04-server-cloudimg-amd64-disk1.img"
        # TODO: add checksum
    )
def download_default_image():
    status_set("maintenance", "Downloading default image")
    fetcher = ArchiveUrlFetchHandler()
    fetcher.download(
        source="https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img",
        dest="/opt/VNF/images/ubuntu-16.04-server-cloudimg-amd64-disk1.img"
        # TODO: add checksum
    )
    def fetch_install_puppet_deb(self, puppet):
        '''Fetch and install the puppet deb
        '''
        hookenv.status_set('maintenance',
                           'Configuring Puppetlabs apt sources')
        aufh = ArchiveUrlFetchHandler()
        aufh.download(self.puppet_deb_url(), self.puppet_deb_temp())
        dpkg_puppet_deb = 'dpkg -i %s' % self.puppet_deb_temp()
        call(dpkg_puppet_deb.split(), shell=False)
        apt_update()

        # Clean up
        rm_trusty_puppet_deb = 'rm %s' % self.puppet_deb_temp()
        call(rm_trusty_puppet_deb.split(), shell=False)
        self.puppet_active()
Esempio n. 6
0
def download_tomcat():
    '''Downloads Tomcat from Apache archive and extracts the tarball.'''
    status_set('maintenance', 'Downloading Tomcat...')

    if not os.path.isfile('/opt/apache-tomcat-9.0.1.tar.gz'):
        fetcher = ArchiveUrlFetchHandler()
        fetcher.download(
            'https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.1/bin/apache-tomcat-9.0.1.tar.gz',
            '/opt/apache-tomcat-9.0.1.tar.gz')

    if not os.path.isdir(TOMCAT_DIR):
        subprocess.check_call(
            ['tar', 'xvzf', '/opt/apache-tomcat-9.0.1.tar.gz', '-C', '/opt'])

    set_state('layer-tomcat.downloaded')
Esempio n. 7
0
 def download_platform(self):
     hookenv.status_set('maintenance', 'Downloading platform')
     url = self.get_platform_package_url()
     package = self.get_platform_package_name()
     log("Platform package url: " + url, INFO)
     aufh = ArchiveUrlFetchHandler()
     dest_file = "/tmp/" + package
     aufh.download(url, dest_file)
     fetch.apt_update()
     checksum = self.config['package-checksum']
     if checksum:
         hash_type = self.config['hash-type']
         if not hash_type:
             hash_type = 'md5'
         host.check_hash(dest_file, checksum, hash_type)
     return dest_file
Esempio n. 8
0
def install_layer_telegraf():
    """Installs the Telegraf software if it is not already installed."""
    if is_telegraf_installed():
        increment_number_telegrafs()
    else:
        status_set('maintenance', 'Installing Telegraf...')
        fetcher = ArchiveUrlFetchHandler()
        if not os.path.isdir('/opt/telegraf'):
            mkdir('/opt/telegraf')
        fetcher.download('https://dl.influxdata.com/telegraf/releases/telegraf_1.4.5-1_amd64.deb',
                         '/opt/telegraf/telegraf_1.4.5-1_amd64.deb')
        subprocess.check_call(['dpkg', '--force-confdef', '-i',
                               '/opt/telegraf/telegraf_1.4.5-1_amd64.deb'])
        shutil.copyfile('files/plugins.json', '/opt/telegraf/plugins.json')
        shutil.copyfile('files/telegraf.json', '/opt/telegraf/telegraf.json')
        increment_number_telegrafs()

    set_flag('layer-telegraf.installed')
    def download_plugin(self, plugin_name):
        hookenv.status_set('maintenance', 'Downloading plugin ' + plugin_name)
        url = self.get_plugin_package_url(plugin_name)
        package = self.get_plugin_package_name(plugin_name)
        log("Plugin package url: " + url, INFO)
        aufh =  ArchiveUrlFetchHandler()
        dest_file = "/tmp/" + package
        aufh.download(url, dest_file)
        fetch.apt_update()

        hash_key = plugin_name + '-hash' 
        checksum = ''
        if hash_key in self.config.keys(): 
           checksum = self.config[hash_key]
        if checksum:
            hash_type = self.config['hash-type']
            if not hash_type:
                hash_type = 'md5'
            host.check_hash(dest_file, checksum, hash_type)
        return dest_file