Beispiel #1
0
def main():
    db = vmdatabase.VMDatabase()
    provider = db.getProvider(PROVIDER_NAME)
    print "Working with provider %s" % provider.name
    client = utils.get_client(provider)

    for base_image in provider.base_images:
        if base_image.min_ready <= 0:
            continue
        print "Working on base image %s" % base_image.name

        flavor = utils.get_flavor(client, base_image.min_ram)
        print "Found flavor", flavor

        branches = local_prep(base_image.name)

        remote_base_image = client.images.find(name=base_image.external_id)
        timestamp = int(time.time())
        remote_snap_image_name = (
            '%sdevstack-%s-%s.template.openstack.org' %
            (DEVSTACK_GATE_PREFIX, base_image.name, str(timestamp)))
        remote_snap_image = build_image(provider, client, base_image,
                                        remote_base_image, flavor,
                                        remote_snap_image_name, branches,
                                        timestamp)
def main():
    if "-n" in sys.argv:
        dry = True
    else:
        dry = False

    db = vmdatabase.VMDatabase()
    provider = db.getProvider(PROVIDER_NAME)
    print "Working with provider %s" % provider.name
    client = utils.get_client(provider)

    for base_image in provider.base_images:
        if base_image.min_ready < 0:
            continue
        print "Working on base image %s" % base_image.name

        flavor = utils.get_flavor(client, base_image.min_ram)
        print "Found flavor", flavor

        branches = local_prep(base_image.name)
        pprint.pprint(branches)

        remote_base_image = client.images.find(name=base_image.external_id)
        if not dry:
            timestamp = int(time.time())
            remote_snap_image_name = "%sdevstack-%s-%s.template.openstack.org" % (
                DEVSTACK_GATE_PREFIX,
                base_image.name,
                str(timestamp),
            )
            build_image(
                provider, client, base_image, remote_base_image, flavor, remote_snap_image_name, branches, timestamp
            )
def main():
    db = vmdatabase.VMDatabase()

    if not SKIP_DEVSTACK_GATE_JENKINS:
        config = ConfigParser.ConfigParser()
        config.read(DEVSTACK_GATE_SECURE_CONFIG)

        jenkins = myjenkins.Jenkins(config.get('jenkins', 'server'),
                                    config.get('jenkins', 'user'),
                                    config.get('jenkins', 'apikey'))
        jenkins.get_info()
    else:
        jenkins = None

    print 'Known machines (start):'
    db.print_state()

    provider = db.getProvider(PROVIDER_NAME)
    print "Working with provider %s" % provider.name

    client = utils.get_client(provider)

    flavor = utils.get_flavor(client, 1024)
    print "Found flavor", flavor

    error = False
    now = time.time()
    for machine in provider.machines:
        # Normally, reap machines that have sat in their current state
        # for 24 hours, unless that state is READY.
        if (REAP_ALL_SERVERS or
            (machine.state != vmdatabase.READY and
             now - machine.state_time > MACHINE_LIFETIME) or
            machine.state == vmdatabase.DELETE):
            print 'Deleting machine', machine.name
            try:
                delete_machine(jenkins, client, machine)
            except:
                error = True
                traceback.print_exc()

    provider_min_ready = 0
    for base_image in provider.base_images:
        provider_min_ready += base_image.min_ready
        for snap_image in base_image.snapshot_images:
            # Normally, reap images that have sat in their current state
            # for 24 hours, unless the image is the current snapshot
            if (REAP_ALL_IMAGES or
                (snap_image != base_image.current_snapshot and
                now - snap_image.state_time > MACHINE_LIFETIME)):
                print 'Deleting image', snap_image.name
                try:
                    delete_image(client, snap_image)
                except:
                    error = True
                    traceback.print_exc()

    # Make sure the provider has enough headroom for the min_ready
    # of all base images, deleting used serverss if needed.
    overcommitment = ((len(provider.machines) -
                       len(provider.ready_machines) + provider_min_ready) -
                      provider.max_servers)

    while overcommitment > 0:
        print 'Overcommitted by %s machines' % overcommitment
        last_overcommitment = overcommitment
        for machine in provider.machines:
            if machine.state == vmdatabase.READY:
                continue
            if machine.state == vmdatabase.BUILDING:
                continue
            if machine.state == vmdatabase.HOLD:
                continue
            print 'Deleting machine', machine.name
            try:
                delete_machine(jenkins, client, machine)
                overcommitment -= 1
            except:
                error = True
                traceback.print_exc()
        if overcommitment == last_overcommitment:
            raise Exception("Unable to reduce overcommitment")
        last_overcommitment = overcommitment

    print
    print 'Known machines (end):'
    db.print_state()

    if error:
        sys.exit(1)
def main():
    db = vmdatabase.VMDatabase()

    if not SKIP_DEVSTACK_GATE_JENKINS:
        config = ConfigParser.ConfigParser()
        config.read(DEVSTACK_GATE_SECURE_CONFIG)

        jenkins = myjenkins.Jenkins(config.get('jenkins', 'server'),
                                    config.get('jenkins', 'user'),
                                    config.get('jenkins', 'apikey'))
        jenkins.get_info()
    else:
        jenkins = None

    print 'Known machines (start):'
    db.print_state()

    provider = db.getProvider(PROVIDER_NAME)
    print "Working with provider %s" % provider.name

    client = utils.get_client(provider)

    flavor = utils.get_flavor(client, 1024)
    print "Found flavor", flavor

    error = False
    now = time.time()
    for machine in provider.machines:
        # Normally, reap machines that have sat in their current state
        # for 24 hours, unless that state is READY.
        if (REAP_ALL_SERVERS or
            (machine.state != vmdatabase.READY and
             now - machine.state_time > MACHINE_LIFETIME) or
            machine.state == vmdatabase.DELETE or
            machine.state == vmdatabase.ERROR):
            print 'Deleting machine', machine.name
            try:
                delete_machine(jenkins, client, machine)
            except:
                error = True
                traceback.print_exc()

    provider_min_ready = 0
    for base_image in provider.base_images:
        provider_min_ready += base_image.min_ready
        for snap_image in base_image.snapshot_images:
            # Normally, reap images that have sat in their current state
            # for 24 hours, unless the image is the current snapshot
            if (REAP_ALL_IMAGES or
                (snap_image != base_image.current_snapshot and
                now - snap_image.state_time > MACHINE_LIFETIME)):
                print 'Deleting image', snap_image.name
                try:
                    delete_image(client, snap_image)
                except:
                    error = True
                    traceback.print_exc()

    print
    print 'Known machines (end):'
    db.print_state()

    utils.update_stats(provider)
    if error:
        sys.exit(1)
Beispiel #5
0
def main():
    db = vmdatabase.VMDatabase()

    if not SKIP_DEVSTACK_GATE_JENKINS:
        config = ConfigParser.ConfigParser()
        config.read(DEVSTACK_GATE_SECURE_CONFIG)

        jenkins = myjenkins.Jenkins(config.get('jenkins', 'server'),
                                    config.get('jenkins', 'user'),
                                    config.get('jenkins', 'apikey'))
        jenkins.get_info()
    else:
        jenkins = None

    print 'Known machines (start):'
    db.print_state()

    provider = db.getProvider(PROVIDER_NAME)
    print "Working with provider %s" % provider.name

    client = utils.get_client(provider)

    flavor = utils.get_flavor(client, 1024)
    print "Found flavor", flavor

    error = False
    now = time.time()
    for machine in provider.machines:
        # Normally, reap machines that have sat in their current state
        # for 24 hours, unless that state is READY.
        if (REAP_ALL_SERVERS
                or (machine.state != vmdatabase.READY
                    and now - machine.state_time > MACHINE_LIFETIME)
                or machine.state == vmdatabase.DELETE):
            print 'Deleting machine', machine.name
            try:
                delete_machine(jenkins, client, machine)
            except:
                error = True
                traceback.print_exc()

    provider_min_ready = 0
    for base_image in provider.base_images:
        provider_min_ready += base_image.min_ready
        for snap_image in base_image.snapshot_images:
            # Normally, reap images that have sat in their current state
            # for 24 hours, unless the image is the current snapshot
            if (REAP_ALL_IMAGES
                    or (snap_image != base_image.current_snapshot
                        and now - snap_image.state_time > MACHINE_LIFETIME)):
                print 'Deleting image', snap_image.name
                try:
                    delete_image(client, snap_image)
                except:
                    error = True
                    traceback.print_exc()

    # Make sure the provider has enough headroom for the min_ready
    # of all base images, deleting used serverss if needed.
    overcommitment = ((len(provider.machines) - len(provider.ready_machines) +
                       provider_min_ready) - provider.max_servers)

    while overcommitment > 0:
        print 'Overcommitted by %s machines' % overcommitment
        last_overcommitment = overcommitment
        for machine in provider.machines:
            if machine.state == vmdatabase.READY:
                continue
            if machine.state == vmdatabase.BUILDING:
                continue
            if machine.state == vmdatabase.HOLD:
                continue
            print 'Deleting machine', machine.name
            try:
                delete_machine(jenkins, client, machine)
                overcommitment -= 1
            except:
                error = True
                traceback.print_exc()
        if overcommitment == last_overcommitment:
            raise Exception("Unable to reduce overcommitment")
        last_overcommitment = overcommitment

    print
    print 'Known machines (end):'
    db.print_state()

    if error:
        sys.exit(1)
    def __init__ (self, debug_level=0, args=[], optlist=[]) :
        ChallengeBase.__init__(self, debug_level)

        self.message ="""
    usage: %s [-h] [-v] [-d] [ -s ssh-key ] [ -e error-page ] [ -c container-name ] [ -i image-id ] [ -f flavor-id ] -n FQDN-name  

    image-id -f flavor-id
        -h - usage help 
        -v - verbose / debug output 
        -d - delete objects if they existed in cloud before creating new one
        -n - FQDN name like www.myexample.com
        -s - path to your ssh public key (not priv!)
        -e - path to a html file that will be served from the LB when all pool members are down
        -c - name of cloud files container-name to store the backup data
        -i - specify image-id or use the default for Ubuntu 10.04
        -f - specify flavor-id or use the default for the smallest cloud server
    """ % (PROGRAM_NAME)

        self.optlist = optlist
        self.args = args

        self.opt_delete = False

        self.fqdn_name = None
        self.domain_name = None
        self.domain = None
        self.recs = None

        self.ssh_public_key_name = None
        self.ssh_public_key = None

        self.error_page_name = None
        self.error_page_path = None
        self.error_page = None

        self.container_name = None
        self.container = None

        self.image = None
        self.image_id = None

        self.flavor = None
        self.flavor_id = None

        self.server_prefix=None
        self.cs_count=2
        self.servers = []
        
        self.lb=None
        self.lb_name =None
        self.vip=None
        self.vip_address = None
        self.nodes=[]

        for o, val in optlist:
            if o == "-n":
                self.fqdn_name = val
                self.domain_name =  ".".join( self.fqdn_name.split('.')[1:] )
                self.domain=None
                self.recs = None
            elif o == "-s":
                self.ssh_public_key_name = val
            elif o == "-e":
                self.error_page_path = val
            elif o == "-d":
                self.opt_delete = True
            elif o == "-c":
                self.container_name = val
            elif o == "-i":
                self.image_id = val
            elif o == "-f":
                self.flavor_id = val

        if not self.fqdn_name :
            self.usage()
            sys.exit(-1)

        #default values for some variables 

        if not self.container_name :
            self.container_name = self.fqdn_name 

        self.image = None
        if not self.image_id :
            self.image_id = utils.get_image(self.cs)
        
        self.flavor= None
        if not self.flavor_id :
            self.flavor_id = utils.get_flavor(self.cs)

        self.lb_name = self.fqdn_name

        self.server_prefix = self.fqdn_name
def main():
    db = vmdatabase.VMDatabase()

    if not SKIP_DEVSTACK_GATE_JENKINS:
        config = ConfigParser.ConfigParser()
        config.read(DEVSTACK_GATE_SECURE_CONFIG)

        jenkins = myjenkins.Jenkins(config.get('jenkins', 'server'),
                                    config.get('jenkins', 'user'),
                                    config.get('jenkins', 'apikey'))
        jenkins.get_info()
    else:
        jenkins = None

    provider = db.getProvider(PROVIDER_NAME)
    print "Working with provider %s" % provider.name

    client = utils.get_client(provider)

    last_name = ''
    error_counts = {}
    error = False

    for base_image in provider.base_images:
        snap_image = base_image.current_snapshot
        if not snap_image:
            continue
        print "Working on image %s" % snap_image.name

        flavor = utils.get_flavor(client, base_image.min_ram)
        print "Found flavor", flavor

        remote_snap_image = client.images.get(snap_image.external_id)
        print "Found image", remote_snap_image

        num_to_launch = calculate_deficit(provider, base_image)
        for i in range(num_to_launch):
            try:
                server, machine = launch_node(client,
                                              snap_image,
                                              remote_snap_image,
                                              flavor,
                                              last_name)
                last_name = machine.name
            except:
                traceback.print_exc()
                error = True

    while True:
        utils.update_stats(provider)
        building_machines = provider.building_machines
        if not building_machines:
            print "No more machines are building, finished."
            break

        print "Waiting on %s machines" % len(building_machines)
        for machine in building_machines:
            try:
                check_machine(jenkins, client, machine, error_counts)
            except:
                traceback.print_exc()
                print "Abandoning machine %s" % machine.id
                machine.state = vmdatabase.ERROR
                error = True
            db.commit()

        time.sleep(3)

    if error:
        sys.exit(1)
def main():
    db = vmdatabase.VMDatabase()

    jenkins = None
    credentials_id = None
    if not SKIP_DEVSTACK_GATE_JENKINS:
        config = ConfigParser.ConfigParser()
        config.read(DEVSTACK_GATE_SECURE_CONFIG)

        jenkins = myjenkins.Jenkins(config.get('jenkins', 'server'),
                                    config.get('jenkins', 'user'),
                                    config.get('jenkins', 'apikey'))
        jenkins.get_info()
        if config.has_option('jenkins', 'credentials_id'):
            credentials_id = config.get('jenkins', 'credentials_id')

    provider = db.getProvider(PROVIDER_NAME)
    print "Working with provider %s" % provider.name

    client = utils.get_client(provider)

    last_name = ''
    error_counts = {}
    error = False

    for base_image in provider.base_images:
        snap_image = base_image.current_snapshot
        if not snap_image:
            continue
        print "Working on image %s" % snap_image.name

        flavor = utils.get_flavor(client, base_image.min_ram)
        print "Found flavor", flavor

        remote_snap_image = client.images.get(snap_image.external_id)
        print "Found image", remote_snap_image

        num_to_launch = calculate_deficit(provider, base_image)
        for i in range(num_to_launch):
            try:
                server, machine = launch_node(client, snap_image,
                                              remote_snap_image, flavor,
                                              last_name)
                last_name = machine.name
            except:
                traceback.print_exc()
                error = True

    while True:
        utils.update_stats(provider)
        building_machines = provider.building_machines
        if not building_machines:
            print "No more machines are building, finished."
            break

        print "Waiting on %s machines" % len(building_machines)
        for machine in building_machines:
            try:
                check_machine(jenkins, client, machine, error_counts,
                              credentials_id)
            except:
                traceback.print_exc()
                print "Abandoning machine %s" % machine.id
                utils.log.exception("Abandoning ID: %s" % machine.id)
                machine.state = vmdatabase.ERROR
                error = True
            db.commit()

        time.sleep(3)

    if error:
        sys.exit(1)
Beispiel #9
0
def main():
    db = vmdatabase.VMDatabase()

    if not SKIP_DEVSTACK_GATE_JENKINS:
        config = ConfigParser.ConfigParser()
        config.read(DEVSTACK_GATE_SECURE_CONFIG)

        jenkins = myjenkins.Jenkins(config.get('jenkins', 'server'),
                                    config.get('jenkins', 'user'),
                                    config.get('jenkins', 'apikey'))
        jenkins.get_info()
    else:
        jenkins = None

    print 'Known machines (start):'
    db.print_state()

    provider = db.getProvider(PROVIDER_NAME)
    print "Working with provider %s" % provider.name

    client = utils.get_client(provider)

    flavor = utils.get_flavor(client, 1024)
    print "Found flavor", flavor

    error = False
    now = time.time()
    for machine in provider.machines:
        # Normally, reap machines that have sat in their current state
        # for 24 hours, unless that state is READY.
        if (REAP_ALL_SERVERS
                or (machine.state != vmdatabase.READY
                    and now - machine.state_time > MACHINE_LIFETIME)
                or machine.state == vmdatabase.DELETE
                or machine.state == vmdatabase.ERROR):
            print 'Deleting machine', machine.name
            try:
                delete_machine(jenkins, client, machine)
            except:
                error = True
                traceback.print_exc()

    provider_min_ready = 0
    for base_image in provider.base_images:
        provider_min_ready += base_image.min_ready
        for snap_image in base_image.snapshot_images:
            # Normally, reap images that have sat in their current state
            # for 24 hours, unless the image is the current snapshot
            if (REAP_ALL_IMAGES
                    or (snap_image != base_image.current_snapshot
                        and now - snap_image.state_time > MACHINE_LIFETIME)):
                print 'Deleting image', snap_image.name
                try:
                    delete_image(client, snap_image)
                except:
                    error = True
                    traceback.print_exc()

    print
    print 'Known machines (end):'
    db.print_state()

    utils.update_stats(provider)
    if error:
        sys.exit(1)
    def __init__ (self, debug_level=0, args=[], optlist=[]) :
        ChallengeBase.__init__(self, debug_level)

        self.message ="""
    usage: %s [-h] [-v] [-d] [ -k key-key  ] [ -c cert ] [ -i image-id ]\
[ -f flavor-id ] -n FQDN-name  

    image-id -f flavor-id
        -h - usage help 
        -v - verbose / debug output 
        -d - delete objects if they existed in cloud before creating new one
        -k - certificate pritate key (see -c below)
        -c - public certificate ( see -k above)
        -n - FQDN name like www.myexample.com
        -i - specify image-id or use the default for Ubuntu 10.04
        -f - specify flavor-id or use the default for the smallest cloud server
    """ % (PROGRAM_NAME) 

        self.cert_use_default = False
        self.cert_key_name = None
        self.cert_key = None
        self.cert_name = None
        self.cert = None

        self.opt_delete = False

        self.fqdn_name = None
        self.domain_name = None
        self.domain = None
        self.recs = None

        self.lb=None
        self.lb_name = None
        self.vip=None
        self.vip_address = None
        self.nodes=[]

        self.image = None
        self.image_id = None

        self.flavor = None
        self.flavor_id = None

        self.server_prefix=None
        self.cs_count=3
        self.server_passord = "SecretP@ss1"
        self.servers = []

        self.storage_name = None
        self.volumes=[]

        self.network_name = None
        self.network_range = "192.168.100.0/24"
        self.network = None
        self.network_id = None


        for o, val in optlist:
            if o == "-n":
                self.fqdn_name = val
                self.domain_name =  ".".join( self.fqdn_name.split('.')[1:] )
                self.domain=None
                self.recs = None
            elif o == "-d":
                self.opt_delete = True
            elif o == "-i":
                self.image_id = val
            elif o == "-f":
                self.flavor_id = val
            elif o == "-k":
                self.cert_key_name = val
            elif o == "-c":
                self.cert_name = val
            elif o == "-i":
                self.image_id = val
            elif o == "-f":
                self.flavor_id = val

        if not self.fqdn_name :
            self.usage()
            sys.exit(-1)

        #default values for some variables 

        self.image = None
        if not self.image_id :
            self.image_id = utils.get_image(self.cs)
        
        self.flavor= None
        if not self.flavor_id :
            self.flavor_id = utils.get_flavor(self.cs)

        self.lb_name = self.fqdn_name
        self.storage_name = self.fqdn_name
        self.server_prefix = self.fqdn_name
        self.network_name = self.fqdn_name

        if not self.cert_key_name and not self.cert_name :
            self.cert_use_default = True
            self.cert_key_name = self.fqdn_name + ".key"
            self.cert_key="""-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCypZq3lUHWhBjDxV6hOtOQFI3WvcGlp9RP+ZHVTcwDb/buaGIL
99xCUabM5TIjzfSMthddEb+43RIdZeaXSnqV0Ut+xF9fPIHiky+DrOS2i77ltu67
RGTerezjM36D4TW5N3vQOR+qIezp1yko1qJr5hROp2ykqcgIL5GzR4980QIDAQAB
AoGBAKIZyKDqa3pGFN6XWf18jnn/XJDNUEiLWAhVkfF2DTfVQcAksUrg1ljLFEp5
chyxBkUj+WE2+Lu6xXQtgaYoK7/+mRRpKEZ6aHEsd5KqoVgxp2igyRZOGyVWaAJ3
loi+GmMiRkjC6o6xxNGG7UNfXSACfbB8eEBaGw61ZhbZJ28NAkEA5rVk/mqQFYzO
WynHT1DUz4YeIpj1ZAnhjn/957knU61VoAjeruLANOmN5bQ2gCKJm7MsPJ11iAdp
Cfltaprq7wJBAMY7Jp0hQBWOp3J1VNTkeG23At/ZQv5QzkUih2hcHjXy54RYqFe/
pIH9qrLC01BjhG2PePrJwaKMmhl7TvQ7FD8CQHmG7848n+1aIJFQ7pZPQ+qVAWbE
H+80bUY9EahwldC0K7iDM5n4A7tbk81+In9Yshf8R78eSnz/Oktwwjw3oq0CQEyZ
3PEJQUdTSdeMCYz/AJ59AwpXXXEC7sJ+dk7YkgAM7nQRAnRuJPbqfET5zkiZPDpO
H9ThlAbpSD8ijD8KeWcCQBxun2xWhCH19BulbUufsocKrwaxAijJ4pc5fX+cabEU
Na05oMyXQxN2tR4gWlbyVrGuZPVRDH39oRej5z2/JUA=
-----END RSA PRIVATE KEY-----
"""
        self.cert_name = self.fqdn_name + ".crt"
        self.cert = """-----BEGIN CERTIFICATE-----