# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import logging import sys from aws_utils import EBSHelper, AMIHelper if len(sys.argv) != 5: print print "Create an AMI on EC2 from a bootable image file" print print "usage: %s <ec2_region> <ec2_key> <ec2_secret> <image_file>" % sys.argv[0] print sys.exit(1) region = sys.argv[1] key = sys.argv[2] secret = sys.argv[3] image_file = sys.argv[4] logging.basicConfig(level=logging.DEBUG, format='%(message)s') ebs_helper = EBSHelper(region, key, secret) snapshot = ebs_helper.safe_upload_and_shutdown(image_file) ami_helper = AMIHelper(region, key, secret) ami = ami_helper.register_ebs_ami(snapshot) print "Got AMI: %s" % ami
# limitations under the License. import logging import sys from aws_utils import EBSHelper, AMIHelper from pvgrub_utils import do_pw_sub if len(sys.argv) != 7: print print "Create an AMI on EC2 by running a native installer contained in a pre-existing AMI" print print "usage: %s <ec2_region> <ec2_key> <ec2_secret> <install_ami> <install_script> <root_pw>" % sys.argv[0] print sys.exit(1) region = sys.argv[1] key = sys.argv[2] secret = sys.argv[3] install_ami = sys.argv[4] install_script = sys.argv[5] root_pw = sys.argv[6] logging.basicConfig(level=logging.DEBUG, format='%(message)s') ami_helper = AMIHelper(region, key, secret) user_data = do_pw_sub(install_script, root_pw) install_ami = ami_helper.launch_wait_snapshot(install_ami, user_data, 10) print "Got AMI: %s" % install_ami
results[test.name] = testresult result_lock.release() def review_results(): fails = 0 for test, result in results.items(): log.info(result) if result['status'] == 'error': fails += 1 sys.exit(fails) if __name__ == '__main__': opts = get_opts() image = disk_utils.construct_image(opts.anaconda_tree, opts.parameters) ebs_helper = EBSHelper(opts.ec2_region) ami_helper = AMIHelper(opts.ec2_region) snapshot = ebs_helper.safe_upload_and_shutdown(image) # upload it seed_ami = ami_helper.register_ebs_ami(snapshot) # "stage 1" AMI threads = [] tests = anaconda_test.get_test(opts.test_case) # 'all' means get all of them for test in tests: threads.append(threading.Thread( target=run_test, args=(ami_helper, seed_ami, test), name=test.name)) for t in threads: t.start() for t in threads: t.join() review_results(results)
def get_opts(): usage=""" %prog <install_ami> <kickstart> Create an AMI on EC2 by running a native installer contained in a pre-existing AMI.""" parser = OptionParser(usage=usage) parser.add_option('-i', '--instance-type', default='m1.small', help='Choose an instance type to install in', dest='inst_type') parser.add_option('-r', '--region', default='us-east-1', help='Set the EC2 region we are working in') parser.add_option('-s', '--disk-size', default=10, type='int', help='Set the size in G of the disk Anaconda will install to') options, args = parser.parse_args() if len(args) != 2: parser.error('You must provide an AMI and a kickstart file') if not os.path.exists(args[1]): parser.error('could not read %s!' % args[1]) return options, args[0], args[1] logging.basicConfig(level=logging.DEBUG, format='%(message)s') if __name__ == '__main__': opts, install_ami, kickstart = get_opts() ami_helper = AMIHelper(opts.region) user_data = open(kickstart).read() install_ami = ami_helper.launch_wait_snapshot( install_ami, user_data, int(opts.disk_size), opts.inst_type) print "Got AMI: %s" % install_ami