Skip to content

Commit

Permalink
specify ibm cloud zone instead of hardcoded API url
Browse files Browse the repository at this point in the history
  • Loading branch information
nikromen committed Oct 3, 2023
1 parent 84ebbd0 commit c0f0156
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions resalloc_ibm_cloud/argparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def default_arg_parser():
"--token-file", help="Path to IBM cloud token file", required=True
)
parser.add_argument(
"--service-url",
help="SERVICE URL e.g. https://jp-tok.iaas.cloud.ibm.com/v1",
"--zone",
help="default IBM Cloud zone. e.g. jp-tok, us-east, us-west, ...",
required=True,
)
return parser
Expand Down
2 changes: 1 addition & 1 deletion resalloc_ibm_cloud/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ def get_service(cmd: str, opts: Namespace):
authenticator = IAMAuthenticator(token)
now = datetime.datetime.now()
service = VpcV1(now.strftime("%Y-%m-%d"), authenticator=authenticator)
service.set_service_url(opts.service_url)
service.set_service_url(f"https://{opts.zone}.iaas.cloud.ibm.com/v1")
return service
6 changes: 2 additions & 4 deletions resalloc_ibm_cloud/ibm_cloud_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ def allocate_and_assign_ip(service, opts):
Allocate and assign a Floating IP to an existing machine in one call.
"""

service_url = (
opts.service_url[:-1] if opts.service_url[-1] == "/" else opts.service_url
)
service_url = f"https://{opts.zone}.iaas.cloud.ibm.com/v1"
url = service_url + "/floating_ips"
headers = {
"Accept": "application/json",
Expand Down Expand Up @@ -164,7 +162,7 @@ def create_instance(service, instance_name, opts):
],
},
"zone": {
"name": opts.zone,
"name": urlparse(opts.se),
},
"volume_attachments": [
{
Expand Down

0 comments on commit c0f0156

Please sign in to comment.