gpt4 book ai didi

org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName.fromZoneAndName()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 23:17:31 27 4
gpt4 key购买 nike

本文整理了Java中org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName.fromZoneAndName()方法的一些代码示例,展示了ZoneAndName.fromZoneAndName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneAndName.fromZoneAndName()方法的具体详情如下:
包路径:org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName
类名称:ZoneAndName
方法名:fromZoneAndName

ZoneAndName.fromZoneAndName介绍

暂无

代码示例

代码示例来源:origin: io.cloudsoft.jclouds.api/openstack-nova

@Override
  public boolean apply(String zone) {
   AtomicReference<ZoneAndName> securityGroupInZoneRef = Atomics.newReference(ZoneAndName.fromZoneAndName(zone, groupName));
   return returnSecurityGroupExistsInZone.apply(securityGroupInZoneRef);
  }
};

代码示例来源:origin: jclouds/legacy-jclouds

private void cleanupOrphanedKeyPairsInZone(Set<String> groups, String zoneId) {
 Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
 if (keyPairApi.isPresent()) {
   for (String group : groups) {
    for (KeyPair pair : keyPairApi.get().list().filter(nameMatches(namingConvention.create().containsGroup(group)))) {
      ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
      logger.debug(">> deleting keypair(%s)", zoneAndName);
      keyPairApi.get().delete(pair.getName());
      // TODO: test this clear happens
      keyPairCache.invalidate(zoneAndName);
      logger.debug("<< deleted keypair(%s)", zoneAndName);
    }
    keyPairCache.invalidate(ZoneAndName.fromZoneAndName(zoneId,
         namingConvention.create().sharedNameForGroup(group)));
   }
 }
}

代码示例来源:origin: io.cloudsoft.jclouds.api/openstack-nova

private void cleanupOrphanedKeyPairsInZone(Set<String> groups, String zoneId) {
 Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
 if (keyPairApi.isPresent()) {
   for (String group : groups) {
    for (KeyPair pair : keyPairApi.get().list().filter(nameMatches(namingConvention.create().containsGroup(group)))) {
      ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
      logger.debug(">> deleting keypair(%s)", zoneAndName);
      keyPairApi.get().delete(pair.getName());
      // TODO: test this clear happens
      keyPairCache.invalidate(zoneAndName);
      logger.debug("<< deleted keypair(%s)", zoneAndName);
    }
    keyPairCache.invalidate(ZoneAndName.fromZoneAndName(zoneId,
         namingConvention.create().sharedNameForGroup(group)));
   }
 }
}

代码示例来源:origin: org.jclouds.api/openstack-nova

private void cleanupOrphanedKeyPairsInZone(Set<String> groups, String zoneId) {
 Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
 if (keyPairApi.isPresent()) {
   for (String group : groups) {
    for (KeyPair pair : keyPairApi.get().list().filter(nameMatches(namingConvention.create().containsGroup(group)))) {
      ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
      logger.debug(">> deleting keypair(%s)", zoneAndName);
      keyPairApi.get().delete(pair.getName());
      // TODO: test this clear happens
      keyPairCache.invalidate(zoneAndName);
      logger.debug("<< deleted keypair(%s)", zoneAndName);
    }
    keyPairCache.invalidate(ZoneAndName.fromZoneAndName(zoneId,
         namingConvention.create().sharedNameForGroup(group)));
   }
 }
}

代码示例来源:origin: jclouds/legacy-jclouds

private void cleanupOrphanedSecurityGroupsInZone(Set<String> groups, String zoneId) {
 Optional<? extends SecurityGroupApi> securityGroupApi = novaApi.getSecurityGroupExtensionForZone(zoneId);
 if (securityGroupApi.isPresent()) {
   for (String group : groups) {
    for (SecurityGroup securityGroup : Iterables.filter(securityGroupApi.get().list(),
         SecurityGroupPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
      ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, securityGroup.getName());
      logger.debug(">> deleting securityGroup(%s)", zoneAndName);
      securityGroupApi.get().delete(securityGroup.getId());
      // TODO: test this clear happens
      securityGroupMap.invalidate(zoneAndName);
      logger.debug("<< deleted securityGroup(%s)", zoneAndName);
    }
   }
 }
}

代码示例来源:origin: io.cloudsoft.jclouds.api/openstack-nova

private void cleanupOrphanedSecurityGroupsInZone(Set<String> groups, String zoneId) {
 Optional<? extends SecurityGroupApi> securityGroupApi = novaApi.getSecurityGroupExtensionForZone(zoneId);
 if (securityGroupApi.isPresent()) {
   for (String group : groups) {
    for (SecurityGroup securityGroup : Iterables.filter(securityGroupApi.get().list(),
         SecurityGroupPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
      ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, securityGroup.getName());
      logger.debug(">> deleting securityGroup(%s)", zoneAndName);
      securityGroupApi.get().delete(securityGroup.getId());
      // TODO: test this clear happens
      securityGroupMap.invalidate(zoneAndName);
      logger.debug("<< deleted securityGroup(%s)", zoneAndName);
    }
   }
 }
}

代码示例来源:origin: org.jclouds.api/openstack-nova

private void cleanupOrphanedSecurityGroupsInZone(Set<String> groups, String zoneId) {
 Optional<? extends SecurityGroupApi> securityGroupApi = novaApi.getSecurityGroupExtensionForZone(zoneId);
 if (securityGroupApi.isPresent()) {
   for (String group : groups) {
    for (SecurityGroup securityGroup : Iterables.filter(securityGroupApi.get().list(),
         SecurityGroupPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
      ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, securityGroup.getName());
      logger.debug(">> deleting securityGroup(%s)", zoneAndName);
      securityGroupApi.get().delete(securityGroup.getId());
      // TODO: test this clear happens
      securityGroupMap.invalidate(zoneAndName);
      logger.debug("<< deleted securityGroup(%s)", zoneAndName);
    }
   }
 }
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test(expectedExceptions = IllegalStateException.class)
public void testWhenFoundPredicateMustUpdateAtomicReference() throws Exception {
 Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysTrue();
 ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");
 Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {
   @Override
   public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
    fail();
    return null;
   }
 };
 FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
      returnSecurityGroupExistsInZone, groupCreator);
 parser.load(input);
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test
public void testWhenFoundReturnsSecurityGroupFromAtomicReferenceValueUpdatedDuringPredicateCheck() throws Exception {
 final SecurityGroupInZone securityGroupInZone = createMock(SecurityGroupInZone.class);
 Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = new Predicate<AtomicReference<ZoneAndName>>(){
   @Override
   public boolean apply(AtomicReference<ZoneAndName> input) {
    input.set(securityGroupInZone);
    return true;
   }
    };
 ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");
 Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {
   @Override
   public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
    fail();
    return null;
   }
 };
 FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
      returnSecurityGroupExistsInZone, groupCreator);
 assertEquals(parser.load(input), securityGroupInZone);
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test
public void testApply() throws UnknownHostException {
 final NovaApi api = createMock(NovaApi.class);
 KeyPairApi keyApi = createMock(KeyPairApi.class);
 KeyPair pair = createMock(KeyPair.class);
 Optional optKeyApi = Optional.of(keyApi);
 
 expect(api.getKeyPairExtensionForZone("zone")).andReturn(optKeyApi).atLeastOnce();
 expect(keyApi.create("group-1")).andReturn(pair);
 replay(api, keyApi);
 CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
   @Override
   protected void configure() {
    bind(new TypeLiteral<Supplier<String>>() {
    }).toInstance(Suppliers.ofInstance("1"));
    bind(NovaApi.class).toInstance(api);
   }
 }).getInstance(CreateUniqueKeyPair.class);
 assertEquals(parser.load(ZoneAndName.fromZoneAndName("zone", "group")), pair);
 verify(api, keyApi);
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test
public void testApplyWithIllegalStateException() throws UnknownHostException {
 final NovaApi api = createMock(NovaApi.class);
 KeyPairApi keyApi = createMock(KeyPairApi.class);
 @SuppressWarnings("unchecked")
 final Supplier<String> uniqueIdSupplier = createMock(Supplier.class);
 KeyPair pair = createMock(KeyPair.class);
 expect(api.getKeyPairExtensionForZone("zone")).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();
 expect(uniqueIdSupplier.get()).andReturn("1");
 expect(keyApi.create("group-1")).andThrow(new IllegalStateException());
 expect(uniqueIdSupplier.get()).andReturn("2");
 expect(keyApi.create("group-2")).andReturn(pair);
 replay(api, keyApi, uniqueIdSupplier);
 CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
   @Override
   protected void configure() {
    bind(new TypeLiteral<Supplier<String>>() {
    }).toInstance(uniqueIdSupplier);
    bind(NovaApi.class).toInstance(api);
   }
 }).getInstance(CreateUniqueKeyPair.class);
 assertEquals(parser.load(ZoneAndName.fromZoneAndName("zone", "group")), pair);
 verify(api, keyApi, uniqueIdSupplier);
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test(expectedExceptions = IllegalStateException.class)
  public void testWhenNotFoundInputMustBeZoneSecurityGroupNameAndPorts() throws Exception {
   Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysFalse();

   ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");

   Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {

     @Override
     public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
      fail();
      return null;
     }

   };

   FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
        returnSecurityGroupExistsInZone, groupCreator);

   parser.load(input);

  }
}

代码示例来源:origin: io.cloudsoft.jclouds.api/openstack-nova

@Override
public IpPermission apply(SecurityGroupRule rule) {
 IpPermission.Builder builder = IpPermission.builder();
 builder.ipProtocol(rule.getIpProtocol());
 builder.fromPort(rule.getFromPort());
 builder.toPort(rule.getToPort());
 if (rule.getGroup() != null) {
   String zone = getFirst(filter(locationIndex.get().keySet(), isSecurityGroupInZone(rule.getGroup().getName())),
       null);
   if (zone != null) {
    SecurityGroupInZone group = groupMap.getUnchecked(ZoneAndName.fromZoneAndName(zone, rule.getGroup().getName()));
    builder.groupId(zone + "/" + group.getSecurityGroup().getId());
   }
 }
 if (rule.getIpRange() != null)
   builder.cidrBlock(rule.getIpRange());
 
 return builder.build();
}

代码示例来源:origin: io.cloudsoft.jclouds.api/openstack-nova

@Override
public ZoneAndName apply(NodeMetadata input) {
  String zoneId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation()
      .getParent().getId() : input.getLocation().getId();
  return ZoneAndName.fromZoneAndName(zoneId, input.getGroup());
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
public ZoneAndName apply(NodeMetadata input) {
  String zoneId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation()
      .getParent().getId() : input.getLocation().getId();
  return ZoneAndName.fromZoneAndName(zoneId, input.getGroup());
}

代码示例来源:origin: org.jclouds.api/openstack-nova

@Override
public ZoneAndName apply(NodeMetadata input) {
  String zoneId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation()
      .getParent().getId() : input.getLocation().getId();
  return ZoneAndName.fromZoneAndName(zoneId, input.getGroup());
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testDoesNotUpdateReferenceWhenSecurityGroupListMissingGroupName() throws Exception {
   HttpRequest list = HttpRequest.builder().method("GET").endpoint(
        URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
        ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
            authToken).build()).build();

   HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
        payloadFromResource("/securitygroup_list.json")).build();

   NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
        responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list,
        listResponse);

   FindSecurityGroupWithNameAndReturnTrue predicate = new FindSecurityGroupWithNameAndReturnTrue(
        apiWhenSecurityGroupsExist);

   ZoneAndName zoneAndGroup = ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "name2");

   AtomicReference<ZoneAndName> securityGroupInZoneRef = Atomics.newReference(zoneAndGroup);

   // we cannot find it
   assertFalse(predicate.apply(securityGroupInZoneRef));

   // the reference is the same
   assertEquals(securityGroupInZoneRef.get(), zoneAndGroup);

  }
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testUpdateReferenceWhenSecurityGroupListContainsGroupName() throws Exception {
 HttpRequest list = HttpRequest.builder().method("GET").endpoint(
      URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
      ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
          authToken).build()).build();
 HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
      payloadFromResource("/securitygroup_list.json")).build();
 NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
      responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list,
      listResponse);
 FindSecurityGroupWithNameAndReturnTrue predicate = new FindSecurityGroupWithNameAndReturnTrue(
      apiWhenSecurityGroupsExist);
 AtomicReference<ZoneAndName> securityGroupInZoneRef = Atomics.newReference(ZoneAndName
      .fromZoneAndName("az-1.region-a.geo-1", "name1"));
 // we can find it
 assertTrue(predicate.apply(securityGroupInZoneRef));
 // the reference is now up to date, and includes the actual group found.
 assertEquals(securityGroupInZoneRef.get().toString(), new SecurityGroupInZone(Iterables
      .getOnlyElement(new ParseSecurityGroupListTest().expected()), "az-1.region-a.geo-1").toString());
}

代码示例来源:origin: jclouds/legacy-jclouds

.get(new TypeLiteral<LoadingCache<ZoneAndName, KeyPair>>() {
     }));
keyPairCache.put(ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "foo"), KeyPair.builder().name("foo")
     .privateKey("privateKey").build());

代码示例来源:origin: jclouds/legacy-jclouds

if (templateOptions.getKeyPairName() != null) {
  options.keyPairName(templateOptions.getKeyPairName());        
  KeyPair keyPair = keyPairCache.getIfPresent(ZoneAndName.fromZoneAndName(template.getLocation().getId(), templateOptions.getKeyPairName()));
  if (keyPair != null && keyPair.getPrivateKey() != null) {
   privateKey = Optional.of(keyPair.getPrivateKey());

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com