@AfterSuite(alwaysRun = true)
 @Parameters("cleanUp")
 public void cleanUp(@Optional("true") boolean cleanUp) throws Exception {
   if (isCleanUpNeeded(cleanUp)) {
     CloudbreakClient cloudbreakClient =
         itContext.getContextParam(
             CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class);
     String stackId = itContext.getCleanUpParameter(CloudbreakITContextConstants.STACK_ID);
     cleanUpService.deleteStackAndWait(cloudbreakClient, stackId);
     List<InstanceGroup> instanceGroups =
         itContext.getCleanUpParameter(CloudbreakITContextConstants.TEMPLATE_ID, List.class);
     if (instanceGroups != null && !instanceGroups.isEmpty()) {
       Set<String> deletedTemplates = new HashSet<>();
       for (InstanceGroup ig : instanceGroups) {
         if (!deletedTemplates.contains(ig.getTemplateId())) {
           cleanUpService.deleteTemplate(cloudbreakClient, ig.getTemplateId());
           deletedTemplates.add(ig.getTemplateId());
         }
       }
     }
     Set<Long> recipeIds =
         itContext.getContextParam(CloudbreakITContextConstants.RECIPE_ID, Set.class);
     if (recipeIds != null) {
       for (Long recipeId : recipeIds) {
         cleanUpService.deleteRecipe(cloudbreakClient, recipeId);
       }
     }
     cleanUpService.deleteCredential(
         cloudbreakClient,
         itContext.getCleanUpParameter(CloudbreakITContextConstants.CREDENTIAL_ID));
     cleanUpService.deleteBlueprint(
         cloudbreakClient,
         itContext.getCleanUpParameter(CloudbreakITContextConstants.BLUEPRINT_ID));
     cleanUpService.deleteNetwork(
         cloudbreakClient, itContext.getCleanUpParameter(CloudbreakITContextConstants.NETWORK_ID));
     cleanUpService.deleteSecurityGroup(
         cloudbreakClient,
         itContext.getCleanUpParameter(CloudbreakITContextConstants.SECURITY_GROUP_ID));
   }
 }
  @BeforeSuite(dependsOnMethods = "initContext")
  @Parameters({
    "cloudbreakServer",
    "cloudProvider",
    "credentialName",
    "instanceGroups",
    "hostGroups",
    "blueprintName",
    "stackName",
    "networkName",
    "securityGroupName"
  })
  public void initCloudbreakSuite(
      @Optional("") String cloudbreakServer,
      @Optional("") String cloudProvider,
      @Optional("") String credentialName,
      @Optional("") String instanceGroups,
      @Optional("") String hostGroups,
      @Optional("") String blueprintName,
      @Optional("") String stackName,
      @Optional("") String networkName,
      @Optional("") String securityGroupName)
      throws Exception {
    cloudbreakServer =
        StringUtils.hasLength(cloudbreakServer) ? cloudbreakServer : defaultCloudbreakServer;
    itContext.putContextParam(
        CloudbreakITContextConstants.SKIP_REMAINING_SUITETEST_AFTER_ONE_FAILED,
        skipRemainingSuiteTestsAfterOneFailed);
    itContext.putContextParam(CloudbreakITContextConstants.CLOUDBREAK_SERVER, cloudbreakServer);
    String identity = itContext.getContextParam(IntegrationTestContext.IDENTITY_URL);
    String user = itContext.getContextParam(IntegrationTestContext.AUTH_USER);
    String password = itContext.getContextParam(IntegrationTestContext.AUTH_PASSWORD);

    CloudbreakClient cloudbreakClient =
        new CloudbreakClient.CloudbreakClientBuilder(cloudbreakServer, identity, "cloudbreak_shell")
            .withCertificateValidation(false)
            .withDebug(true)
            .withCredential(user, password)
            .build();
    itContext.putContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, cloudbreakClient);
    if (cleanUpBeforeStart) {
      cleanUpService.deleteTestStacksAndResources(cloudbreakClient);
    }
    putBlueprintToContextIfExist(
        itContext
            .getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class)
            .blueprintEndpoint(),
        blueprintName);
    putNetworkToContext(
        itContext
            .getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class)
            .networkEndpoint(),
        cloudProvider,
        networkName);
    putSecurityGroupToContext(
        itContext
            .getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class)
            .securityGroupEndpoint(),
        securityGroupName);
    putCredentialToContext(
        itContext
            .getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class)
            .credentialEndpoint(),
        cloudProvider,
        credentialName);
    putStackToContextIfExist(
        itContext
            .getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class)
            .stackEndpoint(),
        stackName);
    if (StringUtils.hasLength(instanceGroups)) {
      List<String[]> instanceGroupStrings =
          templateAdditionHelper.parseCommaSeparatedRows(instanceGroups);
      itContext.putContextParam(
          CloudbreakITContextConstants.TEMPLATE_ID,
          createInstanceGroups(
              itContext
                  .getContextParam(
                      CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class)
                  .templateEndpoint(),
              instanceGroupStrings));
    }
    if (StringUtils.hasLength(hostGroups)) {
      List<String[]> hostGroupStrings = templateAdditionHelper.parseCommaSeparatedRows(hostGroups);
      itContext.putContextParam(
          CloudbreakITContextConstants.HOSTGROUP_ID, createHostGroups(hostGroupStrings));
    }
  }