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


Java OSFactory类代码示例

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


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

示例1: teardownTest

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
@Override
public final void teardownTest(JavaSamplerContext context) {
	// we only need one teardown invocation
	if (teardownDone || os == null)
		return;
	teardownDone = true;

	log.debug("cleaning resources");

	try {
		// this method is executed from the JMeter main thread, this means we need to re-wire a token to instantiate
		// a lightweight client without re-authentication
		Access access = os.getAccess();
		os = OSFactory.clientFromAccess(access);

		// call the actual teardown
		teardown(context);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
}
 
开发者ID:savoirfairelinux,项目名称:jmeter-openstack,代码行数:22,代码来源:AbstractOpenstackSampler.java

示例2: OSClientFactory

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
/**
 * Creates an {@link OSClientFactory} with a custom {@link OSClientCreator}.
 *
 * @param apiAccessConfig
 *            API access configuration that describes how to authenticate
 *            with and communicate over the OpenStack API.
 *
 */
public OSClientFactory(ApiAccessConfig apiAccessConfig, OSClientBuilder clientBuilder) {
    checkArgument(apiAccessConfig != null, "no apiAccessConfig given");
    checkArgument(clientBuilder != null, "no clientBuilder given");
    apiAccessConfig.validate();

    this.apiAccessConfig = apiAccessConfig;
    this.clientBuilder = clientBuilder;

    if (apiAccessConfig.shouldLogHttpRequests()) {
        LOG.debug("setting up HTTP request logging");
        // enable logging of each http request from openstack4j
        OSFactory.enableHttpLoggingFilter(true);
        // Install slf4j logging bridge to capture java.util.logging output
        // from the openstack4j. NOTE: the logger appears to be named 'os'.
        SLF4JBridgeHandler.removeHandlersForRootLogger();
        SLF4JBridgeHandler.install();
    }
}
 
开发者ID:elastisys,项目名称:scale.commons,代码行数:27,代码来源:OSClientFactory.java

示例3: Authorize

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
public static OSClient Authorize(JSONObject credentials,
		JSONObject endpointsAPI) {
	JSONObject auth = (JSONObject) credentials.get("auth");
	String tenantId = (String) auth.get("tenantId");
	JSONObject pwdcred = (JSONObject) auth.get("passwordCredentials");
	String username = (String) pwdcred.get("username");
	String password = (String) pwdcred.get("password");

	String identityService = (String) endpointsAPI.get("os-identity-api");

	OSClient os = OSFactory.builder().endpoint(identityService)
			.credentials(username, password).tenantId(tenantId)
			.authenticate();

	return os;
}
 
开发者ID:tosca-types,项目名称:openstack,代码行数:17,代码来源:OSUtilities.java

示例4: create

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
@Override
public synchronized OSClient create() {

  checkState(cloud.endpoint().isPresent(),
      String.format("%s requires endpoint to be present", this));

  final String[] split = cloud.credential().user().split(":");
  checkState(split.length == 2, "Illegal username, expected tenant:user");
  final String tenantName = split[0];
  final String userName = split[1];

  if (access == null) {
    final OSClient.OSClientV2 authenticate =
        OSFactory.builderV2().endpoint(cloud.endpoint().get())
            .credentials(userName, cloud.credential().password()).tenantName(tenantName)
            .authenticate();
    this.access = authenticate.getAccess();
    return authenticate;
  }
  return OSFactory.clientFromAccess(access);
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:22,代码来源:OsClientV2Factory.java

示例5: authFromServiceConfiguration

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
private OSClient authFromServiceConfiguration() {

    final String[] split = cloud.credential().user().split(":");
    checkState(split.length == 3, String
        .format("Illegal username, expected user to be of format domain:tenant:user, got %s",
            cloud.credential().user()));

    final String domainId = split[0];
    final String tenantId = split[1];
    final String userId = split[2];

    //todo resolve identifier from credentials
    Identifier domainIdentifier = Identifier.byId(domainId);
    Identifier tenantIdentifier = Identifier.byId(tenantId);

    checkState(cloud.endpoint().isPresent(), "Endpoint is required for Openstack4J Driver.");

    return OSFactory.builderV3().endpoint(cloud.endpoint().get())
        .credentials(userId, cloud.credential().password(), domainIdentifier)
        .scopeToProject(tenantIdentifier).authenticate();
  }
 
开发者ID:cloudiator,项目名称:sword,代码行数:22,代码来源:OsClientV3Factory.java

示例6: authenticate

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
private boolean authenticate() {
    if (_has_input_authtoken) {
        return false;
    }

    _authtoken = null;
    if ("keystone".equals(_authtype)) {
        try {
            OSClient os = OSFactory.builder().endpoint(_authurl)
                .credentials(_username, _password).tenantName(_tenant).authenticate();
            _authtoken = os.getToken().getId();
            return true;
        }
        catch (AuthenticationException authe) {
            s_logger.warn("authenticate to keystone " + _authurl + "failed: " + authe);
            return false;
        }
    }

    // authenticate type unknown
    return false;
}
 
开发者ID:Juniper,项目名称:contrail-java-api,代码行数:23,代码来源:ApiConnectorImpl.java

示例7: getOSClientV3

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
/**
 * Function that authenticates to openstack using v3 APIs.
 * @param endPoint
 * @param userName
 * @param password
 * @param domain
 * @param project
 * @return OSClient object that can be used for other OpenStack operations.
 */
public static void getOSClientV3(String endPoint, String userName, String password,
		String domain, String project) {

	if(os == null || apiVersion == null ||apiVersion != 3 || ! os.getEndpoint().equals(endPoint)) {

		Identifier domainIdentifier = Identifier.byName(domain);
		Identifier projectIdentifier = Identifier.byName(project);
		os = OSFactory.builderV3()
				.scopeToProject(projectIdentifier, domainIdentifier)
				.endpoint(endPoint)
				.credentials(userName, password, domainIdentifier)
				.authenticate();

		apiVersion = 3;
	}
}
 
开发者ID:apache,项目名称:airavata,代码行数:26,代码来源:OS4JClientProvider.java

示例8: getOSClientV2

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
/**
 * Function that authenticates to openstack using v2 APIs.
 * @param endPoint
 * @param userName
 * @param password
 * @param domain
 * @param project
 * @return OSClient object that can be used for other Openstack operations.
 */
public static void getOSClientV2(String endPoint, String userName, String password,
		String domain) {

	if(os == null || apiVersion == null ||apiVersion != 2 || ! os.getEndpoint().equals(endPoint)) {

		Identifier domainIdentifier = Identifier.byName(domain);
		//Identifier projectIdentifier = Identifier.byName(project);
		os = OSFactory.builderV3()
				//.scopeToProject(projectIdentifier, domainIdentifier)
				.endpoint(endPoint)
				.credentials(userName, password, domainIdentifier)
				.authenticate();

		apiVersion = 2;
	}
}
 
开发者ID:apache,项目名称:airavata,代码行数:26,代码来源:OS4JClientProvider.java

示例9: create

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
@Override
public V3 create(IBMObjectStorageServiceInfo serviceInfo,
        ServiceConnectorConfig serviceConnectorConfig) {
    final Identifier domainIdent = Identifier.byName(serviceInfo.getDomainName());
    final Identifier projectIdent = Identifier.byName(serviceInfo.getProject());
    return OSFactory.builderV3().endpoint(serviceInfo.getAuthUrl())
            .credentials(serviceInfo.getUserId(), serviceInfo.getPassword())
            .scopeToProject(projectIdent, domainIdent);
}
 
开发者ID:IBM-Cloud,项目名称:bluemix-cloud-connectors,代码行数:10,代码来源:V3InstanceCreator.java

示例10: getAvailableSession

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
OSClient.OSClientV3 getAvailableSession(Endpoint endpoint) {

        OSClient.OSClientV3 localOs;
        Config config = Config.newConfig().withSSLContext(endpoint.getSslContext()).withHostnameVerifier((hostname, session) -> true);
        if (connectionsMap.containsKey(endpoint)) {
            localOs = OSFactory.clientFromToken(connectionsMap.get(endpoint), Facing.PUBLIC, config);
        } else {
            String endpointURL;
            try {
                endpointURL = prepareEndpointURL(endpoint);
            } catch (URISyntaxException | MalformedURLException e) {
                throw new RuntimeException(e.getMessage(), e);
            }

            // LOGGER
            OSFactory.enableHttpLoggingFilter(log.isDebugEnabled() || log.isInfoEnabled());

            Identifier domainIdentifier = Identifier.byId(endpoint.getDomainId());

            IOSClientBuilder.V3 keystoneV3Builder = OSFactory.builderV3().perspective(Facing.PUBLIC)
                    .endpoint(endpointURL)
                    .credentials(endpoint.getUser(), endpoint.getPassword(), domainIdentifier)
                    .scopeToProject(Identifier.byName(endpoint.getProject()), domainIdentifier)
                    .withConfig(config);

            localOs = keystoneV3Builder.authenticate();
            connectionsMap.put(endpoint, localOs.getToken());
        }

        return localOs;
    }
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:32,代码来源:KeystoneProvider.java

示例11: OpenStackService

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
public OpenStackService() {
	openStack = OSFactory
			.builder()
			.endpoint(TestConfiguration.openStackURL())
			.credentials(TestConfiguration.openStackUsername(),
					TestConfiguration.openStackPassword())
			.tenantName(TestConfiguration.openStackTenant()).authenticate();
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:9,代码来源:OpenStackService.java

示例12: authenticateV3

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
public static OpenstackConnectionFactory authenticateV3(String authUrl, String userDomainName) {
	Assert.notNull(username, "Username may not be empty, when initializing");
	Assert.notNull(password, "Password may not be empty, when initializing");

	log.info("Initializing Provider:" + PROVIDER);

	osClient = OSFactory.builderV3().endpoint(authUrl).credentials(username, password, Identifier.byName(userDomainName))
			.authenticate();
	return instance;
}
 
开发者ID:evoila,项目名称:cfsummiteu2017,代码行数:11,代码来源:OpenstackConnectionFactory.java

示例13: getOpenStackClient

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
private OSClient getOpenStackClient(OpenStackAccess osAccess) {
    checkNotNull(osAccess);

    // creating a client every time must be inefficient, but this method
    // will be removed once XOS provides equivalent APIs
    return OSFactory.builder()
            .endpoint(osAccess.endpoint())
            .credentials(osAccess.user(), osAccess.password())
            .tenantName(osAccess.tenant())
            .authenticate();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:DefaultVtnServiceApi.java

示例14: authenticateAndGetObjectStorageService

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
private ObjectStorageService authenticateAndGetObjectStorageService() {
	String OBJECT_STORAGE_AUTH_URL = "https://identity.open.softlayer.com/v3";

	Identifier domainIdentifier = Identifier.byName(DOMAIN_ID);

	System.out.println("Authenticating...");

	OSClientV3 os = OSFactory.builderV3()
			.endpoint(OBJECT_STORAGE_AUTH_URL)
			.credentials(USERNAME,PASSWORD, domainIdentifier)
			.scopeToProject(Identifier.byId(PROJECT_ID))
			.authenticate();

	System.out.println("Authenticated successfully!");

	ObjectStorageService objectStorage = os.objectStorage();

	return objectStorage;
}
 
开发者ID:ibm-bluemix-mobile-services,项目名称:bluemix-objectstorage-sample-liberty,代码行数:20,代码来源:SimpleServlet.java

示例15: buildOSClient

import org.openstack4j.openstack.OSFactory; //导入依赖的package包/类
private static OSClient buildOSClient() {
    String sslEnabled=configprop.getProperty("OS_ENABLE_SSL");
    Boolean isSSLEnabled = new Boolean(sslEnabled); 
    String v3Authentication=configprop.getProperty("OS_ENABLE_V3_AUTHENTICATION");
    Boolean v3AuthenticationEnabled = new Boolean(v3Authentication);
    if(v3AuthenticationEnabled)
        os = OSFactory.builderV3().useNonStrictSSLClient(isSSLEnabled).scopeToProject(Identifier.byId(configprop.getProperty("OS_TENANT_ID")), Identifier.byName(configprop.getProperty("OS_DOMAIN")))
            .credentials(configprop.getProperty("OS_USERNAME"), configprop.getProperty("OS_PASSWORD"), Identifier.byName(configprop.getProperty("OS_DOMAIN"))).endpoint(configprop.getProperty("OS_AUTH_URL"))
            .authenticate();
    else
        os = OSFactory.builderV2().endpoint(configprop.getProperty("OS_AUTH_URL")).credentials(configprop.getProperty("OS_USERNAME"), configprop.getProperty("OS_PASSWORD")).tenantId(configprop.getProperty("OS_TENANT_ID")).useNonStrictSSLClient(isSSLEnabled).authenticate();
    
    return os;
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:15,代码来源:Osp4jSession.java


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