From 21c55d66c67cce097adab2f237356388b1a16077 Mon Sep 17 00:00:00 2001 From: Gulsum Atici Date: Thu, 2 Feb 2023 20:41:00 +0300 Subject: [PATCH] Reformat files according to new black validation Change-Id: I68f6423f5f9a204c35b7c0c5239eb8a66e605f2c Signed-off-by: Gulsum Atici --- NG-RO/osm_ng_ro/ns.py | 11 ---------- NG-RO/osm_ng_ro/ns_thread.py | 11 +++++++--- NG-RO/osm_ng_ro/ro_main.py | 1 - NG-RO/osm_ng_ro/tests/test_ns.py | 11 ++-------- NG-RO/osm_ng_ro/vim_admin.py | 1 - .../test_sdn_asssist_juniper_contrail.py | 1 - RO-VIM-aws/osm_rovim_aws/vimconn_aws.py | 1 - RO-VIM-azure/osm_rovim_azure/vimconn_azure.py | 4 ---- RO-VIM-gcp/osm_rovim_gcp/vimconn_gcp.py | 5 ----- .../osm_rovim_openstack/vimconn_openstack.py | 13 ++---------- .../osm_rovim_vmware/vimconn_vmware.py | 3 ++- integration-tests/test_vimconn_gcp.py | 1 - ...ing_black_formatting-38523eb5ec59dae6.yaml | 20 +++++++++++++++++++ 13 files changed, 34 insertions(+), 49 deletions(-) create mode 100644 releasenotes/notes/fixing_black_formatting-38523eb5ec59dae6.yaml diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index 70217d69..4e88cc4b 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -1012,12 +1012,10 @@ class Ns(object): == "persistent-storage:persistent-storage" ): for vdu_volume in vdu_instantiation_volumes_list: - if ( vdu_volume["vim-volume-id"] and root_disk["id"] == vdu_volume["name"] ): - persistent_root_disk[vsd["id"]] = { "vim_volume_id": vdu_volume["vim-volume-id"], "image_id": vdu.get("sw-image-desc"), @@ -1028,7 +1026,6 @@ class Ns(object): return persistent_root_disk else: - if root_disk.get("size-of-storage"): persistent_root_disk[vsd["id"]] = { "image_id": vdu.get("sw-image-desc"), @@ -1065,9 +1062,7 @@ class Ns(object): and disk["id"] not in persistent_root_disk.keys() ): for vdu_volume in vdu_instantiation_volumes_list: - if vdu_volume["vim-volume-id"] and disk["id"] == vdu_volume["name"]: - persistent_disk[disk["id"]] = { "vim_volume_id": vdu_volume["vim-volume-id"], } @@ -1326,7 +1321,6 @@ class Ns(object): net_list (list): Net list of VDU """ for iface_index, interface in enumerate(target_vdu["interfaces"]): - net_text = Ns._check_vld_information_of_interfaces( interface, ns_preffix, vnf_preffix ) @@ -1545,13 +1539,11 @@ class Ns(object): True if i.get("position") is not None else False for i in target_vdu["interfaces"] ): - Ns._sort_vdu_interfaces(target_vdu) # If the position info is provided for some interfaces but not all of them, the interfaces # which has specific position numbers will be placed and others' positions will not be taken care. else: - Ns._partially_locate_vdu_interfaces(target_vdu) # If the position info is not provided for the interfaces, interfaces will be attached @@ -1578,7 +1570,6 @@ class Ns(object): ) if vdu_instantiation_volumes_list: - # Find the root volumes and add to the disk_list persistent_root_disk = Ns.find_persistent_root_volumes( vnfd, target_vdu, vdu_instantiation_volumes_list, disk_list @@ -1704,7 +1695,6 @@ class Ns(object): vim_details = yaml.safe_load(f"{vim_details_text}") for iface_index, interface in enumerate(existing_vdu["interfaces"]): - if "port-security-enabled" in interface: interface["port_security"] = interface.pop("port-security-enabled") @@ -3033,7 +3023,6 @@ class Ns(object): task_index += 1 break else: - for vdu_index, vdu in enumerate(db_vnfr["vdur"]): extra_dict["params"] = { "vim_vm_id": vdu["vim-id"], diff --git a/NG-RO/osm_ng_ro/ns_thread.py b/NG-RO/osm_ng_ro/ns_thread.py index 80f911d8..23622f71 100644 --- a/NG-RO/osm_ng_ro/ns_thread.py +++ b/NG-RO/osm_ng_ro/ns_thread.py @@ -1040,7 +1040,6 @@ class VimInteractionSdnNet(VimInteractionBase): return self.new(ro_task, task_create_index, None) def new(self, ro_task, task_index, task_depends): - task = ro_task["tasks"][task_index] task_id = task["task_id"] target_vim = self.my_vims[ro_task["target_id"]] @@ -2293,7 +2292,10 @@ class NsWorker(threading.Thread): ) if task["action"] == "DELETE": - (new_status, db_vim_info_update,) = self._delete_task( + ( + new_status, + db_vim_info_update, + ) = self._delete_task( ro_task, task_index, task_depends, db_ro_task_update ) new_status = ( @@ -2341,7 +2343,10 @@ class NsWorker(threading.Thread): else: refresh_at = ro_task["vim_info"]["refresh_at"] if refresh_at and refresh_at != -1 and now > refresh_at: - (new_status, db_vim_info_update,) = self.item2class[ + ( + new_status, + db_vim_info_update, + ) = self.item2class[ task["item"] ].refresh(ro_task) _update_refresh(new_status) diff --git a/NG-RO/osm_ng_ro/ro_main.py b/NG-RO/osm_ng_ro/ro_main.py index 86e839c6..47296dc3 100644 --- a/NG-RO/osm_ng_ro/ro_main.py +++ b/NG-RO/osm_ng_ro/ro_main.py @@ -214,7 +214,6 @@ class Server(object): } def _format_in(self, kwargs): - error_text = "" try: indata = None diff --git a/NG-RO/osm_ng_ro/tests/test_ns.py b/NG-RO/osm_ng_ro/tests/test_ns.py index d1ab0a46..d2fdc4dc 100644 --- a/NG-RO/osm_ng_ro/tests/test_ns.py +++ b/NG-RO/osm_ng_ro/tests/test_ns.py @@ -1815,7 +1815,6 @@ class TestNs(unittest.TestCase): self, epa_params, ): - target_flavor = {} indata = { "vnf": [ @@ -1842,7 +1841,6 @@ class TestNs(unittest.TestCase): self, epa_params, ): - target_flavor = { "no-target-flavor": "here", } @@ -1865,7 +1863,6 @@ class TestNs(unittest.TestCase): self, epa_params, ): - expected_result = { "find_params": { "flavor_data": { @@ -1910,7 +1907,6 @@ class TestNs(unittest.TestCase): self, epa_params, ): - expected_result = { "find_params": { "flavor_data": { @@ -2067,7 +2063,6 @@ class TestNs(unittest.TestCase): self, epa_params, ): - expected_result = { "find_params": { "flavor_data": { @@ -2132,7 +2127,6 @@ class TestNs(unittest.TestCase): self, epa_params, ): - kwargs = { "db": db, } @@ -2243,7 +2237,6 @@ class TestNs(unittest.TestCase): self, epa_params, ): - expected_result = { "find_params": { "flavor_data": { @@ -2308,7 +2301,6 @@ class TestNs(unittest.TestCase): self, epa_params, ): - kwargs = { "db": db, } @@ -3650,7 +3642,8 @@ class TestProcessVduParams(unittest.TestCase): self, mock_volume_keeping_required ): """Find persistent ordinary volume, volume id is not persistent_root_disk dict, - vim-volume-id is given as instantiation parameter but disk id is not matching.""" + vim-volume-id is given as instantiation parameter but disk id is not matching. + """ mock_volume_keeping_required.return_value = True vdu_instantiation_volumes_list = [ { diff --git a/NG-RO/osm_ng_ro/vim_admin.py b/NG-RO/osm_ng_ro/vim_admin.py index 3350d434..b6e34e11 100644 --- a/NG-RO/osm_ng_ro/vim_admin.py +++ b/NG-RO/osm_ng_ro/vim_admin.py @@ -39,7 +39,6 @@ class VimAdminException(Exception): class LockRenew: - renew_list = [] # ^ static method, common for all RO. Time ordered list of dictionaries with information of locks that needs to # be renewed. The time order is achieved as it is appended at the end diff --git a/RO-SDN-juniper_contrail/osm_rosdn_juniper_contrail/tests/test_sdn_asssist_juniper_contrail.py b/RO-SDN-juniper_contrail/osm_rosdn_juniper_contrail/tests/test_sdn_asssist_juniper_contrail.py index 8ef04e1b..144603a2 100644 --- a/RO-SDN-juniper_contrail/osm_rosdn_juniper_contrail/tests/test_sdn_asssist_juniper_contrail.py +++ b/RO-SDN-juniper_contrail/osm_rosdn_juniper_contrail/tests/test_sdn_asssist_juniper_contrail.py @@ -35,7 +35,6 @@ class TestJuniperContrail(unittest.TestCase): @patch("osm_rosdn_juniper_contrail.sdn_api.UnderlayApi") def test_juniper_contrail_sdn_with_ssl_cert(self, mock_underlay_api): - config = { "ca_cert": "/path/to/certfile", "project": "test_project", diff --git a/RO-VIM-aws/osm_rovim_aws/vimconn_aws.py b/RO-VIM-aws/osm_rovim_aws/vimconn_aws.py index f50893d9..393acba0 100644 --- a/RO-VIM-aws/osm_rovim_aws/vimconn_aws.py +++ b/RO-VIM-aws/osm_rovim_aws/vimconn_aws.py @@ -806,7 +806,6 @@ class vimconnector(vimconn.VimConnector): else: for index, subnet in enumerate(net_list): - net_intr = self.conn_vpc.create_network_interface( subnet_id=subnet.get("net_id"), groups=None, diff --git a/RO-VIM-azure/osm_rovim_azure/vimconn_azure.py b/RO-VIM-azure/osm_rovim_azure/vimconn_azure.py index d93ff5cd..bf4a3060 100755 --- a/RO-VIM-azure/osm_rovim_azure/vimconn_azure.py +++ b/RO-VIM-azure/osm_rovim_azure/vimconn_azure.py @@ -56,7 +56,6 @@ def find_in_list(the_list, condition_lambda): class vimconnector(vimconn.VimConnector): - # Translate azure provisioning state to OSM provision state # The first three ones are the transitional status once a user initiated action has been requested # Once the operation is complete, it will transition into the states Succeeded or Failed @@ -970,7 +969,6 @@ class vimconnector(vimconn.VimConnector): self._format_vimconn_exception(e) def _build_os_profile(self, vm_name, cloud_config, image_id): - # initial os_profile os_profile = {"computer_name": vm_name} @@ -1315,7 +1313,6 @@ class vimconnector(vimconn.VimConnector): self._format_vimconn_exception(e) def delete_inuse_nic(self, nic_name): - # Obtain nic data nic_data = self.conn_vnet.network_interfaces.get(self.resource_group, nic_name) @@ -1338,7 +1335,6 @@ class vimconnector(vimconn.VimConnector): # TODO - check if there is a public ip to delete and delete it if network_interfaces: - # Deallocate the vm async_vm_deallocate = ( self.conn_compute.virtual_machines.begin_deallocate( diff --git a/RO-VIM-gcp/osm_rovim_gcp/vimconn_gcp.py b/RO-VIM-gcp/osm_rovim_gcp/vimconn_gcp.py index 97acfe76..7e7f606d 100644 --- a/RO-VIM-gcp/osm_rovim_gcp/vimconn_gcp.py +++ b/RO-VIM-gcp/osm_rovim_gcp/vimconn_gcp.py @@ -37,7 +37,6 @@ if getenv("OSMRO_PDB_DEBUG"): class vimconnector(vimconn.VimConnector): - # Translate Google Cloud provisioning state to OSM provision state # The first three ones are the transitional status once a user initiated action has been requested # Once the operation is complete, it will transition into the states Succeeded or Failed @@ -303,7 +302,6 @@ class vimconnector(vimconn.VimConnector): self.logger.debug("create network name %s, ip_profile %s", net_name, ip_profile) try: - self.logger.debug("creating network_name: {}".format(net_name)) network = "projects/{}/global/networks/default".format(self.project) @@ -372,7 +370,6 @@ class vimconnector(vimconn.VimConnector): ) try: - self.logger.debug("creating subnet_name: {}".format(subnet_name)) subnetwork_body = { @@ -421,7 +418,6 @@ class vimconnector(vimconn.VimConnector): ) try: - if self.reload_client: self._reload_connection() @@ -501,7 +497,6 @@ class vimconnector(vimconn.VimConnector): self.logger.debug("Deleting network: {}".format(str(net_id))) try: - net_name = self._get_resource_name_from_resource_id(net_id) # Check associated VMs diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py index 3539cc5b..9faf98d4 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -1548,7 +1548,6 @@ class vimconnector(vimconn.VimConnector): return new_flavor.id except nvExceptions.Conflict as e: - if change_name_if_used and retry < max_retries: continue @@ -1892,7 +1891,6 @@ class vimconnector(vimconn.VimConnector): # For VF elif net["type"] == "VF" or net["type"] == "SR-IOV": - port_dict["binding:vnic_type"] = "direct" # VIO specific Changes @@ -2080,7 +2078,6 @@ class vimconnector(vimconn.VimConnector): key_id = "vim_volume_id" if "vim_volume_id" in disk.keys() else "vim_id" if disk.get(key_id): - block_device_mapping["vd" + chr(base_disk_index)] = disk[key_id] existing_vim_volumes.append({"id": disk[key_id]}) @@ -2160,7 +2157,6 @@ class vimconnector(vimconn.VimConnector): key_id = "vim_volume_id" if "vim_volume_id" in disk.keys() else "vim_id" if disk.get(key_id): - # Use existing persistent volume block_device_mapping["vd" + chr(base_disk_index)] = disk[key_id] existing_vim_volumes.append({"id": disk[key_id]}) @@ -2491,7 +2487,6 @@ class vimconnector(vimconn.VimConnector): # In case of RO in HA there can be conflicts, two RO trying to assign same floating IP, so retry # several times while not assigned: - free_floating_ip = self._get_free_floating_ip( server, floating_network ) @@ -2588,7 +2583,6 @@ class vimconnector(vimconn.VimConnector): self.neutron.update_port(port[0], port_update) except Exception: - raise vimconn.VimConnException( "It was not possible to disable port security for port {}".format( port[0] @@ -2895,7 +2889,6 @@ class vimconnector(vimconn.VimConnector): k_id (str): Port id in the VIM """ try: - port_dict = self.neutron.list_ports() existing_ports = [port["id"] for port in port_dict["ports"] if port_dict] @@ -2903,7 +2896,6 @@ class vimconnector(vimconn.VimConnector): self.neutron.delete_port(k_id) except Exception as e: - self.logger.error("Error deleting port: {}: {}".format(type(e).__name__, e)) def _delete_volumes_by_id_wth_cinder( @@ -2985,7 +2977,6 @@ class vimconnector(vimconn.VimConnector): k_item, k_id = self._get_item_name_id(k) if k_item == "volume": - unavailable_vol = self._delete_volumes_by_id_wth_cinder( k, k_id, volumes_to_hold, created_items ) @@ -2994,7 +2985,6 @@ class vimconnector(vimconn.VimConnector): keep_waiting = True elif k_item == "floating_ip": - self._delete_floating_ip_by_id(k, k_id, created_items) except Exception as e: @@ -3216,7 +3206,8 @@ class vimconnector(vimconn.VimConnector): def action_vminstance(self, vm_id, action_dict, created_items={}): """Send and action over a VM instance from VIM - Returns None or the console dict if the action was successfully sent to the VIM""" + Returns None or the console dict if the action was successfully sent to the VIM + """ self.logger.debug("Action over VM '%s': %s", vm_id, str(action_dict)) try: diff --git a/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py b/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py index 39033cf2..456db81d 100644 --- a/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py +++ b/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py @@ -829,7 +829,8 @@ class vimconnector(vimconn.VimConnector): def get_network(self, net_id): """Method obtains network details of net_id VIM network - Return a dict with the fields at filter_dict (see get_network_list) plus some VIM specific>}, ...]""" + Return a dict with the fields at filter_dict (see get_network_list) plus some VIM specific>}, ...] + """ try: _, vdc = self.get_vdc_details() vdc_id = vdc.get("id").split(":")[3] diff --git a/integration-tests/test_vimconn_gcp.py b/integration-tests/test_vimconn_gcp.py index ea9783bc..2285f216 100644 --- a/integration-tests/test_vimconn_gcp.py +++ b/integration-tests/test_vimconn_gcp.py @@ -35,7 +35,6 @@ __date__ = "$05-nov-2021 12:00:00$" class TestGCPOperations: - gcp_conn = None time_id = datetime.today().strftime("%Y%m%d%H%M%S") vim_id = "gcp-test-" + time_id diff --git a/releasenotes/notes/fixing_black_formatting-38523eb5ec59dae6.yaml b/releasenotes/notes/fixing_black_formatting-38523eb5ec59dae6.yaml new file mode 100644 index 00000000..a8c6c50e --- /dev/null +++ b/releasenotes/notes/fixing_black_formatting-38523eb5ec59dae6.yaml @@ -0,0 +1,20 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +fixes: + - | + Reformat files according to new black validation. -- 2.17.1