summaryrefslogtreecommitdiffstats
AgeCommit message (Expand)AuthorFilesLines
2022-03-07Dependency Injection using Lombokmpriyank1-21/+10
2022-03-03Merge "Update dmi-registry yang to support cmHandle State"Bruno Sakoto7-12/+350
2022-03-03Merge "Bug fix for delete data node not working for root node"Renu Kumari3-32/+28
2022-03-03Bug fix for delete data node not working for root nodeputhuparambil.aditya3-32/+28
2022-03-03Update dmi-registry yang to support cmHandle Statelukegleeson7-12/+350
2022-03-02Update dependencies as recommended by SECCOMToineSiebelink1-0/+10
2022-03-02Merge "CPS-475 - Fix SQ codesmells introduced as aprt of CPS-887"Toine Siebelink1-2/+2
2022-03-02CPS-475 - Fix SQ codesmells introduced as aprt of CPS-887JosephKeenan1-2/+2
2022-03-02Addressed refactoring comments related to method namempriyank3-13/+17
2022-03-01Merge "Adding missing rollback for Liquibase change logs"Toine Siebelink2-1/+27
2022-03-01Create Endpoint For Get Cm Handles By NameDylanB95EST36-522/+1425
2022-03-01Adding missing rollback for Liquibase change logslukegleeson2-1/+27
2022-02-28Merge "Bug fix for delete data node not working for root node"Bruno Sakoto3-17/+44
2022-02-28NCMP Java API depends on NCM-Rest-API (cyclic) through json properties on Jav...DylanB95EST20-98/+263
2022-02-28CPS-887 Decreasing performance of cmHandle registrationJosephKeenan15-110/+335
2022-02-28Merge "Updated openapi.yaml to match to changes in get data node API"Toine Siebelink20-47/+38
2022-02-28Bug fix for delete data node not working for root nodeputhuparambil.aditya3-17/+44
2022-02-28Updated openapi.yaml to match to changes in get data node APIputhuparambil.aditya20-47/+38
2022-02-25Fix success response code CM Handle Registrationmpriyank9-33/+68
2022-02-17Align JSON DataNode for Get and Post/Put API in CPSputhuparambil.aditya9-24/+60
2022-02-16Core logic to update,add or remove cmHandle propertiesmpriyank10-52/+435
2022-02-16Merge "Fragment handling decreasing performance for large number of cmHandles"aditya puthuparambil4-108/+97
2022-02-15Fix to keep yang resource cache in syncRenu Kumari4-52/+169
2022-02-15Fragment handling decreasing performance for large number of cmHandlesDylanB95EST4-108/+97
2022-02-14Improve logging in NCMPsourabh_sourabh5-36/+51
2022-02-14Merge "Update release notes"aditya puthuparambil1-1/+77
2022-02-14Merge "Upgrade SDN-C"Toine Siebelink5-27/+41
2022-02-11Update release notesBruno Sakoto1-1/+77
2022-02-11Upgrade SDN-Cemaclee5-27/+41
2022-02-10Document Logging Guidelinessourabh_sourabh2-0/+117
2022-02-09Merge "Fix for retry mechanism on concurrent CmHandle registration"Bruno Sakoto4-3/+134
2022-02-09Fix for retry mechanism on concurrent CmHandle registrationputhuparambil.aditya4-3/+134
2022-02-07Add support for delete data-node eventRenu Kumari6-69/+99
2022-02-07Merge "Refactor Delete Anchor functionality"Renu Kumari12-104/+128
2022-02-03Merge "Test Scenario for replaceListContent"aditya puthuparambil3-139/+160
2022-02-03Merge "[TECHDEBT] Align CPS NCMP REST API Specification"Bruno Sakoto11-37/+138
2022-02-02Refactor Delete Anchor functionalityRenu Kumari12-104/+128
2022-02-02Merge "Refactored Delete SchemaSet functionality"Renu Kumari13-136/+236
2022-02-02Test Scenario for replaceListContentToineSiebelink3-139/+160
2022-02-02[TECHDEBT] Align CPS NCMP REST API SpecificationJosephKeenan12-38/+140
2022-02-02Merge "[TECHDEBT] Align CPS Core REST API Specification and Implementation"aditya puthuparambil5-26/+62
2022-02-02Merge "Database port not configurable through env variable"Toine Siebelink3-2/+3
2022-01-31[TECHDEBT] Align CPS Core REST API Specification and ImplementationJosephKeenan5-26/+62
2022-01-28Refactored Delete SchemaSet functionalityRenu Kumari13-136/+236
2022-01-28Support 'public' Cm Handle PropertiesDylanB95EST27-301/+513
2022-01-28Database port not configurable through env variableputhuparambil.aditya3-2/+3
2022-01-27Merge "Added CPS enhanced health check"aditya puthuparambil1-8/+6
2022-01-27Added CPS enhanced health checkNagendra902871-8/+6
2022-01-27Merge "Improve logging in NCMP"Toine Siebelink6-9/+146
2022-01-25Improve logging in NCMPsourabh_sourabh6-10/+147
class="mi">500: serviceMigration(service, status, username) else: print "Service {0} was tested and does not need a migration".format(serviceName) reportFile.write(service.line()) reportFile.close() def serviceMigration(service, serviceStatus, username): print "Service {0} was tested and it needs a migration".format(service.serviceName) print "Service {0} - Migration start" if serviceStatus == "Locked": print "Service {0} is locked - forcing checkin".format(service.serviceName) service.Checkin() print "Doing new checkout" service.Checkout(username) zipName = service.DownloadHeat() if not zipName: print "no heat found" service.uploadStatus = "no heat found" else: uploadResponse = service.UploadHeat(zipName) uploadResults = json.loads(uploadResponse) if uploadResults['status'] == 'Success' and uploadResults['errors'].__len__() == 0: service.uploadStatus = "Heat uploaded successfully" else: service.uploadStatus = "Heat uploaded with errors" print "Doing new checkin" service.Checkin() print "Service {0} - Migration end" def printHelp(): print("Upgrade script Help:") print("==================================") print("1607_to_1610 -h --> get help") print("1607_to_1610 -a <username>/<password> [-ip {ip}]") print("Example: 1607_to_1610 -a root/secret") class Service(object): def __init__(self, serviceName, vspId ,vendorName, lockingUser): self.serviceName = serviceName self.vspId = vspId self.vendorName = vendorName self.lockingUser = lockingUser self.webHandler = WebHandler(host=Service.serveraddress, port=DEFAULT_PORT) # Schema? self.uploadStatus = "not started" def __repr__(self): return 'Name: {0}, Id: {1}, Vendor: {2}, locked by: {3}, status {4}'.format(self.serviceName, self.vspId ,self.vendorName, self.lockingUser, self.uploadStatus) @classmethod def header(cls): return 'Name,Id,Vendor,locked-by,status\n' @classmethod def server(cls, address): cls.serveraddress=address def line(self): return '{0},{1},{2},{3},{4}\n'.format(self.serviceName, self.vspId ,self.vendorName, self.lockingUser, self.uploadStatus) def Checkout(self, userId): # /v1.0/vendor-software-products/{vspId}/actions urlpath=VSP_ACTIONS_PATH.format(vspId=self.vspId) response, headers = self.webHandler.rest( url=urlpath, method='PUT', data={"action": "Checkout"}, userId=userId) self.lockingUser=userId #we will later use this user to checkin return response def Checkin(self): # /v1.0/vendor-software-products/{vspId}/actions urlpath = VSP_ACTIONS_PATH.format(vspId=self.vspId) response, headers = self.webHandler.rest(url=urlpath, method='PUT', data={"action": "Checkin"}, userId=self.lockingUser) return response def Get(self): # /v1.0/vendor-software-products/{vspId} urlpath = VSP_GET_URL.format(vspId=self.vspId) try: response, headers = self.webHandler.rest(url=urlpath, method='GET', data=None, userId=self.lockingUser) except HttpError as e: print e.message response = e.status return response def UploadHeat(self, zipName): #/v1.0/vendor-software-products/{vspId}/upload urlpath = VSP_UPLOAD_PATH.format(vspId=self.vspId) try: fields = [] with open(zipName, 'rb') as fin: buffer = fin.read() fin.close() files = [('upload', 'heatfile.zip', buffer)] response = self.webHandler.post_multipart('HTTP', urlpath, fields, files, self.lockingUser) return response finally: print "done upload" def DownloadHeat(self): urlpath=VSP_DOWNLOAD_PATH.format(vspId=self.vspId) try: response, headers = self.webHandler.rest(url=urlpath, method='Get', data=None, userId=self.lockingUser, accept='application/octet-stream') except HttpError as e: if e.status == 404: return "" for (key, value) in headers: if key.lower() == "content-disposition": file_name = value[value.index('=')+1:] break heatsDir= os.path.join(os.path.dirname(__file__), 'heats') if not os.path.exists(heatsDir): os.makedirs(heatsDir) file_name = os.path.join(heatsDir, file_name) with open(file_name, "wb") as fout: fout.write(response) fout.close() return file_name class WebHandler(object): def __init__(self, host, port): self.host = host self.port = port def rest(self, url, method, data, userId, accept='application/json', content_type='application/json'): connection = httplib.HTTPConnection(host=self.host, port=self.port) try: headers = {'Content-Type':content_type ,'Accept':accept} headers['USER_ID'] = userId connection.request(method=method, headers=headers, body=json.dumps(data), url=url) response = connection.getresponse() if response.status not in range(200, 300): raise HttpError(status= response.status, message=response.reason) return response.read(), response.getheaders() finally: connection.close() def post_multipart(self, scheme, selector, fields, files, userId): """ Post fields and files to an http host as multipart/form-data. fields is a sequence of (name, value) elements for regular form fields. files is a sequence of (name, filename, value) elements for data to be uploaded as files Return the server's response page. """ content_type, body = self.encode_multipart_form_data(fields, files) if scheme and scheme.lower() == "http": h = httplib.HTTP(self.host, self.port) else: h = httplib.HTTPS(self.host, self.port) h.putrequest('POST', selector) h.putheader('content-type', content_type) h.putheader('content-length', str(len(body))) h.putheader('Accept', 'application/json') h.putheader('USER_ID', userId) h.endheaders() h.send(body) errcode, errmsg, headers = h.getreply() print errcode, errmsg, headers return h.file.read() def encode_multipart_form_data(self, fields, files): LIMIT = '----------lImIt_of_THE_fIle_eW_$' CRLF = '\r\n' L = [] for (key, value) in fields: L.append('--' + LIMIT) L.append('Content-Disposition: form-data; name="%s"' % key) L.append('') L.append(value) for (key, filename, value) in files: L.append('--' + LIMIT) L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, filename)) L.append('Content-Type: %s' % self.get_content_type(filename)) L.append('') L.append(value) L.append('--' + LIMIT + '--') L.append('') body = CRLF.join(L) content_type = 'multipart/form-data; boundary=%s' % LIMIT return content_type, body def get_content_type(self, filename): return mimetypes.guess_type(filename)[0] or 'application/octet-stream' class HttpError(Exception): def __init__(self, status, message): self.status = status self.message=message def __str__(self): return repr(self.value, self.message) if __name__ == "__main__": main(sys.argv[1:])