libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bchazalet <>
Subject [GitHub] libcloud pull request #1165: Allow shared vpc in gce
Date Thu, 18 Jan 2018 13:26:05 GMT
GitHub user bchazalet opened a pull request:

    Allow shared vpc in gce

    ## Allow for use of shared network (vpc) and subnetwork in GCE
    ### Description
    It's currently not possible to create an GCE instance within a [shared VPC](
and a shared subnet via ansible although it's possible from the google compute console (see
    In the code, the problem seems to be that even if a fully qualified resource URL is passed
for a network (or subnetwork), it is parsed into parts and then reconstructed assuming the
resource is under the configured gcloud project. But since we're using a shared VPC, the resource
is under a different project.
     For example, say, I have two projects, `my-main-project` which hosts a shared vpc named
`sharedvpc` and `my-other-project` which has shared access to `sharedvpc`. What I want to
do is to create a GCE instance under `my-other-project` and within the `sharedvpc` project.
    So in the gce module, I pass the resource URLs:
      - name: Create instance
            instance_names: "{{ instance_name }}"
            machine_type: "{{ machine_type }}"
            image: "{{ image_name }}"
            zone: "{{ zone }}"
            tags: app-servers
            state: present
    But, in the module's code, the resource URLs will be parsed and transform respectively
to `/global/networks/sharedvpc` and `/regions/europe-west2/subnetworks/default` which implicitly
refer to the project configured by glcoud, i.e. `my-other-project`. As a result, I get a `ResourceNotFound`
    Instead, if a resource (network or subnetwork) is fully qualified via a resource URL (i.e.
it starts with `https://`), we can simply use it in the underlying google request. This is
what the new code does.
    ### Status
    Done, ready for review. I'm new to libcloud, so I'll happily take feedback and amend the
    ### Checklist (tick everything that applies)
    - [ ] [Code linting](
(required, can be done after the PR checks)
    - [ ] Documentation
    - [ ] [Tests](
    - [ ] [ICLA](
(required for bigger changes)

You can merge this pull request into a Git repository by running:

    $ git pull wip/hack-to-allow-shared-vpc-in-gce

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1165
commit f71da15c372a0d69a9d705e073a5a4cadfd897c1
Author: Boris Chazalet <bchazalet@...>
Date:   2018-01-18T09:05:29Z

    Allow shared network/subnetwork
    If they come as fully qualified resource URLs (https://)

commit 408ac7bbd9def69499434fdd389ef93b3c5f804e
Author: Boris Chazalet <bchazalet@...>
Date:   2018-01-18T09:18:36Z

    Make sure simply qualified subnet works too



View raw message