Beispiel #1
0
    def create_images(req):
        """
        Create a new deployment
        ["host01", "host02", ... ] or no arguments.  
        """
        print("Creating images")
        err, msg, hosts = Deployments.get_valid_hosts(req)
        if err != 0:
            return {'error': msg}, 200

        # get all the oses that need to be installed.
        oses = list(set([x["os"] for x in hosts]))
        # check that we have ISO mapped images for each one
        err, msg, isos = Deployments.get_valid_isos(oses)
        if err != 0:
            return {'error': msg}, 200
        # if the iso image isn't already exploded, extract it.
        err, msg = IsoMaker.extract_isos(isos)
        if err != 0:
            return {'error': msg}, 200
        # if the boot image isn't already created, create it.
        err, msg = IsoMaker.mkboot_isos(isos)
        if err != 0:
            return {'error': msg}, 400
        # always go through and create the auto installation media for each server.
        err, msg = Builder.make_images(hosts)
        if err != 0:
            return {'error': msg}, 400
        return {'status': "server images created!"}, 201
Beispiel #2
0
 def test_build_template(self):
     err, msg, f = Builder.build_template(self.cfg["hosts"][0], 
                                          self.cfg)
     if err != 0:
         print msg
     #print f
     assert(err == 0)
Beispiel #3
0
 def test_build_template(self):
     err, msg, f, net = Builder.build_template(self.cfg["hosts"][2],
                                               self.cfg)
     print net
     if err != 0:
         print msg
     assert (err == 0)
Beispiel #4
0
def mkboot_iso():
    # Get the ISO map
    db = YamlDB()
    err, msg, iso_images = db.get_iso_map(Const.KUBAM_CFG)
    if err != 0:
        return jsonify({"error": msg}), 400
    if len(iso_images) == 0:
        return jsonify({
            "error":
            "No ISOS have been mapped.  Please map an ISO image with an OS"
        }), 400
    iso_maker = IsoMaker()
    err, msg = iso_maker.mkboot_iso(isos)
    if err != 0:
        return jsonify({"error": msg}), 400

    builder = Builder()
    err, msg = builder.deploy_server_images(Const.KUBAM_CFG)
    if err != 0:
        return jsonify({"error": msg}), 400
    return jsonify({"status": "ok"}), 201
Beispiel #5
0
def mkboot_iso():
    # get the iso map
    err, msg, isos = YamlDB.get_iso_map(KUBAM_CFG)
    if err != 0:
        return jsonify({"error": msg}), 400
    if len(isos) == 0:
        return jsonify({"error": "No ISOS have been mapped.  Please map an ISO image with an OS"}), 400
    err, msg = IsoMaker.mkboot_iso(isos)
    if err != 0:
        return jsonify({"error": msg}), 400

    err, msg = Builder.deploy_server_images(KUBAM_CFG)
    if err != 0:
        return jsonify({"error": msg}), 400
    return jsonify({"status": "ok"}), 201
Beispiel #6
0
 def test_find_template(self):
     node = self.cfg["hosts"][0]
     err, msg, template, template_dir = Builder.find_template(node) 
Beispiel #7
0
def deploy_server_autoinstall_images():
    err, msg = Builder.deploy_server_images(KUBAM_CFG)
    if not err == 0:
        return jsonify({"error": msg})
    return jsonify({"status": "ok"}), 201