if "vnet_name" in config:
self.vnet_name = config["vnet_name"]
+ # VNET_RESOURCE_GROUP
+ self.vnet_resource_group = config.get("vnet_resource_group")
+
# TODO - not used, do anything about it?
# public ssh key
self.pub_key = config.get("pub_key")
"""
try:
vnet = self.conn_vnet.virtual_networks.get(
- self.resource_group, self.vnet_name
+ self.vnet_resource_group or self.resource_group, self.vnet_name
)
self.vnet_address_space = vnet.address_space.address_prefixes[0]
self.vnet_id = vnet.id
self.logger.debug("create base vnet: %s", self.vnet_name)
self.conn_vnet.virtual_networks.begin_create_or_update(
- self.resource_group, self.vnet_name, vnet_params
+ self.vnet_resource_group or self.resource_group,
+ self.vnet_name,
+ vnet_params,
)
vnet = self.conn_vnet.virtual_networks.get(
- self.resource_group, self.vnet_name
+ self.vnet_resource_group or self.resource_group, self.vnet_name
)
self.vnet_id = vnet.id
except Exception as e:
self.logger.debug("creating subnet_name: {}".format(subnet_name))
async_creation = self.conn_vnet.subnets.begin_create_or_update(
- self.resource_group, self.vnet_name, subnet_name, subnet_params
+ self.vnet_resource_group or self.resource_group,
+ self.vnet_name,
+ subnet_name,
+ subnet_params,
)
async_creation.wait()
# TODO - do not wait here, check where it is used
Adds a prefix to the subnet_name with a number in case the indicated name is repeated
Checks subnets with the indicated name (without suffix) and adds a suffix with a number
"""
- all_subnets = self.conn_vnet.subnets.list(self.resource_group, self.vnet_name)
+ all_subnets = self.conn_vnet.subnets.list(
+ self.vnet_resource_group or self.resource_group, self.vnet_name
+ )
# Filter to subnets starting with the indicated name
subnets = list(
filter(lambda subnet: (subnet.name.startswith(subnet_name)), all_subnets)
location = self.region or self._get_location_from_resource_group(
self.resource_group
)
+
try:
net_ifz = {"location": location}
net_ip_config = {
self._reload_connection()
vnet = self.conn_vnet.virtual_networks.get(
- self.resource_group, self.vnet_name
+ self.vnet_resource_group or self.resource_group, self.vnet_name
)
subnet_list = []
def delete_network(self, net_id, created_items=None):
self.logger.debug(
- "deleting network {} - {}".format(self.resource_group, net_id)
+ "deleting network {} - {}".format(
+ self.vnet_resource_group or self.resource_group, net_id
+ )
)
self._reload_connection()
try:
# Obtain subnets ant try to delete nic first
subnet = self.conn_vnet.subnets.get(
- self.resource_group, self.vnet_name, res_name
+ self.vnet_resource_group or self.resource_group,
+ self.vnet_name,
+ res_name,
)
if not subnet:
raise vimconn.VimConnNotFoundException(
# Subnet API fails (CloudError: Azure Error: ResourceNotFound)
# Put the initial virtual_network API
async_delete = self.conn_vnet.subnets.begin_delete(
- self.resource_group, self.vnet_name, res_name
+ self.vnet_resource_group or self.resource_group,
+ self.vnet_name,
+ res_name,
)
async_delete.wait()
netName = self._get_net_name_from_resource_id(net_id)
resName = self._get_resource_name_from_resource_id(net_id)
- net = self.conn_vnet.subnets.get(self.resource_group, netName, resName)
+ net = self.conn_vnet.subnets.get(
+ self.vnet_resource_group or self.resource_group, netName, resName
+ )
out_nets[net_id] = {
"status": self.provision_state2osm[net.provisioning_state],
logger.debug("List networks")
network_list = azure.get_network_list({"name": "internal"})
logger.debug("Network_list: {}".format(network_list))
-
+
logger.debug("Show machine isabelvm")
vmachine = azure.get_vminstance( ("/subscriptions/5c1a2458-dfde-4adf-a4e3-08fa0e21d171/resourceGroups/{}"
"/providers/Microsoft.Compute/virtualMachines/isabelVM"
"/Skus/18.04-LTS/Versions/18.04.201809110")
"""
"""
-
+
network_id = ("subscriptions/5c1a2458-dfde-4adf-a4e3-08fa0e21d171/resourceGroups/{}
"/providers/Microsoft.Network/virtualNetworks/osm_vnet/subnets/internal"
).format(test_params["resource_group"])
--- /dev/null
+#######################################################################################
+# 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:
+ - |
+ Fixing bug 1861 - Supporting of a VNET for a different resource group in
+ Azure Connector.