本文整理汇总了Java中com.woorea.openstack.quantum.Quantum类的典型用法代码示例。如果您正苦于以下问题:Java Quantum类的具体用法?Java Quantum怎么用?Java Quantum使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Quantum类属于com.woorea.openstack.quantum包,在下文中一共展示了Quantum类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: find
import com.woorea.openstack.quantum.Quantum; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public WooreaNetwork find(String groupId) {
if (L.isDebugEnabled()) L.debug(Strings.substitute(R.getString("D-WOOREA-NETWORK-CONNECTOR#0003"),
Maps.hash("groupId", groupId)));
Quantum quantum = createQuantumInstance(groupId);
Networks networks = quantum.networks().list().execute();
WooreaNetwork entity = new WooreaNetwork(groupId);
for (Network network : networks.getList()) {
entity.setStatus(network.getStatus());
if (network.getName().equals(groupId)) {
Subnet subnet = quantum.subnets().show(network.getSubnets().get(0)).execute();
entity.setGatewayIp(subnet.getGw());
entity.setCidr(subnet.getCidr());
}
}
return entity;
}
示例2: getNeutronClient
import com.woorea.openstack.quantum.Quantum; //导入依赖的package包/类
public static Quantum getNeutronClient(String osAuthUrl, String osPassword,
String osTenantName, String osUsername) {
// Set account information, and issue an authentication request.
Keystone keystoneClient = new Keystone(jopst.getOsAuthUrl());
Access access = keystoneClient.tokens()
.authenticate(new UsernamePassword(jopst.getOsUsername(),
jopst.getOsPassword()))
.withTenantName(jopst.getOsTenantName())
.execute();
String neutronEndpoint = KeystoneUtils
.findEndpointURL(access.getServiceCatalog(),
"network", null, "public");
if (jopst.isDebug()) {
System.out.println("DEBUG: " + neutronEndpoint);
}
// Create a Quantum/Neutron client object.
Quantum neutronClient = new Quantum(neutronEndpoint);
neutronClient.token(access.getToken().getId());
//tenantId = access.getToken().getTenant().getId();
return neutronClient;
}
示例3: delete
import com.woorea.openstack.quantum.Quantum; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void delete(String groupId) {
if (L.isDebugEnabled()) L.debug(Strings.substitute(R.getString("D-WOOREA-NETWORK-CONNECTOR#0002"),
Maps.hash("groupId", groupId)));
Quantum quantum = createQuantumInstance(groupId);
Networks networks = quantum.networks().list().execute();
for (Network network : networks.getList()) {
if (network.getName().equals(groupId)) {
RouterForAddInterface interfaceRouter = new RouterForAddInterface();
Routers routers = quantum.routers().list().execute();
Ports ports = quantum.ports().list().execute();
for (Port p : ports.getList()) {
if (p.getNetworkId().equals(network.getId())) {
for (Router r : routers.getList()) {
if (r.getId().equals(p.getDeviceId())) {
interfaceRouter.setRouterId(r.getId());
for (String subnet : network.getSubnets()) {
interfaceRouter.setSubnetId(subnet);
quantum.routers().deleteInterface(interfaceRouter).execute();
}
break;
}
}
break;
}
}
quantum.networks().delete(network.getId()).execute();
}
}
}
示例4: createQuantumInstance
import com.woorea.openstack.quantum.Quantum; //导入依赖的package包/类
private Quantum createQuantumInstance(String groupId) {
String endpoint = WooreaAuths.getNetworkEndpoint(authRepository.findById(groupId));
if (!endpoint.endsWith("/")) endpoint += "/";
Quantum quantum = new Quantum(endpoint + "v2.0");
quantum.token(provider.getToken(groupId));
return quantum;
}
示例5: main
import com.woorea.openstack.quantum.Quantum; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
// access with unscoped token
Access access = keystone.tokens().authenticate(
new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
.execute();
// use the token in the following requests
keystone.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
Tenants tenants = keystone.tenants().list().execute();
// try to exchange token using the first tenant
if (tenants.getList().size() > 0) {
// access with tenant
access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
Quantum quantum = new Quantum(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "network", null, "public"));
quantum.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
Networks networks = quantum.networks().list().execute();
for (Network network : networks) {
System.out.println(network);
}
} else {
System.out.println("No tenants found!");
}
}
示例6: main
import com.woorea.openstack.quantum.Quantum; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
// access with unscoped token
Access access = keystone.tokens().authenticate(
new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
.execute();
// use the token in the following requests
keystone.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
Tenants tenants = keystone.tenants().list().execute();
// try to exchange token using the first tenant
if (tenants.getList().size() > 0) {
// access with tenant
access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
Quantum quantumClient = new Quantum(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "network", null, "public"));
quantumClient.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
Network networkQuery = new Network();
networkQuery.setName("benn.cs");
networkQuery.setAdminStateUp(true);
/*
Networks networks = quantumClient.execute(NetworkQuery.queryNetworks(networkQuery));
for (Network network : networks) {
System.out.println(network);
}
Subnet subnetQuery = new Subnet();
subnetQuery.setIpversion(Subnet.IpVersion.IPV4);
Subnets Subnets = quantumClient.execute(NetworkQuery.querySubnets(subnetQuery));
for (Subnet subnet : Subnets) {
System.out.println(subnet);
}
*/
} else {
System.out.println("No tenants found!");
}
}
示例7: createQuantumInstance
import com.woorea.openstack.quantum.Quantum; //导入依赖的package包/类
private Quantum createQuantumInstance(String groupId) {
Quantum quantum = new Quantum(getEndpoint(groupId));
quantum.token(provider.getToken(groupId));
return quantum;
}