简体   繁体   English

如何在openstack中使用jclouds将网络分配给vm,以及如何使用jclouds在openstack中列出所有网络

[英]how to assign network to vm using jclouds in openstack and How to list all networks in Openstack using Jclouds

Can someone help me understanding how to assign a specific network to a newly created VM using the JClouds API in OpenStack? 有人可以帮助我了解如何使用OpenStack中的JClouds API将特定网络分配给新创建的VM吗? I'm using following code to create the real server: 我正在使用以下代码创建真实的服务器:

CreateServerOptions[] serverOptions = new CreateServerOptions[0];

ServerCreated serverCreated = serverApi.create(clonedVmName, imageId, FlavourId, serverOptions);

Also I'm using v1.0-quantum APIs to fetch all the networks as follows but it's not returning any. 另外,我正在使用v1.0-quantum API来按如下方式获取所有网络,但不会返回任何网络。 I'm not sure what's wrong with the following code: 我不确定以下代码有什么问题:

Iterable<Module> modules = ImmutableSet.<Module> of(
              new SLF4JLoggingModule());

      quantum = ContextBuilder.newBuilder(provider)
            .endpoint("http://10.37.53.229:5000/v2.0/")
            .credentials(identity, password)
            .modules(modules)
            .build();


      QuantumApi quanApi =  (QuantumApi)quantum.getApi();
      for(String zone : quanApi.getConfiguredZones())
      {
          System.out.println("Zone : "+ zone);
      }

      NetworkApi netApi = quanApi.getNetworkApiForZone("RegionOne");
      FluentIterable<? extends Network> nets = netApi.list();

      for(Network net : nets)
      {
          System.out.println(net.getName() +" Id : "+net.getId());
      }

I use version 1.7.3 of JClouds and I build the options in the following way, giving network ids as parameters: 我使用JClouds的1.7.3版本,并以以下方式构建选项,将网络ID作为参数:

 CreateServerOptions options = CreateServerOptions.Builder
       .networks("00000000-0000-0000-0000-000000000000", "11111111-1111-1111-1111-111111111111")

As for listing networks here are good examples. 至于列表网络, 是很好的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Jclouds从OpenStack Swift获取多部分对象 - How to get a multi part object from openstack swift using jclouds 使用jclouds列出SAIO Openstack swift服务器中的容器不成功 - Using jclouds to list containers in SAIO Openstack swift server not successful 在OpenStack中使用jclouds传递ssh密钥 - Pass ssh key using jclouds in openstack 是否可以使用jclouds获取openstack云中可用的所有数据库服务器的列表? - is it possible to get a list of all database servers that are available in the openstack cloud using jclouds? jclouds openstack创建实例 - jclouds openstack create instance jclouds在openstack中创建租户 - jclouds create tenant in openstack 使用jclouds在Openstack上创建网络时,出现错误:[{“ NeutronError”:“无法识别的属性&#39;networkType&#39;”}}] - While creating network on Openstack using jclouds I am getting the error : [{“NeutronError”: “Unrecognized attribute(s) 'networkType'”}] jClouds + OpenStack:(NoSuchElementException)键[openstack-neutron]不在提供程序或API的列表中 - jClouds + OpenStack: (NoSuchElementException) key [openstack-neutron] not in the list of providers or apis 在OpenStack中使用jClouds或openstack4j - Use of jClouds or openstack4j with OpenStack 在openstack上使用ansible的网络自动化 - Automation of networks using ansible on openstack
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM