def update_credential(tenant_id, credential_id, new_user_name=None, new_password=None):
 session = db.get_session()
 try:
  cred = session.query(network_models_v2.Credential).filter_by(tenant_id=tenant_id).filter_by(credential_id=credential_id).one()
  if new_user_name:
   cred['user_name'] = new_user_name
  if new_password:
   cred['password'] = new_password
  session.merge(cred)
  session.flush()
  return cred
 except exc.NoResultFound:
  raise c_exc.CredentialNotFound(credential_id=credential_id, tenant_id=tenant_id)

def update_credential ( tenant_id , credential_id , new_user_name = None , new_password = None ) : session = db . get_session ( ) try : cred = session . query ( network_models_v2 . Credential ) . filter_by ( tenant_id = tenant_id ) . filter_by ( credential_id = credential_id ) . one ( ) if new_user_name : cred [ 'user_name' ] = new_user_name if new_password : cred [ 'password' ] = new_password session . merge ( cred ) session . flush ( ) return cred except exc . NoResultFound : raise c_exc . CredentialNotFound ( credential_id = credential_id , tenant_id = tenant_id )
updates a credential for a tenant .