def create_base(): try: data = request.get_json(force=True) except: return badjson() try: name = data['name'].strip() if not name: raise RuntimeError("Name is required") description = data['description'] ami_version_base = int(data['ami_version_base']) if not ami_version_base or ami_version_base <= 0: raise RuntimeError("Bad base ami version id %s" % (ami_version_base)) except Exception as e: return baseresponse(success=False, message="Bad data input", errors=str(e)) try: create_base_amination(name=name, description=description, ami_version_base=ami_version_base) except Exception as e: return baseresponse(success=False, message="Unable to create amination", errors=str(e)) return success()
def create_version(): try: data = request.get_json(force=True) except: return badjson() try: parent = int(data['parent']) if not parent or parent <= 0: raise RuntimeError("Bad parent id %s" % (parent)) ami_version = int(data['ami_version']) if not ami_version or ami_version <= 0: raise RuntimeError("Bad ami version id %s" % (ami_version)) start = False if 'start' in data: start = bool(data['start']) except Exception as e: return baseresponse(success=False, message="Bad data input", errors=str(e)) try: create_amination_version(amination_base=parent, ami_version=ami_version, start=start) except Exception as e: return baseresponse(success=False, message="Unable to create amination", errors=str(e)) return success()
def get_bases(): try: bases = all_base_aminations() except Exception as e: return baseresponse(success=False, message="Unable to load aminations", errors=str(e)) return baseresponse(success=True, message=bases)
def get_base_versions(base_id): try: versions = versions_for_base(base_id) except Exception as e: return baseresponse(success=False, message="Unable to load versions for base %s" % base_id, errors=str(e)) return baseresponse(success=True, message=versions)
def get_base_versions(base_id): try: versions = versions_for_base(base_id) except Exception as e: return baseresponse( success=False, message="Unable to load versions for base %s" % base_id, errors=str(e) ) return baseresponse( success=True, message=versions )
def get_bases(): try: bases = all_bases() except Exception as e: return baseresponse( success=False, message="Unable to load base", errors=str(e) ) return baseresponse( success=True, message=bases )
def run(amination): start_amination(amination) return baseresponse( success=True, message=bases )
def create_base(): try: data = request.get_json(force=True) except: return badjson() try: name = data['name'].strip() if not name: raise RuntimeError("Name is required") append_version = bool(data['append_version']) append_date = bool(data['append_date']) if data['tags']: tag_list = list(data['tags']) else: tag_list = [] description = data['description'] except Exception as e: return baseresponse( success=False, message="Bad data input", errors=str(e) ) try: create_base_template( name=name, append_date=append_date, append_version=append_version, tags=tag_list, description=description, provisioner='', cli_args=[] ) except Exception as e: return baseresponse( success=False, message="Unable to create template", errors=str(e) ) return success()
def create_version(): try: data = request.get_json(force=True) except: return badjson() try: parent = int(data['parent']) if not parent or parent <= 0: raise RuntimeError("Bad parent id %s" % (parent)) aminator_provsioner = data['provisioner'] if not aminator_provsioner: raise RuntimeError("Provisioner is required") cli_args = [] for arg in data['cli_args']: cli_args.append({ 'name' : arg['name'], 'value' : unicode(arg['value']) }) except Exception as e: return baseresponse( success=False, message="Bad data input", errors=str(e) ) try: create_template_version( parent=parent, provisioner=aminator_provsioner, cli_args=cli_args ) except Exception as e: return baseresponse( success=False, message="Unable to create template version", errors=str(e) ) return success()
def create_version(): try: data = request.get_json(force=True) except: return badjson() try: parent = int(data['parent']) if not parent or parent <= 0: raise RuntimeError("Bad parent id %s" % (parent)) ami_version = int(data['ami_version']) if not ami_version or ami_version <= 0: raise RuntimeError("Bad ami version id %s" % (ami_version)) start = False if 'start' in data: start = bool(data['start']) except Exception as e: return baseresponse( success=False, message="Bad data input", errors=str(e) ) try: create_amination_version( amination_base=parent, ami_version=ami_version, start=start ) except Exception as e: return baseresponse( success=False, message="Unable to create amination", errors=str(e) ) return success()
def create_base(): try: data = request.get_json(force=True) except: return badjson() try: name = data['name'].strip() if not name: raise RuntimeError("Name is required") description = data['description'] ami_version_base = int(data['ami_version_base']) if not ami_version_base or ami_version_base <= 0: raise RuntimeError("Bad base ami version id %s" % (ami_version_base)) except Exception as e: return baseresponse( success=False, message="Bad data input", errors=str(e) ) try: create_base_amination( name=name, description=description, ami_version_base=ami_version_base ) except Exception as e: return baseresponse( success=False, message="Unable to create amination", errors=str(e) ) return success()
def create_version(): try: data = request.get_json(force=True) except: return badjson() try: parent = int(data['parent']) if not parent or parent <= 0: raise RuntimeError("Bad parent id %s" % (parent)) template = int(data['template']) region_list = [] if data['regions']: region_list = list(data['regions']) base_region = data['base_region'].strip() if not base_region: raise RuntimeError("A base region is required") except Exception as e: return baseresponse(success=False, message="Bad data input", errors=str(e)) try: create_version_version(parent=parent, template=template, base_region=base_region, regions=region_list) except Exception as e: return baseresponse(success=False, message="Unable to create ami version version", errors=str(e)) return success()
def run(amination): start_amination(amination) return baseresponse(success=True, message=bases)