diff --git a/docs/hana-management/index.md b/docs/hana-management/index.md index 8c26027..22a3bd7 100644 --- a/docs/hana-management/index.md +++ b/docs/hana-management/index.md @@ -42,7 +42,6 @@ Commands for this area are: hdirt --hdi-rebind-tenant TENANT_ID [PARAMS] rebind tenant hdi container instances hdira --hdi-rebind-all [PARAMS] rebind all hdi container instances --hdi-repair-bindings [PARAMS] create missing and delete ambiguous bindings - --hdi-migrate-all migrate all hdi containers to service-manager * --hdi-delete-tenant TENANT_ID delete hdi container instance and bindings for tenant * --hdi-delete-all delete all hdi container instances and bindings ... [TENANT_ID] filter list for tenant id @@ -148,12 +147,6 @@ manager. In other words, `mtx hdirt '{"special":true}'` corresponds cf bind-service -c '{"special":true}' ``` -## HDI Migrate - -The migration command `mtx --hdi-migrate-all` is a convenience functionality for migrating instance manager maintained -hdi containers and bindings to service manager. It will take care to not only migrate the underlying containers, but -also create new bindings for all of them so they can be accessed like before. - ## HDI Delete The deletion commands are only sensible for cleanup after some mocking/testing purposes. diff --git a/docs/index.md b/docs/index.md index 0e302fa..1c56154 100644 --- a/docs/index.md +++ b/docs/index.md @@ -95,7 +95,6 @@ commands: hdirt --hdi-rebind-tenant TENANT_ID [PARAMS] rebind tenant hdi container instances hdira --hdi-rebind-all [PARAMS] rebind all hdi container instances --hdi-repair-bindings [PARAMS] create missing and delete ambiguous bindings - --hdi-migrate-all migrate all hdi containers to service-manager * --hdi-delete-tenant TENANT_ID delete hdi container instance and bindings for tenant * --hdi-delete-all delete all hdi container instances and bindings ... [TENANT_ID] filter list for tenant id @@ -124,6 +123,4 @@ commands: either handle this gracefully or be restarted - `--server-start-debugger` will send SIGUSR1 to node process (requires ssh enabled on cf), which starts debugger _ without restart_ -- `--hdi-migrate-all` will call the instance-manager's migration route and then lazily create missing service-bindings - on service-manager - `TENANT` means you can enter either the subdomain or tenant id and both will work diff --git a/src/cli.js b/src/cli.js index 85cda19..ffbee22 100644 --- a/src/cli.js +++ b/src/cli.js @@ -70,7 +70,6 @@ commands: hdirt --hdi-rebind-tenant TENANT_ID [PARAMS] rebind tenant hdi container instances hdira --hdi-rebind-all [PARAMS] rebind all hdi container instances --hdi-repair-bindings [PARAMS] create missing and delete ambiguous bindings - --hdi-migrate-all migrate all hdi containers to service-manager * --hdi-delete-tenant TENANT_ID delete hdi container instance and bindings for tenant * --hdi-delete-all delete all hdi container instances and bindings ... [TENANT_ID] filter list for tenant id diff --git a/src/cliOptions.js b/src/cliOptions.js index 5d6a9a7..27e8c6c 100644 --- a/src/cliOptions.js +++ b/src/cliOptions.js @@ -243,11 +243,6 @@ module.exports = { callback: hdi.hdiRepairBindings, useCache: false, }, - HDI_MIGRATE_ALL: { - commandVariants: ["--hdi-migrate-all"], - callback: hdi.hdiMigrateAll, - useCache: false, - }, HDI_DELETE_TENANT: { commandVariants: ["--hdi-delete-tenant"], requiredPassArgs: [PASS_ARG.TENANT_ID], diff --git a/src/submodules/hanaManagement.js b/src/submodules/hanaManagement.js index a708061..e43fe3c 100644 --- a/src/submodules/hanaManagement.js +++ b/src/submodules/hanaManagement.js @@ -643,106 +643,6 @@ const hdiDeleteAllInstanceManager = async (context) => { const hdiDeleteAll = async (context) => (await _isServiceManager(context)) ? hdiDeleteAllServiceManager(context) : hdiDeleteAllInstanceManager(context); -const _lazyCreateServiceBinding = async (tenant_id, sm_url, token) => { - const { items: bindings } = await ( - await request({ - url: sm_url, - pathname: `/v1/service_bindings`, - query: { labelQuery: `tenant_id eq '${tenant_id}'` }, - auth: { token }, - headers: { - "Content-Type": "application/json", - }, - logged: false, - }) - ).json(); - if (bindings.length > 0) { - return "FOUND"; - } - - const { items: instances } = await ( - await request({ - url: sm_url, - pathname: `/v1/service_instances`, - query: { labelQuery: `tenant_id eq '${tenant_id}'` }, - auth: { token }, - headers: { - "Content-Type": "application/json", - }, - logged: false, - }) - ).json(); - if (instances.length === 0) { - console.error("error: found no service instances for tenant %s--skipping migration for this tenant", tenant_id); - return "ERROR"; - } - const [instance] = instances; - - await _createBindingServiceManagerFromInstance(sm_url, token, instance); - return "BINDING_CREATED"; -}; - -const hdiMigrateAll = async (context) => { - const { cfEnvServices } = await context.getHdiInfo(); - const [serviceManager, instanceManager] = ["service-manager", "managed-hana"].map((name) => { - const services = cfEnvServices[name]; - assert(Array.isArray(services), "could not find %s service binding", name); - assert(services.length === 1, "found multiple %s service bindings, expected just one", name); - return services[0]; - }); - - const { - credentials: { get_all_managed_instances_url, migrate_managed_instance_url, user: username, password }, - } = instanceManager; - assert( - migrate_managed_instance_url, - "cannot find 'migrate_managed_instance_url' property on instance-manager service" - ); - const { credentials } = serviceManager; - const { sm_url } = credentials; - const token = await context.getCachedUaaTokenFromCredentials(credentials); - - const containers = await ( - await request({ - url: get_all_managed_instances_url, - auth: { username, password }, - }) - ).json(); - - containers.sort(compareForInstanceManagerTenantId); - - const headers = ["tenant_id", "instance_manager_migration_status", "service_manager_binding_status"]; - const table = [headers]; - - // NOTE: we want to do this serially - for (const { tenant_id, managed_binding_id } of containers) { - let instance_manager_migration_status = "..."; - let service_manager_binding_status = "..."; - const response = await request({ - method: "POST", - url: migrate_managed_instance_url - .replace("{tenant_id}", tenant_id) - .replace("{service-manager_container_id}", serviceManager.instance_guid), - auth: { username, password }, - checkStatus: false, - }); - if (!response.ok) { - console.error("got bad response for tenant %s: %s", tenant_id, await response.text()); - instance_manager_migration_status = "FOUND"; - } else { - const { migration_status } = await response.json(); - instance_manager_migration_status = migration_status; - } - - service_manager_binding_status = await _lazyCreateServiceBinding(tenant_id, sm_url, token, managed_binding_id); - - table.push([tenant_id, instance_manager_migration_status, service_manager_binding_status]); - } - - console.log(); - return tableList(table); -}; - module.exports = { hdiList, hdiLongList, @@ -753,5 +653,4 @@ module.exports = { hdiTunnelTenant, hdiDeleteTenant, hdiDeleteAll, - hdiMigrateAll, };