def test_delete_subnet(self): ctx = self.mock_ctx("testdeletesubnet", cdir="10.0.3.0/24") ctx.logger.info("BEGIN test_delete_subnet") current_ctx.set(ctx=ctx) status_code = subnet.create(ctx=ctx) ctx.logger.debug("status_code =" + str(status_code)) self.assertTrue(bool((status_code == 200) or (status_code == 201))) current_ctx.set(ctx=ctx) utils.wait_status(ctx, "subnet", constants.SUCCEEDED, timeout=600) current_ctx.set(ctx=ctx) ctx.logger.info("create subnet with deletable propertie set to False") ctx.node.properties[constants.DELETABLE_KEY] = False ctx.logger.info("not delete subnet") self.assertEqual(0, subnet.delete(ctx=ctx)) current_ctx.set(ctx=ctx) ctx.logger.info("Set deletable propertie to True") ctx.node.properties[constants.DELETABLE_KEY] = True status_code = subnet.delete(ctx=ctx) ctx.logger.debug("status_code =" + str(status_code)) self.assertTrue(bool((status_code == 202) or (status_code == 204))) try: current_ctx.set(ctx=ctx) utils.wait_status(ctx, "subnet", "waiting for exception", timeout=600) except utils.WindowsAzureError: pass ctx.logger.info("END test_delete_subnet")
def test_connect_security_group_subnet(self): ctx = self.mock_ctx("testaddsecugroupsubnet", cdir="10.0.5.0/24") ctx.logger.info("BEGIN test_connect_security_group_subnet") ctx.logger.info("create security_group") self.assertEqual(201, security_group.create(ctx=ctx)) ctx.logger.debug( "security_group_id = {}".format(ctx.instance.runtime_properties[constants.SECURITY_GROUP_ID_KEY]) ) current_ctx.set(ctx=ctx) utils.wait_status(ctx, "security_group", constants.SUCCEEDED, timeout=900) ctx.instance.relationships.append( test_mockcontext.MockRelationshipContext( node_id="test", runtime_properties={ constants.SECURITY_GROUP_ID_KEY: ctx.instance.runtime_properties[constants.SECURITY_GROUP_ID_KEY] }, type=constants.SUBNET_CONNECTED_TO_SECURITY_GROUP, ) ) current_ctx.set(ctx=ctx) status_code = subnet.create(ctx=ctx) ctx.logger.debug("status_code = " + str(status_code)) self.assertTrue(bool((status_code == 200) or (status_code == 201))) current_ctx.set(ctx=ctx) utils.wait_status(ctx, "subnet", constants.SUCCEEDED, timeout=600) ctx.logger.info("test subnet is connected to a security_group") current_ctx.set(ctx=ctx) json = subnet.get_json_from_azure(ctx=ctx) self.assertIsNotNone(json["properties"]["networkSecurityGroup"]) self.assertEqual( str(json["properties"]["networkSecurityGroup"]["id"]).lower(), str(ctx.instance.runtime_properties[constants.SECURITY_GROUP_ID_KEY]).lower(), ) current_ctx.set(ctx=ctx) status_code = subnet.delete(ctx=ctx) ctx.logger.debug("status_code = " + str(status_code)) self.assertTrue(bool((status_code == 202) or (status_code == 204))) try: current_ctx.set(ctx=ctx) utils.wait_status(ctx, "subnet", "waiting for exception", timeout=600) except utils.WindowsAzureError: pass ctx.logger.info("delete security_group") self.assertEqual(202, security_group.delete(ctx=ctx)) ctx.logger.info("END test_connect_security_group_subnet")
def test_conflict_subnet(self): ctx = self.mock_ctx("testconflictsubnet", cdir="10.0.4.0/24") ctx.logger.info("BEGIN test_conflict_subnet") current_ctx.set(ctx=ctx) status_code = subnet.create(ctx=ctx) ctx.logger.debug("status_code =" + str(status_code)) self.assertTrue(bool((status_code == 200) or (status_code == 201))) current_ctx.set(ctx=ctx) utils.wait_status(ctx, "subnet", constants.SUCCEEDED, timeout=600) ctx.logger.info("Conflict Creating Subnet") current_ctx.set(ctx=ctx) self.assertNotEqual(201, subnet.create(ctx=ctx)) ctx.logger.info("Conflict detected") current_ctx.set(ctx=ctx) status_code = subnet.delete(ctx=ctx) ctx.logger.debug("status_code =" + str(status_code)) self.assertTrue(bool((status_code == 202) or (status_code == 204))) try: current_ctx.set(ctx=ctx) utils.wait_status(ctx, "subnet", "waiting for exception", timeout=600) except utils.WindowsAzureError: pass ctx.logger.info("Subnet Deleted") current_ctx.set(ctx=ctx) status_code = subnet.delete(ctx=ctx) ctx.logger.debug("status_code =" + str(status_code)) self.assertTrue(bool((status_code == 202) or (status_code == 204))) try: current_ctx.set(ctx=ctx) utils.wait_status(ctx, "subnet", "waiting for exception", timeout=600) except utils.WindowsAzureError: pass ctx.logger.info("Virtual subnet Deleted") ctx.logger.info("END test_conflict_subnet")