• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Keypair类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openstack4j.model.compute.Keypair的典型用法代码示例。如果您正苦于以下问题:Java Keypair类的具体用法?Java Keypair怎么用?Java Keypair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Keypair类属于org.openstack4j.model.compute包,在下文中一共展示了Keypair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: create

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
@Override
public KeyPair create(@Nullable String name, @Nullable String publicKey, String locationId) {

  checkNotNull(locationId, "location is null");
  if (name != null) {
    checkArgument(!name.isEmpty(), "name is empty");
  }
  if (publicKey != null) {
    checkArgument(!publicKey.isEmpty(), "publicKey is empty");
  }

  final Location region = getRegion(locationId);
  Keypair osKeyPair = osClient.useRegion(region.id()).compute().keypairs()
      .create(namingStrategy.generateUniqueNameBasedOnName(name), publicKey);

  checkNotNull(osKeyPair, "keyPair was not generated.");
  checkState(osKeyPair.getPrivateKey() != null && publicKey == null,
      "privateKeyPair not present in generated keyPair (when no public key is supplied)");
  return KeyPairBuilder.newBuilder()
      .id(IdScopeByLocations.from(region.id(), osKeyPair.getName()).getIdWithLocation())
      .providerId(osKeyPair.getName()).location(region).publicKey(osKeyPair.getPublicKey())
      .privateKey(osKeyPair.getPrivateKey()).name(osKeyPair.getName()).build();
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:24,代码来源:Openstack4JKeyPairExtension.java


示例2: createKeyPair

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
@Override
public Keypair createKeyPair(String keyPairName, String publicKey) {
	try {

		Keypair keyp = os.compute().keypairs().create(keyPairName, publicKey);

		logger.info("Keypair created successfully: " + keyp.getName());

		return keyp;
	}
	catch( Exception ex ) {
		ex.printStackTrace();
		// TODO: Check with the team on how to handle exceptions.
		logger.error("Failed to create keypair: " + keyPairName);
		return null;
	}
}
 
开发者ID:apache,项目名称:airavata,代码行数:18,代码来源:OpenstackIntfImpl.java


示例3: getKeyPair

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
@Override
public Keypair getKeyPair(String keyPairName) {
	try {

		Keypair keyp = os.compute().keypairs().get(keyPairName);

		if(keyp != null){
			logger.info("Keypair retrieved successfully: " + keyp.getName());				
		}

		return keyp;
	}
	catch( Exception ex ) {
		ex.printStackTrace();
		// TODO: Check with the team on how to handle exceptions.
		logger.error("Failed to retrieve keypair: " + keyPairName);
		return null;
	}
}
 
开发者ID:apache,项目名称:airavata,代码行数:20,代码来源:OpenstackIntfImpl.java


示例4: createKeyPair

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
private void createKeyPair(AuthenticatedContext authenticatedContext, CloudStack stack, OSClient client) {
    KeystoneCredentialView keystoneCredential = openStackClient.createKeystoneCredential(authenticatedContext);

    String keyPairName = keystoneCredential.getKeyPairName();
    if (client.compute().keypairs().get(keyPairName) == null) {
        try {
            Keypair keyPair = client.compute().keypairs().create(keyPairName, stack.getInstanceAuthentication().getPublicKey());
            LOGGER.info("Keypair has been created: {}", keyPair);
        } catch (Exception e) {
            LOGGER.error("Failed to create keypair", e);
            throw new CloudConnectorException(e.getMessage(), e);
        }
    } else {
        LOGGER.info("Keypair already exists: {}", keyPairName);
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:17,代码来源:OpenStackResourceConnector.java


示例5: sshKeys

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
@Override
public CloudSshKeys sshKeys(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
    OSClient osClient = openStackClient.createOSClient(cloudCredential);
    KeystoneCredentialView osCredential = openStackClient.createKeystoneCredential(cloudCredential);

    Set<CloudSshKey> cloudSshKeys = new HashSet<>();
    for (Keypair keypair : osClient.compute().keypairs().list()) {
        Map<String, Object> properties = new HashMap<>();
        properties.put("fingerprint", keypair.getFingerprint());
        properties.put("id", keypair.getId());
        properties.put("publicKey", keypair.getPublicKey());
        properties.put("createdAt", keypair.getCreatedAt());

        CloudSshKey cloudSshKey = new CloudSshKey();
        cloudSshKey.setName(keypair.getName());
        cloudSshKey.setProperties(properties);
        cloudSshKeys.add(cloudSshKey);
    }

    Map<String, Set<CloudSshKey>> result = new HashMap<>();
    result.put(region.value() == null ? osCredential.getTenantName() : region.value(), cloudSshKeys);
    LOGGER.info("openstack cloud ssh keys result: {}", result);
    return new CloudSshKeys(result);
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:25,代码来源:OpenStackPlatformResources.java


示例6: getListOfKeypairs

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
public List<SelectItem> getListOfKeypairs() {
    // Get all Keypairs the current account making the request has access to
    List<? extends Keypair> keypairs = osClient.compute().keypairs().list();

    List<SelectItem> keypairList = new ArrayList<SelectItem>();
    for (Keypair keypair : keypairs) {
        keypairList.add(new SelectItem(keypair.getName(), keypair.getName()));
    }
    return keypairList;
}
 
开发者ID:foundation-runtime,项目名称:jenkins-openstack-deployment-plugin,代码行数:11,代码来源:OpenStack4jClient.java


示例7: CreateKeypair

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
public static String CreateKeypair(OSClient os, String keypair)
		throws InterruptedException {
	Keypair kp = os.compute().keypairs().create(keypair, null);
	String name = kp.getName();
	System.out.println("name: " + name);
	return name;
}
 
开发者ID:tosca-types,项目名称:openstack,代码行数:8,代码来源:OSUtilities.java


示例8: get

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
@Nullable
@Override
public KeyPair get(String id) {
  checkNotNull(id);
  checkArgument(!id.isEmpty());
  final IdScopedByLocation scopedId = IdScopeByLocations.from(id);
  final Keypair retrieved =
      osClient.useRegion(getRegion(scopedId.getLocationId()).id()).compute().keypairs()
          .get(scopedId.getId());
  return KeyPairBuilder.newBuilder().location(getRegion(scopedId.getLocationId()))
      .id(scopedId.getIdWithLocation()).providerId(retrieved.getName())
      .name(retrieved.getName()).build();
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:14,代码来源:Openstack4JKeyPairExtension.java


示例9: ServerInRegion

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
public ServerInRegion(Server createdServer, Server retrievedServer, Location region, @Nullable Keypair keypair) {
  checkNotNull(retrievedServer);
  checkNotNull(createdServer, "createdServer is null.");
  checkNotNull(region, "region is null.");
  this.createdServer = createdServer;
  this.retrievedServer = retrievedServer;
  this.region = region;
  regionScopedId =
      IdScopeByLocations.from(region.id(), createdServer.getId()).getIdWithLocation();
  this.keypair = keypair;
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:12,代码来源:ServerInRegion.java


示例10: main

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    HttpLoggingFilter.toggleLogging(false);
    CloudApiSettings driverConfig = DriverConfigLoader.loadDefault();

    OSClient client = new OSClientFactory(driverConfig).authenticatedClient();
    KeypairService keyApi = client.compute().keypairs();

    String publicKeyContent = new String(Files.toByteArray(publicKeyFile));
    Keypair createdKeypair = keyApi.create(keyPairName, publicKeyContent);
    LOG.info("created keypair: {}", createdKeypair);
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:12,代码来源:CreateKeypairMain.java


示例11: listKeys

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
private static void listKeys(KeypairService keyApi) {
    List<? extends Keypair> keypairs = keyApi.list();
    LOG.info("found {} keypair(s)", keypairs.size());
    for (Keypair keypair : keypairs) {
        LOG.info("keypair: " + keypair);
    }
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:8,代码来源:ListKeypairsMain.java


示例12: testNovaKeypair

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
@Test
public void testNovaKeypair() throws Exception {
    when(osTestKeypair.getName()).thenReturn(KEYPAIR_NAME);
    when(osTestKeypair.getPublicKey()).thenReturn(dummyKeypair.getPublicKey());
    when(osTestKeypair.getFingerprint()).thenReturn("fp");
    when(osTestKeypair.getPrivateKey()).thenReturn("prk");

    CamelContext camelContext = Mockito.mock(CamelContext.class);
    when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());

    Message msg = new DefaultMessage(camelContext);
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
    msg.setHeader(OpenstackConstants.NAME, KEYPAIR_NAME);

    Exchange exchange = Mockito.mock(Exchange.class);
    when(exchange.getIn()).thenReturn(msg);

    NovaEndpoint endpoint = Mockito.mock(NovaEndpoint.class);
    Producer producer = new KeypairProducer(endpoint, client);
    producer.process(exchange);

    ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> keypairCaptor = ArgumentCaptor.forClass(String.class);
    verify(keypairService).create(nameCaptor.capture(), keypairCaptor.capture());

    assertEquals(KEYPAIR_NAME, nameCaptor.getValue());
    assertNull(keypairCaptor.getValue());

    Keypair result = msg.getBody(Keypair.class);
    assertEquals("fp", result.getFingerprint());
    assertEquals("prk", result.getPrivateKey());
    assertEquals(dummyKeypair.getName(), result.getName());
    assertEquals(dummyKeypair.getPublicKey(), result.getPublicKey());
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:35,代码来源:OpenstackIntegrationTest.java


示例13: keyPairs

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
public List<? extends Keypair> keyPairs() {
	return client().compute().keypairs().list();
}
 
开发者ID:evoila,项目名称:cfsummiteu2017,代码行数:4,代码来源:NovaFluent.java


示例14: apply

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
@Override
public VirtualMachine apply(VirtualMachineTemplate virtualMachineTemplate) {

  //todo we currently simply assume that this is a zone (hosts may follow)
  Location zone = locationGetStrategy.get(virtualMachineTemplate.locationId());
  checkNotNull(zone, "zone is null");
  checkState(LocationScope.ZONE.equals(zone.locationScope()), "zone is no zone");
  checkState(zone.parent().isPresent(), "zone has no parent region");
  Location region = zone.parent().get();

  List<String> networks = new ArrayList<>(1);
  if (networkStrategy.get() != null) {
    networks.add(networkStrategy.get());
  }

  //keypair
  String keyPairName = null;
  Keypair keypair = null;
  if (virtualMachineTemplate.templateOptions().isPresent()) {
    keyPairName = virtualMachineTemplate.templateOptions().get().keyPairName();
  }
  if (keyPairName == null) {
    keypair = osClient.compute().keypairs()
        .create(namingStrategy.generateNameBasedOnName(null), null);
  }

  List<String> secGroups = new ArrayList<>(1);
  if (virtualMachineTemplate.templateOptions().isPresent()) {
    secGroups.add(createSecurityGroupFromTemplateOption
        .create(virtualMachineTemplate.templateOptions().get(),
            virtualMachineTemplate.locationId()));
  }

  if (defaultSecurityGroup != null) {
    secGroups.add(defaultSecurityGroup);
  }

  //todo this code also assumes that location is always the availability zone
  final ServerCreateBuilder serverCreateBuilder = Builders.server()
      .name(namingStrategy.generateUniqueNameBasedOnName(virtualMachineTemplate.name()))
      .flavor(IdScopeByLocations.from(virtualMachineTemplate.hardwareFlavorId()).getId())
      .image(IdScopeByLocations.from(virtualMachineTemplate.imageId()).getId())
      .availabilityZone(IdScopeByLocations.from(virtualMachineTemplate.locationId()).getId())
      .networks(networks).keypairName(keyPairName);
  for (String secGroup : secGroups) {
    serverCreateBuilder.addSecurityGroup(secGroup);
  }
  final ServerCreate serverCreate = serverCreateBuilder.build();
  //todo make timeout configurable
  final Server createdServer = osClient.useRegion(region.id()).compute().servers()
      .bootAndWaitActive(serverCreate, 120000);
  // we retrieve the newly created server to get additional details the creation request does
  // not contain
  final Server retrievedServer = osClient.compute().servers().get(createdServer.getId());
  checkState(retrievedServer != null,
      "Could not retrieve newly created server with id " + createdServer.getId());
  return virtualMachineConverter
      .apply(new ServerInRegion(createdServer, retrievedServer, region, keypair));
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:60,代码来源:Openstack4jCreateVirtualMachineStrategy.java


示例15: keypair

import org.openstack4j.model.compute.Keypair; //导入依赖的package包/类
public Optional<Keypair> keypair() {
  return Optional.ofNullable(keypair);
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:4,代码来源:ServerInRegion.java



注:本文中的org.openstack4j.model.compute.Keypair类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SharedPoolDataSource类代码示例发布时间:2022-05-22
下一篇:
Java BlobBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap