filter_db = self._get_project_filter(session)
# To allow project&user addressing by name AS WELL AS _id
filter_db[BaseTopic.id_field(self.topic, _id)] = _id
- data = self.db.get_one(self.topic, filter_db)
self._send_msg(item, {"_id": _id})
- return data
+
+ data = self.db.get_one(self.topic, filter_db)
+ credentials = data["credentials"]
+
+ file_pkg = None
+ current_path = _id
+
+ self.fs.file_delete(current_path, ignore_non_exist=True)
+ self.fs.mkdir(current_path)
+ filename = "credentials.yaml"
+
+ file_path = (current_path, filename)
+ self.logger.info("File path: {}".format(file_path))
+ file_pkg = self.fs.file_open(file_path, "a+b")
+
+ credentials_yaml = yaml.safe_dump(
+ credentials, indent=4, default_flow_style=False
+ )
+ file_pkg.write(credentials_yaml.encode(encoding="utf-8"))
+
+ if file_pkg:
+ file_pkg.close()
+ file_pkg = None
+
+ self.fs.sync(from_path=current_path)
+
+ return (
+ self.fs.file_open((current_path, filename), "rb"),
+ "text/plain",
+ )
def update_cluster(self, session, _id, item, indata):
if not self.multiproject:
oka_flag = ""
if oka["_id"]:
oka_flag = "_id"
+ oka["sw_catalog_path"] = ""
elif oka["sw_catalog_path"]:
oka_flag = "sw_catalog_path"
for ksus in data:
if ksus["_id"] != _id:
for okas in ksus["oka"]:
- if okas["_id"] not in existing_oka:
+ self.logger.info("OKA: {}".format(okas))
+ if okas.get("sw_catalog_path", ""):
+ continue
+ elif okas["_id"] not in existing_oka:
existing_oka.append(okas["_id"])
if used_oka:
api_req=True,
)
elif topic == "clusters" and item == "get_creds":
- outdata = self.engine.get_cluster_info(
+ file, _format = self.engine.get_cluster_info(
engine_session, engine_topic, _id, item
)
+ outdata = file
else:
if item == "reports":
# TODO check that project_id (_id in this context) has permissions