当前位置: 首页>>代码示例>>Java>>正文


Java Keystone类代码示例

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


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

示例1: main

import com.woorea.openstack.keystone.Keystone; //导入依赖的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.Keystone; //导入依赖的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: getCeilometerClient

import com.woorea.openstack.keystone.Keystone; //导入依赖的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

示例4: getGlanceClient

import com.woorea.openstack.keystone.Keystone; //导入依赖的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

示例5: getNeutronClient

import com.woorea.openstack.keystone.Keystone; //导入依赖的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

示例6: getCinderClient

import com.woorea.openstack.keystone.Keystone; //导入依赖的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

示例7: getSwiftClient

import com.woorea.openstack.keystone.Keystone; //导入依赖的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

示例8: getAccessWithTenantId

import com.woorea.openstack.keystone.Keystone; //导入依赖的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

示例9: getToken

import com.woorea.openstack.keystone.Keystone; //导入依赖的package包/类
/**
 * グループIDを条件にトークンを取得します。
 * @param groupId グループID
 * @return トークン
 */
public String getToken(final String groupId) {
    
    if (Strings.isNullOrEmpty(groupId)) throw new InternalException(WooreaTokenProvider.class, "E-WOOREA-TOKEN-PROVIDER#0001");
    return new OpenStackTokenProvider() {

        @Override
        public String getToken() {
            final WooreaAuthentication a = repository.findById(groupId);
            if (a == null) throw new InternalException(WooreaTokenProvider.class, "E-WOOREA-TOKEN-PROVIDER#0002");
            String endpoint = WooreaAuths.getIdentityEndpoint(a);
            if (Strings.isNullOrEmpty(endpoint)) throw new InternalException(WooreaTokenProvider.class, "E-WOOREA-TOKEN-PROVIDER#0003");
            Token token = new Keystone(endpoint)
                .tokens()
                .authenticate()
                .withUsernamePassword(a.getUsername(), a.getPassword())
                .withTenantName(a.getTenantName())
                .execute()
                .getToken();
            L.debug("token Key:{}", token.getId());
            return token.getId();
        }

        @Override
        public void expireToken() {}

    }.getToken();
}
 
开发者ID:ctc-g,项目名称:rack-java,代码行数:33,代码来源:WooreaTokenProvider.java

示例10: main

import com.woorea.openstack.keystone.Keystone; //导入依赖的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

示例11: main

import com.woorea.openstack.keystone.Keystone; //导入依赖的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

示例12: main

import com.woorea.openstack.keystone.Keystone; //导入依赖的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

示例13: main

import com.woorea.openstack.keystone.Keystone; //导入依赖的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

示例14: main

import com.woorea.openstack.keystone.Keystone; //导入依赖的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

示例15: main

import com.woorea.openstack.keystone.Keystone; //导入依赖的package包/类
public static void main(String[] args) {
	Keystone client = new Keystone(KEYSTONE_ENDPOINT);
	client.setTokenProvider(new OpenStackSimpleTokenProvider("secret0"));
	client.tenants().delete("36c481aec1d54fc49190c92c3ef6840a").execute();
	Tenant tenant = client.tenants().create(new Tenant("new_api")).execute();
	System.out.println(tenant);
	System.out.println(client.tenants().list().execute());
	client.tenants().delete(tenant.getId()).execute();
}
 
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:10,代码来源:ExamplesConfiguration.java


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