def post(self, storage_service, endpoints): logging.info('EndpointsAPI PUT called') try: global config global foo wildcards = {'s_id':storage_service, 'ep_id': endpoints, 'rb': g.rest_base} config=get_Endpoints_instance(wildcards) members.append(config) member_ids.append({'@odata.id': config['@odata.id']}) # Create instances of subordinate resources, then call put operation # not implemented yet path = create_path(self.root, self.storage_services, storage_service, self.endpoints, endpoints) if not os.path.exists(path): os.mkdir(path) else: # This will execute when POST is called for more than one time for a resource return config, 500 with open(os.path.join(path, "index.json"), "w") as fd: fd.write(json.dumps(config, indent=4, sort_keys=True)) # update the collection json file with new added resource collection_path = os.path.join(self.root, self.storage_services, storage_service, self.endpoints, 'index.json') update_collections_json(path=collection_path, link=config['@odata.id']) resp = config, 200 except Exception: traceback.print_exc() resp = INTERNAL_ERROR logging.info('EndpointsAPI put exit') return resp
def post(self, storage_systems): logging.info('StorageSystemsAPI PUT called') try: global config global foo wildcards = {'id': storage_systems, 'rb': g.rest_base} config = get_StorageSystems_instance(wildcards) members.append(config) member_ids.append({'@odata.id': config['@odata.id']}) path = os.path.join(self.root, self.storage_systems, storage_systems) if not os.path.exists(path): os.mkdir(path) with open(os.path.join(path, "index.json"), "w") as fd: fd.write(json.dumps(config, indent=4, sort_keys=True)) collection_path = os.path.join(self.root, self.storage_systems, 'index.json') update_collections_json(path=collection_path, link=config['@odata.id']) # Create instances of subordinate resources, then call put operation resp = config, 200 except Exception: traceback.print_exc() resp = INTERNAL_ERROR logging.info('StorageSystemsAPI put exit') return resp
def post(self, storage_service): logging.info('ClassesOfServiceCollectionAPI POST called') try: config = request.get_json(force=True) ok, msg = self.verify(config) if ok: # Save the new singleton singleton_name = os.path.basename(config['@odata.id']) path = os.path.join(self.root, self.storage_services, storage_service, self.classes_of_service, singleton_name) if not os.path.exists(path): os.mkdir(path) with open(os.path.join(path, "index.json"), "w") as fd: fd.write(json.dumps(config, indent=4, sort_keys=True)) # Update the collection collection_path = os.path.join(self.root, self.storage_services, storage_service, self.classes_of_service, 'index.json') update_collections_json(collection_path, config['@odata.id']) # Return a copy of the new singleton with a Created response resp = config, 201 else: resp = msg, 400 except Exception: traceback.print_exc() resp = INTERNAL_ERROR return resp
def post(self,storage_service): logging.info('StorageServicesAPI PUT called') try: global config global foo wildcards = {'id': storage_service, 'rb': g.rest_base} config=get_StorageServices_instance(wildcards) members.append(config) member_ids.append({'@odata.id': config['@odata.id']}) path = os.path.join(self.root, self.storage_services, storage_service) if not os.path.exists(path): os.mkdir(path) with open(os.path.join(path, "index.json"), "w") as fd: fd.write(json.dumps(config, indent=4, sort_keys=True)) collection_path = os.path.join(self.root, self.storage_services, 'index.json') update_collections_json(path=collection_path, link=config['@odata.id']) # Create instances of subordinate resources, then call put operation # Instantiate sub-collections: # Volumes # StoragePools #cfg = CreateFileSystems() #cfg.put(storage_service) #cfg = CreateDrives() #cfg.put(storage_service) #cfg = CreateStorageGroups() #cfg.put(storage_service) #cfg = CreateDataProtectionLoSCapabilities() #cfg.put(storage_service) #cfg = CreateDataSecurityLoSCapabilities() #cfg.put(storage_service) #cfg = CreateDataStorageLoSCapabilities() #cfg.put(storage_service) #cfg = CreateIOPerformanceLoSCapabilities() #cfg.put(storage_service) #cfg = CreateIOConnectivityLoSCapabilities() #cfg.put(storage_service) #cfg = CreateEndpoints() #cfg.put(storage_service) #cfg = CreateEndpointGroups() #cfg.put(storage_service) #cfg = CreateClassesOfService() #cfg.put(storage_service) resp = config, 200 except Exception: traceback.print_exc() resp = INTERNAL_ERROR logging.info('StorageServicesAPI put exit') return resp