def get_dataproject(self): """ Return the python dict representation of the project data """ #current_data = json.loads(self.data_project) current_data = Util.json_loads_byteified(self.data_project) return current_data
def _send_delete(self, url, params=None, **kwargs): try: r = requests.delete(url, params=None, verify=False, **kwargs) except Exception as e: log.exception(e) print "Exception during send DELETE" return {'error': 'error during connection to agent'} return Util.json_loads_byteified(r.text)
def import_kubernetes_from_dir_project(cls, dir_project): result = {} for k8s_filename in glob.glob( os.path.join(dir_project, 'K8S', '*.yaml')): log.info(k8s_filename) yaml_object = Util().loadyamlfile(k8s_filename) json_object = Util.json_loads_byteified( Util.yaml2json(yaml_object)) filename = os.path.splitext(os.path.basename(str(k8s_filename)))[0] result[filename] = json_object return result
def _send_post(self, url, data=None, json=None, **kwargs): try: r = requests.post(url, data=data, json=json, verify=False, **kwargs) print r.text except Exception as e: log.exception(e) print "Exception during send POST" return {'error': 'error during connection to agent'} return Util.json_loads_byteified(r.text)
def importprojectfiles(cls, file_dict): """Imports descriptors (extracted from the new project POST) The keys in the dictionary are the file types """ project = {'nsd': {}, 'vnfd': {}, 'click': {}, 'k8s': {}} for desc_type in project: if desc_type in file_dict: files_desc_type = file_dict[desc_type] for file in files_desc_type: if desc_type != 'k8s': project[desc_type][os.path.splitext( file.name)[0]] = json.loads(file.read()) else: yaml_object = Util().loadyamlfile(file) json_object = Util.json_loads_byteified( Util.yaml2json(yaml_object)) filename = os.path.splitext(os.path.basename( str(file)))[0] project[desc_type][filename] = json_object return project