Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: CloudVE/cloudbridge
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.2.0
Choose a base ref
...
head repository: CloudVE/cloudbridge
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 14 commits
  • 4 files changed
  • 3 contributors

Commits on Sep 15, 2023

  1. Update codecov badge

    nuwang authored Sep 15, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3edbc80 View commit details
  2. Merge pull request #319 from CloudVE/nuwang-patch-1

    Update codecov badge
    nuwang authored Sep 15, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    fd1cc02 View commit details

Commits on Apr 5, 2024

  1. Azure - add AZURE_NETWORK_RESOURCE_GROUP option in order to pick vnet…

    … from another ResourceGroup
    patchkez committed Apr 5, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a45b1b8 View commit details

Commits on Apr 8, 2024

  1. fix lint error

    patchkez committed Apr 8, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    28959f5 View commit details

Commits on Apr 10, 2024

  1. rename network -> networking

    patchkez committed Apr 10, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9211d21 View commit details
  2. fix lint error

    patchkez committed Apr 10, 2024
    Copy the full SHA
    db0a876 View commit details
  3. Copy the full SHA
    a9766e8 View commit details
  4. Merge pull request #322 from CloudVE/pull_request_target

    pull_request to pull_request_target for tests
    nuwang authored Apr 10, 2024
    Copy the full SHA
    6a4d98c View commit details

Commits on Apr 12, 2024

  1. Fix typo

    nuwang authored Apr 12, 2024
    Copy the full SHA
    5b5b036 View commit details
  2. Merge pull request #321 from patchkez/net_rg

    Azure - add AZURE_NETWORK_RESOURCE_GROUP to pick vnet from another ResourceGroup
    nuwang authored Apr 12, 2024
    Copy the full SHA
    1d74786 View commit details

Commits on Apr 13, 2024

  1. Upgrade actions to latest

    nuwang committed Apr 13, 2024
    Copy the full SHA
    751061d View commit details
  2. Checkout action needs explicit sha for pull request target

    nuwang committed Apr 13, 2024
    Copy the full SHA
    23112e9 View commit details
  3. Revert github action to pull_request

    nuwang committed Apr 13, 2024
    Copy the full SHA
    62e6980 View commit details
  4. Update more actions and fix pull request target

    nuwang committed Apr 13, 2024
    Copy the full SHA
    dfcc6c1 View commit details
Showing with 46 additions and 22 deletions.
  1. +11 −7 .github/workflows/integration.yaml
  2. +1 −1 README.rst
  3. +18 −14 cloudbridge/providers/azure/azure_client.py
  4. +16 −0 cloudbridge/providers/azure/provider.py
18 changes: 11 additions & 7 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ on:
push:
branches:
- main
pull_request:
pull_request_target:
branches:
- main
workflow_dispatch: {}
@@ -21,15 +21,17 @@ jobs:
python-version: [ '3.10' ]
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip dir
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-cache-${{ matrix.python-version }}-lint
@@ -54,15 +56,17 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip dir
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-cache-${{ matrix.python-version }}-${{ hashFiles('**/setup.py', '**/requirements.txt') }}
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ Build Status Tests
:target: https://github.com/CloudVE/cloudbridge/actions/
:alt: Integration Tests

.. image:: https://codecov.io/gh/CloudVE/cloudbridge/branch/main/graph/badge.svg
.. image:: https://codecov.io/gh/CloudVE/cloudbridge/graph/badge.svg?token=w0LAfAIVdd
:target: https://codecov.io/gh/CloudVE/cloudbridge
:alt: Code Coverage

32 changes: 18 additions & 14 deletions cloudbridge/providers/azure/azure_client.py
Original file line number Diff line number Diff line change
@@ -203,6 +203,10 @@ def access_key_result(self):
def resource_group(self):
return self._config.get('azure_resource_group')

@property
def networking_resource_group(self):
return self._config.get('azure_networking_resource_group')

@property
def storage_account(self):
return self._config.get('azure_storage_account')
@@ -610,30 +614,30 @@ def list_vm_types(self):

def list_networks(self):
return self.network_management_client.virtual_networks.list(
self.resource_group)
self.networking_resource_group)

def get_network(self, network_id):
url_params = azure_helpers.parse_url(NETWORK_RESOURCE_ID,
network_id)
network_name = url_params.get(NETWORK_NAME, "")
return self.network_management_client.virtual_networks.get(
self.resource_group, network_name)
self.networking_resource_group, network_name)

def create_network(self, name, params):
return self.network_management_client.virtual_networks. \
begin_create_or_update(self.resource_group, name, parameters=params).result()
begin_create_or_update(self.networking_resource_group, name, parameters=params).result()

def delete_network(self, network_id):
url_params = azure_helpers.parse_url(NETWORK_RESOURCE_ID, network_id)
network_name = url_params.get(NETWORK_NAME, "")
return self.network_management_client.virtual_networks. \
begin_delete(self.resource_group, network_name).wait()
begin_delete(self.networking_resource_group, network_name).wait()

def update_network_tags(self, network_id, tags):
url_params = azure_helpers.parse_url(NETWORK_RESOURCE_ID, network_id)
network_name = url_params.get(NETWORK_NAME, "")
return self.network_management_client.virtual_networks. \
begin_create_or_update(self.resource_group, network_name, tags).result()
begin_create_or_update(self.networking_resource_group, network_name, tags).result()

def get_network_id_for_subnet(self, subnet_id):
url_params = azure_helpers.parse_url(SUBNET_RESOURCE_ID, subnet_id)
@@ -646,22 +650,22 @@ def list_subnets(self, network_id):
url_params = azure_helpers.parse_url(NETWORK_RESOURCE_ID, network_id)
network_name = url_params.get(NETWORK_NAME, "")
return self.network_management_client.subnets. \
list(self.resource_group, network_name)
list(self.networking_resource_group, network_name)

def get_subnet(self, subnet_id):
url_params = azure_helpers.parse_url(SUBNET_RESOURCE_ID,
subnet_id)
network_name = url_params.get(NETWORK_NAME, "")
subnet_name = url_params.get(SUBNET_NAME, "")
return self.network_management_client.subnets. \
get(self.resource_group, network_name, subnet_name)
get(self.networking_resource_group, network_name, subnet_name)

def create_subnet(self, network_id, subnet_name, params):
url_params = azure_helpers.parse_url(NETWORK_RESOURCE_ID, network_id)
network_name = url_params.get(NETWORK_NAME, "")
result_create = self.network_management_client \
.subnets.begin_create_or_update(
self.resource_group,
self.networking_resource_group,
network_name,
subnet_name,
params
@@ -690,7 +694,7 @@ def delete_subnet(self, subnet_id):
try:
result_delete = self.network_management_client \
.subnets.begin_delete(
self.resource_group,
self.networking_resource_group,
network_name,
subnet_name
)
@@ -701,34 +705,34 @@ def delete_subnet(self, subnet_id):

def create_floating_ip(self, public_ip_name, public_ip_parameters):
return self.network_management_client.public_ip_addresses. \
begin_create_or_update(self.resource_group,
begin_create_or_update(self.networking_resource_group,
public_ip_name, public_ip_parameters).result()

def get_floating_ip(self, public_ip_id):
url_params = azure_helpers.parse_url(PUBLIC_IP_RESOURCE_ID,
public_ip_id)
public_ip_name = url_params.get(PUBLIC_IP_NAME, "")
return self.network_management_client. \
public_ip_addresses.get(self.resource_group, public_ip_name)
public_ip_addresses.get(self.networking_resource_group, public_ip_name)

def delete_floating_ip(self, public_ip_id):
url_params = azure_helpers.parse_url(PUBLIC_IP_RESOURCE_ID,
public_ip_id)
public_ip_name = url_params.get(PUBLIC_IP_NAME, "")
self.network_management_client. \
public_ip_addresses.begin_delete(self.resource_group,
public_ip_addresses.begin_delete(self.networking_resource_group,
public_ip_name).wait()

def update_fip_tags(self, fip_id, tags):
url_params = azure_helpers.parse_url(PUBLIC_IP_RESOURCE_ID,
fip_id)
fip_name = url_params.get(PUBLIC_IP_NAME, "")
self.network_management_client.public_ip_addresses. \
begin_create_or_update(self.resource_group, fip_name, tags).result()
begin_create_or_update(self.networking_resource_group, fip_name, tags).result()

def list_floating_ips(self):
return self.network_management_client.public_ip_addresses.list(
self.resource_group)
self.networking_resource_group)

def list_vm(self):
return self.compute_client.virtual_machines.list(
16 changes: 16 additions & 0 deletions cloudbridge/providers/azure/provider.py
Original file line number Diff line number Diff line change
@@ -47,6 +47,9 @@ def __init__(self, config):
self.resource_group = self._get_config_value(
'azure_resource_group', get_env('AZURE_RESOURCE_GROUP',
'cloudbridge'))
self.networking_resource_group = self._get_config_value(
'azure_networking_resource_group', get_env('AZURE_NETWORKING_RESOURCE_GROUP',
self.resource_group))
# Storage account name is limited to a max length of 24 alphanum chars
# and unique across all of Azure. Thus, a uuid is used to generate a
# unique name for the Storage Account based on the resource group,
@@ -128,6 +131,7 @@ def azure_client(self):
'azure_tenant': self.tenant,
'azure_region_name': self.region_name,
'azure_resource_group': self.resource_group,
'azure_networking_resource_group': self.networking_resource_group,
'azure_storage_account': self.storage_account,
'azure_public_key_storage_table_name':
self.public_key_storage_table_name,
@@ -177,3 +181,15 @@ def _initialize(self):

else:
raise cloud_error

"""
Verify that resource group used for network exists,
if not, use the self.resource_group
"""
try:
self._azure_client.get_resource_group(self.networking_resource_group)
except CloudError as cloud_error:
if cloud_error.error.error == "ResourceGroupNotFound":
self.networking_resource_group = self.resource_group
else:
raise cloud_error