示例#1
0
#                    from boto.ec2.connection import EC2Connection
#                    from boto.ec2.regioninfo import RegionInfo

#                    rinfo = None
#                    if self.vm.ec2_is_eucalyptus: #default boto regioninfo assumes Amazon EC2
#                        rinfo = RegionInfo(None, "eucalyptus", self.vm.ec2_url)

#                    #Code added to support Eucalyptus and other EC2-compatible clusters
#                    if self.vm.ec2_url:
#                        import urlparse
#                        parsed_url = urlparse.urlparse(self.vm.ec2_url)
#                        is_secure = False

#                        if parsed_url.scheme == 'https':
#                            is_secure = True

#                        conn = EC2Connection(self.vm.ec2_access_key, self.vm.ec2_secret_key,
#                            host = parsed_url.hostname, port = parsed_url.port, path = parsed_url.path, is_secure = is_secure, region = rinfo)
#                    else:
#                        conn = EC2Connection(self.vm.ec2_access_key, self.vm.ec2_secret_key, region = rinfo)

#                    image_id = conn.register_image('%s/%s.manifest.xml' % (self.vm.ec2_bucket, self.vm.ec2_name))
            else:
                self.vm.result_files.append(manifest)
        else:
            self.vm.result_files.append(self.vm.filesystems[0].filename)

        return True

register_plugin(EC2)
示例#2
0
	    if not(os.access(self.vm.firstboot, os.X_OK)):
	        raise MBuilderUserError("The first-boot script is not executable")

            if not(os.path.isfile(self.vm.firstboot)):
                raise VMBuilderUserError('The path to the first-boot script is invalid: %s. Make sure you are providing a full path.' % self.vm.firstboot)
                
        if self.vm.firstlogin:
            logging.debug("Checking if first login script %s exists" % (self.vm.firstlogin,))
            if not(os.access(self.vm.firstlogin, os.X_OK)):
                raise VMBuilderUserError("The first-login script is not executable")

            if not(os.path.isfile(self.vm.firstlogin)):
                raise VMBuilderUserError('The path to the first-login script is invalid: %s.  Make sure you are providing a full path.' % self.vm.firstlogin)

    def post_install(self):
        logging.debug("Installing firstboot script %s" % (self.vm.firstboot,))
        if self.vm.firstboot:
            self.vm.install_file('/root/firstboot.sh', source=self.vm.firstboot, mode=0700)
            os.rename('%s/etc/rc.local' % self.vm.installdir, '%s/etc/rc.local.orig' % self.vm.installdir)
            self.install_from_template('/etc/rc.local', 'firstbootrc', mode=0755)

        logging.debug("Installing first login script %s" % (self.vm.firstlogin,))
        if self.vm.firstlogin:
            self.vm.install_file('/root/firstlogin.sh', source=self.vm.firstlogin, mode=0755)
            os.rename('%s/etc/bash.bashrc' % self.vm.installdir, '%s/etc/bash.bashrc.orig' % self.vm.installdir)
            self.install_from_template('/etc/bash.bashrc', 'firstloginrc')

        return True

register_plugin(Firstscripts)
示例#3
0
                'The libvirt plugin is only equiped to work with KVM at the moment.'
            )

        if not self.vm.hypervisor.name == 'KVM':
            raise VMBuilderUserError(
                'The libvirt plugin is only equiped to work with KVM at the moment.'
            )

    def deploy(self):
        if not self.vm.libvirt:
            # Not for us
            return False

        if self.vm.hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:
            vmxml = VMBuilder.util.render_template('libvirt', self.vm,
                                                   'libvirtxml_fsimage')
        else:
            vmxml = VMBuilder.util.render_template('libvirt', self.vm,
                                                   'libvirtxml')

        if self.vm.hostname in self.all_domains() and not self.vm.overwrite:
            raise VMBuilderUserError('Domain %s already exists at %s' %
                                     (self.vm.hostname, self.vm.libvirt))
        else:
            self.conn.defineXML(vmxml)

        return True


register_plugin(Libvirt)
示例#4
0
#                    from boto.ec2.connection import EC2Connection
#                    from boto.ec2.regioninfo import RegionInfo

#                    rinfo = None
#                    if self.vm.ec2_is_eucalyptus: #default boto regioninfo assumes Amazon EC2
#                        rinfo = RegionInfo(None, "eucalyptus", self.vm.ec2_url)

#                    #Code added to support Eucalyptus and other EC2-compatible clusters
#                    if self.vm.ec2_url:
#                        import urlparse
#                        parsed_url = urlparse.urlparse(self.vm.ec2_url)
#                        is_secure = False

#                        if parsed_url.scheme == 'https':
#                            is_secure = True

#                        conn = EC2Connection(self.vm.ec2_access_key, self.vm.ec2_secret_key,
#                            host = parsed_url.hostname, port = parsed_url.port, path = parsed_url.path, is_secure = is_secure, region = rinfo)
#                    else:
#                        conn = EC2Connection(self.vm.ec2_access_key, self.vm.ec2_secret_key, region = rinfo)

#                    image_id = conn.register_image('%s/%s.manifest.xml' % (self.vm.ec2_bucket, self.vm.ec2_name))
            else:
                self.vm.result_files.append(manifest)
        else:
            self.vm.result_files.append(self.vm.filesystems[0].filename)

        return True

register_plugin(EC2)
示例#5
0
        import libvirt

        self.conn = libvirt.open(self.vm.libvirt)
        if self.vm.hostname in self.all_domains() and not self.vm.overwrite:
            raise VMBuilderUserError('Domain %s already exists at %s' % (self.vm.hostname, self.vm.libvirt))
        
        if not self.vm.hypervisor.name == 'KVM':
            raise VMBuilderUserError('The libvirt plugin is only equiped to work with KVM at the moment.')

        if not self.vm.hypervisor.name == 'KVM':
            raise VMBuilderUserError('The libvirt plugin is only equiped to work with KVM at the moment.')

    def deploy(self):
        if not self.vm.libvirt:
            # Not for us
            return False
        
        if self.vm.hypervisor.preferred_storage == VMBuilder.hypervisor.STORAGE_FS_IMAGE:
            vmxml = VMBuilder.util.render_template('libvirt', self.vm, 'libvirtxml_fsimage')
        else:
            vmxml = VMBuilder.util.render_template('libvirt', self.vm, 'libvirtxml')

        if self.vm.hostname in self.all_domains() and not self.vm.overwrite:
            raise VMBuilderUserError('Domain %s already exists at %s' % (self.vm.hostname, self.vm.libvirt))
        else:
            self.conn.defineXML(vmxml)

        return True

register_plugin(Libvirt)
示例#6
0
                          self.vm.execscript)
            if not os.access(self.vm.execscript, os.X_OK | os.R_OK):
                raise VMBuilderUserError(
                    'The path to the --execscript file has invalid permissions: %s. Make sure the path is readable and executable.'
                    % self.vm.execscript)

    def post_install(self):
        if self.vm.copy:
            logging.info("Copying files specified by --copy in: %s" %
                         self.vm.copy)
            try:
                for line in file(self.vm.copy):
                    pair = line.strip().split(' ')
                    if len(pair) < 2:  # skip blank and incomplete lines
                        continue
                    util.run_cmd('cp', '-LpR', pair[0],
                                 '%s%s' % (self.vm.installdir, pair[1]))

            except IOError, (errno, strerror):
                raise VMBuilderUserError("%s executing --copy directives: %s" %
                                         (errno, strerror))

        if self.vm.execscript:
            logging.info("Executing script: %s" % self.vm.execscript)
            util.run_cmd(self.vm.execscript, self.vm.installdir)

        return True


register_plugin(postinst)
示例#7
0
    def preflight_check(self):
        if self.vm.copy:
            logging.debug("Checking if --copy PATH exists: %s" % self.vm.copy)
            if not(os.path.isfile(self.vm.copy)):
                raise VMBuilderUserError('The path to the --copy directives is invalid: %s. Make sure you are providing a full path.' % self.vm.copy)
                
        if self.vm.execscript:
            logging.debug("Checking if --exec PATH exists: %s" % self.vm.execscript)
            if not(os.path.isfile(self.vm.execscript)):
                raise VMBuilderUserError('The path to the --execscript file is invalid: %s. Make sure you are providing a full path.' % self.vm.execscript) 

    def post_install(self):
        if self.vm.copy:
            logging.info("Copying files specified by --copy in: %s" % self.vm.copy)
            try:
                for line in file(self.vm.copy):
                    pair = line.strip().split(' ')
                    util.run_cmd('cp', '-LpR', pair[0], '%s%s' % (self.vm.installdir, pair[1]))

            except IOError, (errno, strerror):
                raise VMBuilderUserError("%s executing --copy directives: %s" % (errno, strerror))

        if self.vm.execscript:
            logging.info("Executing script: %s" % self.vm.execscript)
            util.run_cmd(self.vm.execscript, self.vm.installdir)

        return True

register_plugin(postinst)