Пример #1
0
    def register_kinds(self, descriptions, db_occi_ids, db_occi_locs):
        """
        Create new kinds
        Args:
            @param descriptions: OCCI kind descriptions
            @param db_occi_ids: Kind IDs already existing in the database
            @param db_occi_locs: Kind locations already existing in the database
        """
        loc_res = list()

        resp_code = return_code["OK"]

        for desc in descriptions:

            occi_id = joker.get_description_id(desc)
            # Step[1]: verify uniqueness of the new kind
            ok_k = joker.verify_occi_uniqueness(occi_id, db_occi_ids)

            if ok_k is True:
                occi_loc = joker.make_category_location(desc)
                ok_loc = joker.verify_occi_uniqueness(occi_loc, db_occi_locs)

                if ok_loc is True:
                    jData = dict()
                    jData["_id"] = uuid_Generator.get_UUID()
                    jData["OCCI_Location"] = occi_loc
                    jData["OCCI_Description"] = desc
                    jData["OCCI_ID"] = occi_id
                    jData["Type"] = "Kind"
                    # Default backend is dummy
                    jData["Provider"] = {"local": [config.DEFAULT_BACKEND], "remote": []}
                    loc_res.append(jData)

                else:
                    message = "Location conflict, kind will not be created."
                    logger.error("===== Register kind : " + message + " =====")
                    resp_code = return_code["Conflict"]
                    return list(), resp_code
            else:
                message = "This kind description already exists in document "
                logger.error("===== Register kind : " + message + " =====")
                resp_code = return_code["Conflict"]
                return list(), resp_code

        return loc_res, resp_code
Пример #2
0
    def register_kinds(self, descriptions, db_occi_ids, db_occi_locs):
        """
        Create new kinds
        Args:
            @param descriptions: OCCI kind descriptions
            @param db_occi_ids: Kind IDs already existing in the database
            @param db_occi_locs: Kind locations already existing in the database
        """
        loc_res = list()

        resp_code = return_code['OK']

        for desc in descriptions:

            occi_id = joker.get_description_id(desc)
            #Step[1]: verify uniqueness of the new kind
            ok_k = joker.verify_occi_uniqueness(occi_id, db_occi_ids)

            if ok_k is True:
                occi_loc = joker.make_category_location(desc)
                ok_loc = joker.verify_occi_uniqueness(occi_loc, db_occi_locs)

                if ok_loc is True:
                    jData = dict()
                    jData['_id'] = uuid_Generator.get_UUID()
                    jData['OCCI_Location'] = occi_loc
                    jData['OCCI_Description'] = desc
                    jData['OCCI_ID'] = occi_id
                    jData['Type'] = "Kind"
                    #Default backend is dummy
                    jData['Provider'] = {"local": [config.DEFAULT_BACKEND], "remote": []}
                    loc_res.append(jData)

                else:
                    message = "Location conflict, kind will not be created."
                    logger.error("===== Register kind : " + message + " =====")
                    resp_code = return_code['Conflict']
                    return list(), resp_code
            else:
                message = "This kind description already exists in document "
                logger.error("===== Register kind : " + message + " =====")
                resp_code = return_code['Conflict']
                return list(), resp_code

        return loc_res, resp_code
Пример #3
0
    def register_mixins(self, descriptions, db_occi_ids, db_occi_locs):
        """
        Add new mixins to the database
        Args:
            @param descriptions: OCCI mixin descriptions
            @param db_occi_ids: Existing Mixin IDs in database
            @param db_occi_locs: Existing Mixin locations in database
        """
        loc_res = list()
        resp_code = return_code['OK']

        for desc in descriptions:

            #Step[1]: Verify mixin uniqueness
            occi_id = joker.get_description_id(desc)
            ok_k = joker.verify_occi_uniqueness(occi_id, db_occi_ids)

            if ok_k is True:
                #Step[2]: Start creation the mixin
                occi_loc = joker.make_category_location(desc)
                ok_loc = joker.verify_occi_uniqueness(occi_loc, db_occi_locs)

                if ok_loc is True:
                    jData = dict()
                    jData['_id'] = uuid_Generator.get_UUID()
                    jData['OCCI_Location'] = occi_loc
                    jData['OCCI_Description'] = desc
                    jData['OCCI_ID'] = occi_id
                    jData['Type'] = "Mixin"
                    loc_res.append(jData)

                else:
                    message = "Location conflict, Mixin will not be created."
                    logger.error("===== Register Mixin : " + message + " =====")
                    resp_code = return_code['Conflict']
                    return list(), resp_code
            else:
                message = "This Mixin description already exists in document."
                logger.error(" ====== Register Mixin : " + message + " =====")
                resp_code = return_code['Conflict']
                return list(), resp_code
        #Step[3]: return the newly created mixins
        return loc_res, resp_code
Пример #4
0
    def register_kinds(self, descriptions, db_occi_ids, db_occi_locs):
        """
        Add new kinds to the database
        Args:
            @param descriptions: OCCI kind descriptions
            @param db_occi_ids: Kind IDs already existing in the database
            @param db_occi_locs: Kind locations already existing in the database
        """
        loc_res = list()

        resp_code = return_code['OK']

        for desc in descriptions:
            occi_id = joker.get_description_id(desc)
            ok_k = joker.verify_occi_uniqueness(occi_id, db_occi_ids)

            if ok_k is True:
                occi_loc = joker.make_category_location(desc)
                ok_loc = joker.verify_occi_uniqueness(occi_loc, db_occi_locs)

                if ok_loc is True:
                    jData = dict()
                    jData['_id'] = uuid_Generator.get_UUID()
                    jData['OCCI_Location'] = occi_loc
                    jData['OCCI_Description'] = desc
                    jData['OCCI_ID'] = occi_id
                    jData['Type'] = "Kind"
                    jData['Provider'] = {"local": ["dummy"], "remote": []}
                    loc_res.append(jData)

                else:
                    message = "Location conflict, kind will not be created."
                    logger.error("===== Register kind ERROR: " + message + " =====")
                    resp_code = return_code['Conflict']
                    return list(), resp_code
            else:
                message = "This kind description already exists in document "
                logger.error("===== Register kind ERROR: " + message + " =====")
                resp_code = return_code['Conflict']
                return list(), resp_code

        return loc_res, resp_code