public void test() {
   InputStream is = getClass().getResourceAsStream("/firewallService.xml");
   Injector injector = Guice.createInjector(new SaxParserModule());
   Factory factory = injector.getInstance(ParseSax.Factory.class);
   FirewallService result =
       factory.create(injector.getInstance(FirewallServiceHandler.class)).parse(is);
   assertEquals(result.isEnabled(), false);
   assertEquals(
       result.getFirewallRules(),
       ImmutableSet.<FirewallRule>of(
           FirewallRule.builder()
               .firewallType("SERVER_TIER_FIREWALL")
               .isEnabled(false)
               .source("internet")
               .destination("VM Tier01")
               .port("22")
               .protocol("Tcp")
               .policy("allow")
               .description("Server Tier Firewall Rule")
               .isLogged(false)
               .build(),
           FirewallRule.builder()
               .firewallType("SERVER_TIER_FIREWALL")
               .isEnabled(true)
               .source("VM Tier03")
               .destination("VM Tier03")
               .protocol("Icmp-ping")
               .policy("allow")
               .description("Server Tier Firewall Rule")
               .isLogged(false)
               .build()));
 }
Exemplo n.º 2
0
  public void testHostingDotCom() {
    InputStream is = getClass().getResourceAsStream("/vdc-hosting.xml");
    Injector injector = Guice.createInjector(new SaxParserModule());
    Factory factory = injector.getInstance(ParseSax.Factory.class);
    VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
    assertEquals(result.getName(), "vDC Name");
    assertEquals(
        result.getHref(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"));
    assertEquals(result.getDescription(), "vDC Name");
    assertEquals(result.getStorageCapacity(), new Capacity("bytes * 10^9", 0, 0, 40960, 0));
    assertEquals(result.getCpuCapacity(), new Capacity("hz * 10^6", 0, 0, 2400, 0));
    assertEquals(result.getMemoryCapacity(), new Capacity("bytes * 10^9", 0, 0, 2, 0));
    assertEquals(result.getVmQuota(), 0);
    assertEquals(
        result.getResourceEntities(),
        new ImmutableMap.Builder<String, ReferenceType>()
            .put(
                "Plesk (Linux) 64-bit Template",
                new ReferenceTypeImpl(
                    "Plesk (Linux) 64-bit Template",
                    "application/vnd.vmware.vcloud.vAppTemplate+xml",
                    URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/1")))
            .put(
                "Windows 2008 Datacenter 64 Bit Template",
                new ReferenceTypeImpl(
                    "Windows 2008 Datacenter 64 Bit Template",
                    "application/vnd.vmware.vcloud.vAppTemplate+xml",
                    URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")))
            .put(
                "Cent OS 64 Bit Template",
                new ReferenceTypeImpl(
                    "Cent OS 64 Bit Template",
                    "application/vnd.vmware.vcloud.vAppTemplate+xml",
                    URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3")))
            .put(
                "cPanel (Linux) 64 Bit Template",
                new ReferenceTypeImpl(
                    "cPanel (Linux) 64 Bit Template",
                    "application/vnd.vmware.vcloud.vAppTemplate+xml",
                    URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/4")))
            .put(
                "188849-1",
                new ReferenceTypeImpl(
                    "188849-1",
                    "application/vnd.vmware.vcloud.vApp+xml",
                    URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")))
            .put(
                "188849-2",
                new ReferenceTypeImpl(
                    "188849-2",
                    "application/vnd.vmware.vcloud.vApp+xml",
                    URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-2")))
            .build());

    assertEquals(result.getAvailableNetworks(), ImmutableMap.<String, ReferenceType>of());
  }
Exemplo n.º 3
0
 @Test(expectedExceptions = NoSuchElementException.class)
 public void testGracefulWhenVDCIsNotLocation() {
   Location location =
       new LocationBuilder()
           .id("https://1.1.1.1/api/v1.0/vdc/11111")
           .description("description")
           .scope(LocationScope.PROVIDER)
           .build();
   Injector injector = createInjectorWithLocation(location);
   InputStream is = getClass().getResourceAsStream("/vapp-pool.xml");
   Factory factory = injector.getInstance(ParseSax.Factory.class);
   VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
   VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
   NodeMetadata node = converter.apply(result);
   assertEquals(node.getLocation(), location);
 }
Exemplo n.º 4
0
 public void testGracefulWhenNoIPs() {
   Location location =
       new LocationBuilder()
           .id("https://1.1.1.1/api/v1.0/vdc/1")
           .description("description")
           .scope(LocationScope.PROVIDER)
           .build();
   Injector injector = createInjectorWithLocation(location);
   InputStream is = getClass().getResourceAsStream("/vapp-none.xml");
   Factory factory = injector.getInstance(ParseSax.Factory.class);
   VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
   VAppToNodeMetadata converter = injector.getInstance(VAppToNodeMetadata.class);
   NodeMetadata node = converter.apply(result);
   assertEquals(node.getLocation(), location);
   assertEquals(node.getPrivateAddresses(), ImmutableSet.of());
   assertEquals(node.getPublicAddresses(), ImmutableSet.of());
 }
  public void testIsolated() {
    InputStream is = getClass().getResourceAsStream("/orgnetwork-isolated.xml");
    Injector injector = Guice.createInjector(new SaxParserModule());
    Factory factory = injector.getInstance(ParseSax.Factory.class);
    OrgNetwork result = factory.create(injector.getInstance(OrgNetworkHandler.class)).parse(is);
    assertEquals(result.getName(), "isolation01");
    assertEquals(
        result.getHref(),
        URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/990419644"));
    assertEquals(result.getType(), "application/vnd.vmware.vcloud.network+xml");
    assertEquals(
        result.getOrg(),
        new ReferenceTypeImpl(
            null,
            VCloudMediaType.ORG_XML,
            URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
    assertEquals(result.getDescription(), null);
    assertEquals(result.getTasks(), ImmutableList.of());
    assert result.getConfiguration() != null;

    assertEquals(
        result.getConfiguration().getIpScope(),
        new IpScope(
            false,
            "192.168.15.1",
            "255.255.255.0",
            "23.172.173.113",
            null,
            null,
            ImmutableSet.<IpRange>of(new IpRange("192.168.15.100", "192.168.15.199")),
            ImmutableSet.<String>of()));
    assertEquals(result.getConfiguration().getParentNetwork(), null);
    assertEquals(result.getConfiguration().getFenceMode(), FenceMode.ISOLATED);
    assert result.getConfiguration().getFeatures() != null;

    assertEquals(
        result.getConfiguration().getFeatures().getDhcpService(),
        new DhcpService(false, 3600, 7200, new IpRange("192.168.15.2", "192.168.15.99")));
    assertEquals(result.getConfiguration().getFeatures().getFirewallService(), null);
    assertEquals(result.getConfiguration().getFeatures().getNatService(), null);

    assertEquals(result.getNetworkPool(), null);
    assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet.<String>of());
  }
Exemplo n.º 6
0
 public void testVCloud1_0() {
   InputStream is = getClass().getResourceAsStream("/vdc-1.0.xml");
   Injector injector = Guice.createInjector(new SaxParserModule());
   Factory factory = injector.getInstance(ParseSax.Factory.class);
   VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
   assertEquals(result.getName(), "Jclouds-Commit-compG1xstorA01");
   assertEquals(
       result.getHref(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1014839439"));
   assertEquals(result.getType(), "application/vnd.vmware.vcloud.vdc+xml");
   assertEquals(result.getStatus(), VDCStatus.READY);
   assertEquals(
       result.getOrg(),
       new ReferenceTypeImpl(
           null,
           VCloudMediaType.ORG_XML,
           URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
   assertEquals(result.getDescription(), null);
   assertEquals(result.getTasks(), ImmutableList.of());
   assertEquals(result.getAllocationModel(), AllocationModel.ALLOCATION_POOL);
   assertEquals(result.getStorageCapacity(), new Capacity("MB", 1024000, 1024000, 0, 0));
   assertEquals(result.getCpuCapacity(), new Capacity("MHz", 20000, 20000, 0, 0));
   assertEquals(result.getMemoryCapacity(), new Capacity("MB", 30720, 30720, 0, 0));
   assertEquals(result.getResourceEntities(), ImmutableMap.<String, ReferenceType>of());
   assertEquals(
       result.getAvailableNetworks(),
       ImmutableMap.of(
           "isolation01",
           new ReferenceTypeImpl(
               "isolation01",
               "application/vnd.vmware.vcloud.network+xml",
               URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/990419644")),
           "internet01",
           new ReferenceTypeImpl(
               "internet01",
               "application/vnd.vmware.vcloud.network+xml",
               URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/758634723"))));
   assertEquals(result.getNicQuota(), 0);
   assertEquals(result.getNetworkQuota(), 100);
   assertEquals(result.getVmQuota(), 50);
   assert result.isEnabled();
 }
  public void testBridged() {
    InputStream is = getClass().getResourceAsStream("/orgnetwork-bridged.xml");
    Injector injector = Guice.createInjector(new SaxParserModule());
    Factory factory = injector.getInstance(ParseSax.Factory.class);
    OrgNetwork result = factory.create(injector.getInstance(OrgNetworkHandler.class)).parse(is);
    assertEquals(result.getName(), "internet01");
    assertEquals(
        result.getHref(),
        URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/758634723"));
    assertEquals(result.getType(), "application/vnd.vmware.vcloud.network+xml");
    assertEquals(
        result.getOrg(),
        new ReferenceTypeImpl(
            null,
            VCloudMediaType.ORG_XML,
            URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
    assertEquals(result.getDescription(), null);
    assertEquals(result.getTasks(), ImmutableList.of());
    assert result.getConfiguration() != null;

    assertEquals(
        result.getConfiguration().getIpScope(),
        new IpScope(
            true,
            "174.47.101.161",
            "255.255.255.224",
            "24.172.173.113",
            null,
            null,
            ImmutableSet.<IpRange>of(new IpRange("174.47.101.164", "174.47.101.190")),
            ImmutableSet.<String>of()));
    assertEquals(result.getConfiguration().getParentNetwork(), null);
    assertEquals(result.getConfiguration().getFenceMode(), FenceMode.BRIDGED);
    assert result.getConfiguration().getFeatures() == null;
    assertEquals(result.getNetworkPool(), null);
    assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet.<String>of());
  }
Exemplo n.º 8
0
 public void testTerremark() {
   InputStream is = getClass().getResourceAsStream("/vdc.xml");
   Injector injector = Guice.createInjector(new SaxParserModule());
   Factory factory = injector.getInstance(ParseSax.Factory.class);
   VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
   assertEquals(result.getName(), "Miami Environment 1");
   assertEquals(
       result.getHref(),
       URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"));
   assertEquals(result.getDescription(), null);
   assertEquals(result.getStorageCapacity(), new Capacity("bytes * 10^9", 100, 0, 8, 0));
   assertEquals(result.getCpuCapacity(), new Capacity("hz * 10^6", 5000, 0, 0, 0));
   assertEquals(result.getMemoryCapacity(), new Capacity("bytes * 2^20", 10240, 0, 0, 0));
   assertEquals(result.getVmQuota(), 0);
   assertEquals(
       result.getResourceEntities(),
       ImmutableMap.<String, ReferenceType>of(
           "adriantest",
           new ReferenceTypeImpl(
               "adriantest",
               VCloudMediaType.VAPP_XML,
               URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15124")),
           "centos-53",
           new ReferenceTypeImpl(
               "centos-53",
               VCloudMediaType.VAPP_XML,
               URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15120"))));
   assertEquals(
       result.getAvailableNetworks(),
       ImmutableMap.of(
           "10.114.34.128/26",
           new ReferenceTypeImpl(
               "10.114.34.128/26",
               "application/vnd.vmware.vcloud.network+xml",
               URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"))));
 }