openbaton / openstack4j-plugin

Apache License 2.0
3 stars 12 forks source link

[Question] Is this necessary? #13

Closed Rizwan-Qamar closed 6 years ago

Rizwan-Qamar commented 7 years ago

Is this check necessary anywhere other than authenticate method isV3API(vimInstance) list method says "List all XYZ that the current tenant has access to"

Similarly, is this necessary?

        if ((network.isRouterExternal() || network.isShared())
            || (isV3API(vimInstance) && network.getTenantId().equals(vimInstance.getTenant())
                || (!isV3API(vimInstance)
                    && network
                        .getTenantId()
                        .equals(getTenantFromName(os, vimInstance.getTenant())))))
mpauls commented 7 years ago

In some cases it is necessary to check the API version. In particular, to know what field/value to use, either tenant (v2) or project (v3). If we use v3 we have to use the tenant_id which is also required in the VIM instance definition. If we use v2, we have to use the tenant_name. Becomes crucial if we want to check (e.g.) to which project/tenant a certain network belongs.

Rizwan-Qamar commented 7 years ago

In authenticate method, scope of the request is defined: For V2 using tenantName:

OSFactory.builderV2()
                .endpoint(vimInstance.getAuthUrl())
                .credentials(vimInstance.getUsername(), vimInstance.getPassword())
                .tenantName(vimInstance.getTenant())
                .authenticate();

For V3 using using scopeToProject:

OSFactory.builderV3()
                .endpoint(vimInstance.getAuthUrl())
                .scopeToProject(project)
                .credentials(vimInstance.getUsername(), vimInstance.getPassword(), domain)
                .authenticate();

Openstack Rest API:

Default policy settings return only networks that the project who submits the request owns, unless an administrative user submits the request. In addition, networks shared with the project who submits the request are also returned. https://developer.openstack.org/api-ref/networking/v2/?expanded=list-networks-detail#list-networks

So, I am thinking only networks which this tenant has access to will be returned. Maybe, I am just confused. Feel free to close this issue. (The code works :+1: )