openstack4j接口调试
Posted 开源、架构、Linux C/C++/python AI BI
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openstack4j接口调试相关的知识,希望对你有一定的参考价值。
//import java.util.List;
//
//import org.openstack4j.api.OSClient.OSClientV3;
//import org.openstack4j.openstack.OSFactory;
//import org.openstack4j.model.common.Identifier;
//import org.openstack4j.model.compute.Flavor;
//import org.openstack4j.model.identity.v3.Project;
//import org.openstack4j.model.identity.v3.User;
//
//public class openstack {
// public static void main(String[] args) {
// OSClientV3 os=OSFactory.builderV3()
// .endpoint("http://ahwater-cloud-controller:35357/v3")
// .credentials("admin", "ahwater", Identifier.byId("default"))
// .scopeToProject(Identifier.byName("admin"),Identifier.byId("default"))
// .authenticate();
// List<? extends User> users = os.identity().users().list();
// System.out.println(users.size());
//
// List<? extends Project> projectList = os.identity().projects().list();
// System.out.println(projectList.size());
//
// List<? extends Flavor> flavors = os.compute().flavors().list();
// System.out.println(flavors.size());
//
// }
//}
import java.util.List;
import org.openstack4j.openstack.OSFactory;
import org.openstack4j.api.Builders;
import org.openstack4j.api.OSClient.OSClientV2;
import org.openstack4j.api.types.Facing;
import org.openstack4j.model.identity.v2.*;
import org.openstack4j.model.storage.block.Volume;
public class openstack {
public static void main(String[] args) {
// TODO Auto-generated method stub
OSClientV2 os=OSFactory.builderV2()
.endpoint("http://ahwater-cloud-controller:35357/v2.0")
.credentials("adminTest", "ahwater")
.tenantName("admin")
.perspective(Facing.ADMIN)
.authenticate();
List<? extends User> users = os.identity().users().list();
System.out.println("users: "+users.size());
// List all Tenants
List<? extends Tenant> tenants = os.identity().tenants().list();
System.out.println("tenants: "+tenants.size());
// System.out.println("tenants detail:"+tenants.toString());
// List<? extends Flavor> flavors = os.compute().flavors().list();
// System.out.println(flavors.size());
//
// List<? extends Volume> volumes = os.blockStorage().volumes().list();
// System.out.println(volumes.size());
//
// List<? extends SwiftContainer> containers = os.objectStorage().containers().list();
// System.out.println(containers.size());
}
}
以上是关于openstack4j接口调试的主要内容,如果未能解决你的问题,请参考以下文章