本文整理汇总了Java中com.woorea.openstack.keystone.model.Access类的典型用法代码示例。如果您正苦于以下问题:Java Access类的具体用法?Java Access怎么用?Java Access使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Access类属于com.woorea.openstack.keystone.model包,在下文中一共展示了Access类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
.withTenantName(ExamplesConfiguration.TENANT_NAME)
.execute();
//use the token in the following requests
keystone.token(access.getToken().getId());
Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId()));
novaClient.token(access.getToken().getId());
Servers servers = novaClient.servers().list(true).execute();
if(servers.getList().size() > 0) {
// Server has to be in activated state.
ServersResource.StopServer stopServer = novaClient.servers().stop(servers.getList().get(0).getId());
stopServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT);
stopServer.execute();
// Wait until server shutdown. Or 400 error occurs.
Thread.sleep(5000);
ServersResource.StartServer startServer = novaClient.servers().start(servers.getList().get(0).getId());
startServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT);
startServer.execute();
}
}
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:29,代码来源:NovaStopStartServer.java
示例2: main
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
.withTenantName("demo")
.execute();
//use the token in the following requests
keystone.token(access.getToken().getId());
//NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId()));
novaClient.token(access.getToken().getId());
//novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
Servers servers = novaClient.servers().list(true).execute();
for(Server server : servers) {
System.out.println(server);
}
}
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:24,代码来源:NovaListServers.java
示例3: getAccess
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
private Access getAccess(Tenant tenant) {
if (getAccess().getToken().getTenant().getId() == tenant.getId()) {
return getAccess();
}
// Use our existing token to authenticate with Keystone to create new tenant-specific tokens
Authentication tokenAuth = new TokenAuthentication(getAccess().getToken().getId());
// Now, *try* to create a NEW token on this tenant.
// NOTE: even "admin" users are not authorized on every tenant, though
// oddly they are authorized to add themselves to tenants!?
try {
return keystone.tokens()
.authenticate(tokenAuth)
.withTenantId(tenant.getId())
.execute();
} catch (OpenStackResponseException err) {
System.out.println("\nFailed to access tenant \"" + tenant.getName() + "\" - user must not have authorization for this tenant!");
return null; // Cannot access nova
}
}
开发者ID:jdutton,项目名称:java-openstack-sdk-cli-example,代码行数:22,代码来源:Cli.java
示例4: createNovaClient
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
/**
* Create a Nova Client Resource by authenticating with Keystone to gain
* access to the specified tenant.
*
* Note: if the user does not have access to the tenant, will return null
*
* @param Tenant who we are binding the Nova to
* @return Nova
*/
private Nova createNovaClient(Tenant tenant) {
Access access = getAccess(tenant);
if (access == null) {
return null; // Our user may not have access to this tenant
}
String region = null; // Don't care which region
// Find the appropriate Nova endpoint from the access credentials
// NOTE: the Nova endpoint is specific to the tenant used to authenticate - cannot see compute resources from other tenants!!!
String apiEndpoint = KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", region, facing);
Nova nova = new Nova(apiEndpoint, connector);
nova.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
return nova;
}
开发者ID:jdutton,项目名称:java-openstack-sdk-cli-example,代码行数:25,代码来源:Cli.java
示例5: createGlanceClient
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
/**
* Create a Glance Client Resource by asking Keystone
*
* @return Glance
*/
private Glance createGlanceClient() {
Access access = getAccess();
String region = null; // Don't care which region
// Find the appropriate Glance endpoint from the access credentials
String apiEndpoint = KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "image", region, facing);
if (!apiEndpoint.endsWith("/v1") && !apiEndpoint.endsWith("/v1/") &&
!apiEndpoint.endsWith("/v2") && !apiEndpoint.endsWith("/v2/")) {
// FIXME: Why do I need to explicitly add an API version!?
// Without this a 300 Multiple Choices error is returned
apiEndpoint += "/v1";
}
Glance glance = new Glance(apiEndpoint, connector);
glance.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
return glance;
}
开发者ID:jdutton,项目名称:java-openstack-sdk-cli-example,代码行数:24,代码来源:Cli.java
示例6: getCeilometerClient
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
public static Ceilometer getCeilometerClient(String osAuthUrl,
String osPassword,
String osTenantName,
String osUsername) {
Keystone keystoneClient = new Keystone(osAuthUrl);
// Set account information, and issue an authentication request.
Access access = keystoneClient.tokens()
.authenticate(new UsernamePassword(osUsername, osPassword))
.withTenantName(osTenantName)
.execute();
String ceilometerEndpoint = KeystoneUtils
.findEndpointURL(access.getServiceCatalog(),
"metering", null, "public");
if (jopst.isDebug()) {
System.out.println("DEBUG: " + ceilometerEndpoint);
}
// Create a Nova client object.
Ceilometer ceilometerClient = new Ceilometer(ceilometerEndpoint);
ceilometerClient.token(access.getToken().getId());
return ceilometerClient;
}
开发者ID:thatsdone,项目名称:openstack-java-cli,代码行数:25,代码来源:Jceilometer.java
示例7: getGlanceClient
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
private static Glance getGlanceClient() {
Keystone keystoneClient = new Keystone(jopst.getOsAuthUrl());
// Set account information, and issue an authentication request.
Access access = keystoneClient.tokens()
.authenticate(new UsernamePassword(jopst.getOsUsername(),
jopst.getOsPassword()))
.withTenantName(jopst.getOsTenantName())
.execute();
String glanceEndpoint = KeystoneUtils
.findEndpointURL(access.getServiceCatalog(),
"image", null, "public");
if (jopst.isDebug()) {
System.out.println("DEBUG: " + glanceEndpoint);
}
// Create a Glance client object.
Glance glanceClient = new Glance(glanceEndpoint);
glanceClient.token(access.getToken().getId());
return glanceClient;
}
开发者ID:thatsdone,项目名称:openstack-java-cli,代码行数:23,代码来源:Jglance.java
示例8: getNeutronClient
import com.woorea.openstack.keystone.model.Access; //导入依赖的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;
}
开发者ID:thatsdone,项目名称:openstack-java-cli,代码行数:24,代码来源:Jneutron.java
示例9: getCinderClient
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
public static Cinder getCinderClient(String osAuthUrl, String osPassword,
String osTenantName, String osUsername) {
Keystone keystoneClient = new Keystone(jopst.getOsAuthUrl());
// Set account information, and issue an authentication request.
Access access = keystoneClient.tokens()
.authenticate(new UsernamePassword(jopst.getOsUsername(),
jopst.getOsPassword()))
.withTenantName(jopst.getOsTenantName())
.execute();
String cinderEndpoint = KeystoneUtils
.findEndpointURL(access.getServiceCatalog(),
"volume", null, "public");
if (jopst.isDebug()) {
System.out.println("DEBUG: " + cinderEndpoint);
}
// Create a Cinder client object.
Cinder cinderClient = new Cinder(cinderEndpoint);
cinderClient.token(access.getToken().getId());
return cinderClient;
}
开发者ID:thatsdone,项目名称:openstack-java-cli,代码行数:24,代码来源:Jcinder.java
示例10: getSwiftClient
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
private static Swift getSwiftClient() {
Keystone keystoneClient = new Keystone(jopst.getOsAuthUrl());
// Set account information, and issue an authentication request.
Access access = keystoneClient.tokens()
.authenticate(new UsernamePassword(jopst.getOsUsername(),
jopst.getOsPassword()))
.withTenantName(jopst.getOsTenantName())
.execute();
String swiftEndpoint = KeystoneUtils
.findEndpointURL(access.getServiceCatalog(),
"object-store", null, "public");
if (jopst.isDebug()) {
System.out.println("DEBUG: " + swiftEndpoint);
}
// Create a Nova client object.
Swift swiftClient = new Swift(swiftEndpoint);
swiftClient.token(access.getToken().getId());
return swiftClient;
}
开发者ID:thatsdone,项目名称:openstack-java-cli,代码行数:24,代码来源:Jswift.java
示例11: getAccessWithTenantId
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
private Access getAccessWithTenantId(){
if(PREFERENCES_INITIALIZED == false){
loadPreferences();
PREFERENCES_INITIALIZED = true;
}
Keystone keystone = new Keystone(KEYSTONE_AUTH_URL, new JerseyConnector());
TokensResource tokens = keystone.tokens();
UsernamePassword credentials = new UsernamePassword(KEYSTONE_USERNAME, KEYSTONE_PASSWORD);
Access access = tokens.authenticate(credentials).withTenantName(TENANT_NAME).execute();
keystone.token(access.getToken().getId());
Tenants tenants = keystone.tenants().list().execute();
List<Tenant> tenantsList = tenants.getList();
if (tenants.getList().size() > 0) {
for (Iterator<Tenant> iterator = tenantsList.iterator(); iterator.hasNext();) {
Tenant tenant = (Tenant) iterator.next();
if (tenant.getName().compareTo(TENANT_NAME) == 0) {
TENANT_ID = tenant.getId();
break;
}
}
} else {
throw new RuntimeException("No tenants found!");
}
TokenAuthentication tokenAuth = new TokenAuthentication(access.getToken().getId());
access = tokens.authenticate(tokenAuth).withTenantId(TENANT_ID).execute();
return access;
}
开发者ID:FITeagle,项目名称:adapters,代码行数:33,代码来源:OpenstackClient.java
示例12: getHypervisors
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
private ArrayList<String> getHypervisors(){
Access access = getAccessWithTenantId();
Nova novaClient = new Nova(NOVA_ENDPOINT.concat("/").concat(TENANT_ID));
novaClient.token(access.getToken().getId());
OpenStackRequest<String> request = new OpenStackRequest<String>(
novaClient, HttpMethod.GET, "/os-hypervisors", null,
String.class);
String hypervisors = null;
try{
hypervisors = novaClient.execute(request);
} catch(OpenStackResponseException e){
LOGGER.log(Level.SEVERE, e.getMessage());
return null;
}
ArrayList<String> hypervisors_list = new ArrayList<String>() ;
try{
JSONParser parser = new JSONParser() ;
JSONObject object = (JSONObject) parser.parse(hypervisors) ;
JSONArray json_hypervisors = (JSONArray) object.get("hypervisors") ;
for (Object o : json_hypervisors){
JSONObject obj = (JSONObject) o ;
hypervisors_list.add(obj.get("hypervisor_hostname").toString()) ;
}
}catch(ParseException pe){
LOGGER.log(Level.WARNING,"Cannot parse result.");
}
return hypervisors_list;
}
开发者ID:FITeagle,项目名称:adapters,代码行数:33,代码来源:OpenstackClient.java
示例13: findEndpointByType
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
/**
* タイプ、アクセス情報からエンドポイントを取得します。
* @param type タイプ
* @param access アクセス情報
* @param region リージョン
* @return エンドポイント
*/
public static String findEndpointByType(String type, Access access, String region) {
if (access == null) return null;
List<Service> services = access.getServiceCatalog();
for (Service service : services) {
if (!type.equals(service.getType())) continue;
for (Endpoint e : service.getEndpoints()) {
if (!region.equals(e.getRegion())) continue;
return e.getPublicURL();
}
}
return null;
}
开发者ID:ctc-g,项目名称:rack-java,代码行数:21,代码来源:WooreaAuths.java
示例14: AuthenticationCriteria
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
@Test
public void 登録されているユーザの場合はアクセス情報が取得できる() {
AuthenticationCriteria criteria = new AuthenticationCriteria();
criteria.setUsername("user01");
criteria.setPassword("user01");
criteria.setTenantName("ctc01");
WooreaAuthentication authentication = connector.authentication(criteria);
assertThat(authentication, notNullValue());
Access access = authentication.entity();
assertThat(access, notNullValue());
assertThat(access.getUser().getName(), is("user01"));
}
开发者ID:ctc-g,项目名称:rack-java,代码行数:13,代码来源:WooreaAuthConnectorTest.java
示例15: main
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)).execute();
//use the token in the following requests
keystone.token(access.getToken().getId());
Tenants tenants = keystone.tenants().list().execute();
//try to exchange token using the first tenant
if(tenants.getList().size() > 0) {
access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId()))
.withTenantId(tenants.getList().get(0).getId())
.execute();
//NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(tenants.getList().get(0).getId()));
novaClient.token(access.getToken().getId());
//novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
Images images = novaClient.images().list(true).execute();
for(Image image : images) {
System.out.println(image);
}
} else {
System.out.println("No tenants found!");
}
}
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:36,代码来源:NovaListImages.java
示例16: main
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
Access access = keystone.tokens().authenticate(
new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
.execute();
//use the token in the following requests
keystone.token(access.getToken().getId());
Tenants tenants = keystone.tenants().list().execute();
//try to exchange token using the first tenant
if(tenants.getList().size() > 0) {
access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
//NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(tenants.getList().get(0).getId()));
novaClient.token(access.getToken().getId());
//novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
Flavors flavors = novaClient.flavors().list(true).execute();
for(Flavor flavor : flavors) {
System.out.println(flavor);
}
} else {
System.out.println("No tenants found!");
}
}
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:35,代码来源:NovaListFlavors.java
示例17: main
import com.woorea.openstack.keystone.model.Access; //导入依赖的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!");
}
}
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:30,代码来源:QuantumListNetworks.java
示例18: main
import com.woorea.openstack.keystone.model.Access; //导入依赖的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!");
}
}
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:43,代码来源:QuantumQueryNetworks.java
示例19: main
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) throws InterruptedException {
KeystoneTokenProvider keystone = new KeystoneTokenProvider(
ExamplesConfiguration.KEYSTONE_ENDPOINT,
ExamplesConfiguration.KEYSTONE_USERNAME,
ExamplesConfiguration.KEYSTONE_PASSWORD
);
Access access = keystone.getAccessByTenant(ExamplesConfiguration.TENANT_NAME);
String endpointURL = KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "orchestration", null, "public");
Heat heat = new Heat(endpointURL);
heat.setTokenProvider(keystone
.getProviderByTenant(ExamplesConfiguration.TENANT_NAME));
CreateStackParam param = new CreateStackParam();
param.setStackName("helloWorld");
param.setTimeoutMinutes(1);
param.setParameters(Collections.<String, String>emptyMap());
param.setTemplate(TEMPLATE);
System.out.printf("Create: " + heat.getStacks().create(param).execute());
Thread.sleep(3000);
for (Stack s : heat.getStacks().list().execute()) {
System.out.println(s.getDescription());
System.out.println(s.getId());
System.out.println(s.getStackName());
System.out.println(s.getStackStatus());
System.out.println(s.getCreationTime());
System.out.println(s.getUpdatedTime());
System.out.println(s.getLinks());
System.out.println(heat.getStacks().byName(s.getStackName()).execute());
}
}
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:43,代码来源:HeatListStacks.java
示例20: main
import com.woorea.openstack.keystone.model.Access; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
Keystone keystone = new Keystone(KEYSTONE_AUTH_URL);
// access with unscoped token
Access access = keystone
.tokens()
.authenticate()
.withUsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)
.execute();
System.out.println(access);
}
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:17,代码来源:KeystoneAuthentication.java
注:本文中的com.woorea.openstack.keystone.model.Access类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论