• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Keystone类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: KeystoneTokenProvider

import com.woorea.openstack.keystone.Keystone; //导入依赖的package包/类
public KeystoneTokenProvider(String endpoint, String username,
        String password) {
    this.keystone = new Keystone(endpoint);
    this.username = username;
    this.password = password;
    this.hashTenantAccess = new ConcurrentHashMap < String, Access > ();
}
 
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:8,代码来源:KeystoneTokenProvider.java


示例17: execute

import com.woorea.openstack.keystone.Keystone; //导入依赖的package包/类
@Override
public void execute(Console console, CommandLine args) {
	
	if(args.getArgs().length == 1) {
		Keystone keystone = new Keystone((String) console.getProperty("keystone.endpoint"));
		
		Access access = keystone.tokens().authenticate(
			new UsernamePassword(
				console.getProperty("keystone.username"), 
				console.getProperty("keystone.password")
			)
		)
		.withTenantName(console.getProperty("keystone.tenant_name"))
		.execute();
		
		System.out.println(console.getProperty("nova.endpoint"));
		
		Nova client = new Nova(console.getProperty("nova.endpoint")+args.getArgs()[0]);
		client.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
		
		NovaEnvironment environment = new NovaEnvironment(console.getEnvironment(), client);
		
		environment.register(new NovaServerList());
		
		console.setEnvironment(environment);
			
	}
	
}
 
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:30,代码来源:NovaEnvironment.java


示例18: execute

import com.woorea.openstack.keystone.Keystone; //导入依赖的package包/类
@Override
public void execute(Keystone keystone, CommandLine args) {
	
	final Tenants tenants = keystone.tenants().list().execute();
	
	Table t = new Table(new TableModel<Tenant>(tenants.getList()) {

		@Override
		public Column[] getHeaders() {
			return new Column[]{
				new Column("id", 32, Column.ALIGN_LEFT),
				new Column("name", 32, Column.ALIGN_LEFT),
				new Column("description", 32, Column.ALIGN_LEFT),
				new Column("enabled", 7, Column.ALIGN_LEFT)
			};
		}

		@Override
		public String[] getRow(Tenant tenant) {
			return new String[]{
				tenant.getId(),
				tenant.getName(),
				tenant.getDescription(),
				tenant.getEnabled().toString()
			};
		}
	});
	System.out.println(t.render());
}
 
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:30,代码来源:KeystoneTenantList.java


示例19: execute

import com.woorea.openstack.keystone.Keystone; //导入依赖的package包/类
@Override
public void execute(Keystone keystone, CommandLine cmd) {
	
	String[] args = cmd.getArgs();
	if(args.length == 1) {
		keystone.tenants().delete(args[0]).execute();
		System.out.println(new ConsoleUtils().green("OK"));
	}
	
}
 
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:11,代码来源:KeystoneTenantDelete.java


示例20: execute

import com.woorea.openstack.keystone.Keystone; //导入依赖的package包/类
@Override
public void execute(Keystone keystone, CommandLine cmd) {
	
	String[] args = cmd.getArgs();
	if(args.length == 1) {
		keystone.users().delete(args[0]).execute();
		System.out.println(new ConsoleUtils().green("OK"));
	}
	
}
 
开发者ID:CIETstudents,项目名称:openstack-maven-CIET-students,代码行数:11,代码来源:KeystoneUserDelete.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileItemHeadersImpl类代码示例发布时间:2022-05-22
下一篇:
Java CoordinatedBolt类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap