Beispiel #1
0
    def load(self, path=None):
        if not path:
            path = self.__path
        with open(path, "r") as f:
            data = snakeify_type(json.load(f))

        self.__schema = data["$schema"]
        self.mesh_name = data["mesh_name"]
        self.mesh_UUID = mt._UUID(data["mesh_UUID"])
        self.net_keys = [mt.Netkey(**key) for key in data["net_keys"]]
        self.app_keys = [mt.Appkey(**key) for key in data["app_keys"]]
        self.provisioners = [mt.Provisioner(**p) for p in data["provisioners"]]

        if "nodes" in data:
            self.nodes = [mt.Node(**n) for n in data["nodes"]]
        if "groups" in data:
            self.groups = [mt.Group(**g) for g in data["groups"]]
        if "iv_index" in data:
            self.iv_index = data["iv_index"]
        if "iv_update" in data:
            self.iv_update = data["iv_update"]

        if "address_handles" in data:
            self.address_handles = data["address_handles"]
        if "devkey_handles" in data:
            self.devkey_handles = data["devkey_handles"]

        if "models" in data:
            self.models = data["models"]
Beispiel #2
0
 def store(self, data):
     self.prov_db.nodes.append(mt.Node(**self.__session_data))
     self.prov_db.store()
     self.__session_data = {}