diff --git a/resalloc_ibm_cloud/argparsers.py b/resalloc_ibm_cloud/argparsers.py index f950676..e3aaf0c 100644 --- a/resalloc_ibm_cloud/argparsers.py +++ b/resalloc_ibm_cloud/argparsers.py @@ -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 diff --git a/resalloc_ibm_cloud/helpers.py b/resalloc_ibm_cloud/helpers.py index 027fa3c..336c65c 100644 --- a/resalloc_ibm_cloud/helpers.py +++ b/resalloc_ibm_cloud/helpers.py @@ -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 diff --git a/resalloc_ibm_cloud/ibm_cloud_vm.py b/resalloc_ibm_cloud/ibm_cloud_vm.py index dcc977f..9614154 100755 --- a/resalloc_ibm_cloud/ibm_cloud_vm.py +++ b/resalloc_ibm_cloud/ibm_cloud_vm.py @@ -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", @@ -164,7 +162,7 @@ def create_instance(service, instance_name, opts): ], }, "zone": { - "name": opts.zone, + "name": urlparse(opts.se), }, "volume_attachments": [ {