Comments (9)
From my understanding of the docs, update_backend only updates the settings supplied with update_backend_details. It can't be used to change the change the backend_name. The API returns a header, opc-work-request-id, which can be used with get_work_request. You will probably find an error in the work request.
https://docs.cloud.oracle.com/iaas/api/#/en/loadbalancer/20170115/Backend/UpdateBackend
I think update_backend_set is the API you need to change a backend server. https://docs.cloud.oracle.com/iaas/api/#/en/loadbalancer/20170115/BackendSet/UpdateBackendSet
from oci-python-sdk.
Any update on load balancer resources will create a work-request, please check the work request if it failed or completed, you can use get_work_request(work_request_id, **kwargs) to check it
from oci-python-sdk.
please check my code below:
def updateBackend(lbr,backendsetname,newip):
# print(type(newTimeOutVal))
config = oci.config.from_file(file_location="~/.oci/config", profile_name="DEFAULT")
lb_cli = oci.load_balancer.LoadBalancerClient(config)
backend_dict = dict(lb_cli.get_load_balancer(lbr).data.backend_sets)
print("the dict data is ",backend_dict)
print("the ocid is",)
#print("the dict is", lb_dict)
dictlist=[]
for key, value in backend_dict.items():
temp = [key, value]
dictlist.append(temp)
for key in backend_dict.keys():
# if key == listner :
print("*********************")
backends = backend_dict[key].backends
print(type(backends))
print(backend_dict[key].name)
mylist = []
print ("the backends are",backends)
if (len(backends)) > 0:
for backendietm in backends:
print("**************")
print("the backenditems are",backendietm)
print("**************")
backendset_details = oci.load_balancer.models.UpdateBackendSetDetails(policy=backend_dict[key].policy,backends=backends,health_checker=backend_dict[key].health_checker)
print("************************************************")
print("the abckendset_details are",backendset_details)
print("calling update_backend_set")
print("the backendset details are",backendset_details.backends)
print("the backendset name",backend_dict[key].name)
print("the lbr is",lbr)
print("*****************")
print("Getting the Backend Details")
print("************************************")
newip = "10.0.0.4:90";
#lb_backend = lb_cli.get_backend(load_balancer_id=lbr,backend_set_name=backend_dict[key].name,backend_name="newip")
#lb_cli.update_backend_set(update_backend_set_details=backends,load_balancer_id=lbr,backend_set_name=backend_dict[key].name)
print("&&&&&&&&&&&&&&&&&&&&&&&")
backenddetails = oci.load_balancer.models.UpdateBackendDetails(weight=1, backup=backendietm.backup,
drain=backendietm.drain,
offline=backendietm.offline)
print("backenddetails are",backenddetails)
print("set set set ",backend_dict[key].name)
print("****************************")
lb_cli.update_backend(update_backend_details=backenddetails, load_balancer_id=lbr, backend_set_name=backend_dict[key].name, backend_name=newip)
updateBackend("ocid1.loadbalancer.oc1.iad.********************","lb-20190416-****-backend-set","10.0.0.4:90")
Here I am calling the (update_backend method )
Parameters: | update_backend_details (UpdateBackendDetails) -- (required) Details for updating a backend server.load_balancer_id (str) --(required) The OCID of the load balancer associated with the backend set and server.backend_set_name (str) --(required) The name of the backend set associated with the backend server.Example: example_backend_setbackend_name (str) --(required) The IP address and port of the backend server to update.Example: 10.0.0.3:8080opc_request_id (str) -- (optional) The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.opc_retry_token (str) -- (optional) A token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations (e.g., if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected).retry_strategy (obj) --(optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy. |
---|---|
A Response object with data of type None | |
Response |
the O/P I am getting is:
backend set name that I am getting is : lb-20190416-****-backend-set
type of backendset {
"backends": [
{
"backup": false,
"drain": false,
"ip_address": "10.0.0.4",
"name": "10.0.0.4:80",
"offline": false,
"port": 80,
"weight": 1
}
],
"health_checker": {
"interval_in_millis": 100000,
"port": 80,
"protocol": "HTTP",
"response_body_regex": "",
"retries": 3,
"return_code": 200,
"timeout_in_millis": 3000,
"url_path": "/"
},
"policy": "ROUND_ROBIN",
"session_persistence_configuration": null,
"ssl_configuration": null
}
Process finished with exit code 0
from oci-python-sdk.
if I update with the same ip and port it is getting succeeded whereas if I give the new "ip" and "port" it is not getting updated. please check the below. please check the Work Requests:
from oci-python-sdk.
Based on your code it seems like you are trying to switch one backend server for another backend server. You cannot do this with update_backend. You can only update the properties of a backend using update_backend. This is why you see the update_backend work requests succeed when you supply an IP address and port which exists in the backend set and see them fail when you supply a new IP address and port. The load balancer figures out which backend you want to update using the IP address and port. When you supply an IP address and port of a backend that is not part of the backend set the load balancer cannot perform an update_backend because it cannot find the backend to update.
You have to use update_backend_set to add or remove backends from the backend set.
https://docs.cloud.oracle.com/iaas/api/#/en/loadbalancer/20170115/BackendSet/UpdateBackendSet
I think these pages may help https://docs.cloud.oracle.com/iaas/Content/Balance/Concepts/balanceoverview.htm and https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/loadbalancing.htm#Add
from oci-python-sdk.
Getting the backend set details:
backenddetails = oci.load_balancer.models.UpdateBackendDetails(weight=1, backup=backendietm.backup,
drain=backendietm.drain,
offline=backendietm.offline)
updating the backend details
lb_cli.update_backend(update_backend_details=backenddetails, load_balancer_id=lbr, backend_set_name=backend_dict[key].name, backend_name=backendietm.name)
As you said in the UpdateBackendDetails we don't have the property backend_name.
Here my requirement is to update the ipaddr and port. where as in the api i got the method update_backed to update the backend_name.
Correct me if i am wrong. And please let me know from which method we can update the backend_name. please let me know the flow.
from oci-python-sdk.
You cannot change the backend_name with update_backend. You need to add the new server to the backend set using update_backend_set. Backend_name is composed of the IP address and port, but it is readonly and cannot be used to set the IP address and port of a backend.
The API call you need is update_backend_set
.
If you have "10.0.0.4:80" in your backend set but you want "10.0.0.5:80" you have to remove "10.0.0.4:80" and add "10.0.0.5:80" using update_backend_set. Once you have updated the backend set you will see the name "10.0.0.5:80" in your list of backends.
from oci-python-sdk.
@sreecharanm, were you able to get the backend updated?
from oci-python-sdk.
@sreecharanm, I'm going to close this ticket, assuming everything is working for you now. Please reopen it if that is not the situation.
from oci-python-sdk.
Related Issues (20)
- oci.pagination.list_call_get_all_results fails when using identity domain client HOT 2
- Missing Composite Operations for Identity Domains
- Generate bypass code with python OCI HOT 2
- Packaging Metadata: Classifiers specify as supported already dead python and not mark modern versions HOT 1
- showoci stuck while running for all resources HOT 3
- resource name not getting cost analysis (Usageapi cllent) HOT 13
- Private IP addresses for the db_nodes in ExaCS is not the correct one HOT 21
- problems running in CLI OCI HOT 3
- metrics are geting 429 error when we calling the api filter maximum , minimum and average metrics HOT 6
- Issue with accessing oci.container_instances.ContainerInstanceClient response data HOT 2
- volume backups are not getting all records in this list_volume_backups api call HOT 8
- Report with properties of PDBs HOT 4
- Error using FlowLogCaptureFilterRuleDetails
- Missing dependency on sseclient
- oci python SDK while using instance-principals, raising exceptions.ServiceError NotAuthorizedOrNotFound HOT 7
- a little typo in the documentation how to run CLI with help option $ python3 oci_capacity_reporter_gui.py -help HOT 1
- Error in log-analytics storage purge-storage-data HOT 4
- Focus report how we can get it. HOT 1
- call mysql_client_composite_ops.copy_backup_and_wait_for_state display AttributeError: 'DbBackupsClient' object has no attribute 'get_work_request'
- usageapi not working for ap-mumbai region HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oci-python-sdk.