Ejemplo n.º 1
0
 /**
  * A comma-separated list that specifies the types of AWS resources for which AWS Config records
  * configuration changes (for example, <code>AWS::EC2::Instance</code> or <code>
  * AWS::CloudTrail::Trail</code>).
  *
  * <p>Before you can set this option to <code>true</code>, you must set the <code>allSupported
  * </code> option to <code>false</code>.
  *
  * <p>If you set this option to <code>true</code>, when AWS Config adds support for a new type of
  * resource, it will not record resources of that type unless you manually add that type to your
  * recording group.
  *
  * <p>For a list of valid <code>resourceTypes</code> values, see the <b>resourceType Value</b>
  * column in <a href=
  * "http://docs.aws.amazon.com/config/latest/developerguide/resource-config-reference.html#supported-resources"
  * >Supported AWS Resource Types</a>.
  *
  * @param resourceTypes A comma-separated list that specifies the types of AWS resources for which
  *     AWS Config records configuration changes (for example, <code>AWS::EC2::Instance</code> or
  *     <code>AWS::CloudTrail::Trail</code>).
  *     <p>Before you can set this option to <code>true</code>, you must set the <code>allSupported
  *     </code> option to <code>false</code>.
  *     <p>If you set this option to <code>true</code>, when AWS Config adds support for a new type
  *     of resource, it will not record resources of that type unless you manually add that type to
  *     your recording group.
  *     <p>For a list of valid <code>resourceTypes</code> values, see the <b>resourceType Value</b>
  *     column in <a href=
  *     "http://docs.aws.amazon.com/config/latest/developerguide/resource-config-reference.html#supported-resources"
  *     >Supported AWS Resource Types</a>.
  * @return Returns a reference to this object so that method calls can be chained together.
  * @see ResourceType
  */
 public RecordingGroup withResourceTypes(ResourceType... resourceTypes) {
   com.amazonaws.internal.SdkInternalList<String> resourceTypesCopy =
       new com.amazonaws.internal.SdkInternalList<String>(resourceTypes.length);
   for (ResourceType value : resourceTypes) {
     resourceTypesCopy.add(value.toString());
   }
   if (getResourceTypes() == null) {
     setResourceTypes(resourceTypesCopy);
   } else {
     getResourceTypes().addAll(resourceTypesCopy);
   }
   return this;
 }
Ejemplo n.º 2
0
  /**
   * Use this in place of valueOf.
   *
   * @param value real value
   * @return ResourceType corresponding to the value
   */
  public static ResourceType fromValue(String value) {
    if (value == null || "".equals(value)) {
      throw new IllegalArgumentException("Value cannot be null or empty!");
    }

    for (ResourceType enumEntry : ResourceType.values()) {
      if (enumEntry.toString().equals(value)) {
        return enumEntry;
      }
    }

    throw new IllegalArgumentException("Cannot create enum from " + value + " value!");
  }
  public static void main(String[] args) throws Exception {

    String version = System.getProperty("jboss.as.compare.version", null);
    String diff = System.getProperty("jboss.as.compare.different.versions", null);
    String type = System.getProperty("jboss.as.compare.type", null);

    if (version == null) {
      System.out.print("Enter legacy AS version: ");
      version = readInput(null);
    }
    System.out.println("Using target model: " + version);

    if (type == null) {
      System.out.print("Enter type [S](standalone)/H(host)/D(domain):");
      type = readInput("S");
    }
    final ResourceType resourceType;
    if (ResourceType.STANDALONE.toString().startsWith(type.toUpperCase())) {
      resourceType = ResourceType.STANDALONE;
    } else if (ResourceType.HOST.toString().startsWith(type.toUpperCase())) {
      resourceType = ResourceType.HOST;
    } else if (ResourceType.DOMAIN.toString().startsWith(type.toUpperCase())) {
      resourceType = ResourceType.DOMAIN;
    } else {
      throw new IllegalArgumentException("Could not determine type for: '" + type + "'");
    }

    if (diff == null) {
      System.out.print(
          "Report on differences in the model when the management versions are different? y/[n]: ");
      diff = readInput("n").toLowerCase();
    }
    boolean compareDifferentVersions;
    if (diff.equals("n")) {
      System.out.println(
          "Reporting on differences in the model when the management versions are different");
      compareDifferentVersions = false;
    } else if (diff.equals("y")) {
      System.out.println(
          "Not reporting on differences in the model when the management versions are different");
      compareDifferentVersions = true;
    } else {
      throw new IllegalArgumentException("Please enter 'y' or 'n'");
    }

    System.out.println("Loading legacy model versions for " + version + "....");
    ModelNode legacyModelVersions =
        Tools.loadModelNodeFromFile(
            new File(
                "target/test-classes/legacy-models/standalone-model-versions-" + version + ".dmr"));
    System.out.println("Loaded legacy model versions");

    System.out.println("Loading legacy resource descriptions for " + version + "....");
    ModelNode legacyResourceDefinitions =
        Tools.loadModelNodeFromFile(
            new File(
                "target/test-classes/legacy-models/"
                    + resourceType.toString().toLowerCase()
                    + "-resource-definition-"
                    + version
                    + ".dmr"));
    System.out.println("Loaded legacy resource descriptions");

    System.out.println("Loading model versions for currently running server...");
    ModelNode currentModelVersions = Tools.getCurrentModelVersions();
    System.out.println("Loaded current model versions");

    System.out.println("Loading resource descriptions for currently running server...");
    final ModelNode currentResourceDefinitions;
    if (resourceType == ResourceType.STANDALONE) {
      currentResourceDefinitions =
          Tools.getCurrentRunningResourceDefinition(PathAddress.EMPTY_ADDRESS);
    } else if (resourceType == ResourceType.DOMAIN) {
      currentResourceDefinitions = Tools.getCurrentRunningDomainResourceDefinition();
    } else {
      currentResourceDefinitions =
          Tools.getCurrentRunningResourceDefinition(
              PathAddress.pathAddress(PathElement.pathElement(HOST, "master")));
    }
    System.out.println("Loaded current resource descriptions");

    CompareModelVersionsUtil compareModelVersionsUtil =
        new CompareModelVersionsUtil(
            compareDifferentVersions,
            version,
            legacyModelVersions,
            legacyResourceDefinitions,
            currentModelVersions,
            currentResourceDefinitions);

    System.out.println("Starting comparison of the current....\n");
    compareModelVersionsUtil.compareModels();
    System.out.println("\nDone comparison!");
  }
Ejemplo n.º 4
0
 /**
  * The resource type of the related resource.
  *
  * @param resourceType The resource type of the related resource.
  * @return Returns a reference to this object so that method calls can be chained together.
  * @see ResourceType
  */
 public void setResourceType(ResourceType resourceType) {
   this.resourceType = resourceType.toString();
 }