Search in sources :

Example 36 with Domain

use of org.openstack4j.model.identity.v3.Domain in project weblogic-kubernetes-operator by oracle.

the class RestBackendImpl method getDomainsList.

private List<Domain> getDomainsList() {
    CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
    Collection<List<Domain>> c = new ArrayList<List<Domain>>();
    try {
        for (String ns : targetNamespaces) {
            DomainList dl = factory.create().listDomain(ns);
            if (dl != null) {
                c.add(dl.getItems());
            }
        }
        return c.stream().flatMap(Collection::stream).collect(Collectors.toList());
    } catch (ApiException e) {
        throw handleApiException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) CallBuilderFactory(oracle.kubernetes.operator.helpers.CallBuilderFactory) DomainList(oracle.kubernetes.weblogic.domain.v1.DomainList) ArrayList(java.util.ArrayList) List(java.util.List) DomainList(oracle.kubernetes.weblogic.domain.v1.DomainList) Domain(oracle.kubernetes.weblogic.domain.v1.Domain) ApiException(io.kubernetes.client.ApiException)

Example 37 with Domain

use of org.openstack4j.model.identity.v3.Domain in project weblogic-kubernetes-operator by oracle.

the class RestBackendImpl method getClusters.

/**
 * {@inheritDoc}
 */
@Override
public Set<String> getClusters(String domainUID) {
    LOGGER.entering(domainUID);
    if (!isDomainUID(domainUID)) {
        throw new AssertionError(formatMessage(MessageKeys.INVALID_DOMAIN_UID, domainUID));
    }
    authorize(domainUID, Operation.get);
    // Get list of WLS Configured Clusters defined for the corresponding WLS Domain identified by Domain UID
    Domain domain = findDomain(domainUID);
    String namespace = getNamespace(domainUID);
    String adminServerServiceName = getAdminServerServiceName(domain);
    String adminSecretName = getAdminServiceSecretName(domain);
    Map<String, WlsClusterConfig> wlsClusterConfigs = getWLSConfiguredClusters(namespace, adminServerServiceName, adminSecretName);
    Set<String> result = wlsClusterConfigs.keySet();
    LOGGER.exiting(result);
    return result;
}
Also used : WlsClusterConfig(oracle.kubernetes.operator.wlsconfig.WlsClusterConfig) Domain(oracle.kubernetes.weblogic.domain.v1.Domain)

Example 38 with Domain

use of org.openstack4j.model.identity.v3.Domain in project weblogic-kubernetes-operator by oracle.

the class RestBackendImpl method scaleCluster.

/**
 * {@inheritDoc}
 */
@Override
public void scaleCluster(String domainUID, String cluster, int managedServerCount) {
    LOGGER.entering(domainUID, cluster, managedServerCount);
    if (managedServerCount < 0) {
        throw createWebApplicationException(Status.BAD_REQUEST, MessageKeys.INVALID_MANAGE_SERVER_COUNT, managedServerCount);
    }
    authorize(domainUID, cluster, Operation.update);
    List<Domain> domains = getDomainsList();
    Domain domain = findDomain(domainUID, domains);
    String namespace = getNamespace(domainUID, domains);
    verifyWLSConfiguredClusterCapacity(namespace, domain, cluster, managedServerCount);
    updateReplicasForDomain(namespace, domain, cluster, managedServerCount);
    LOGGER.exiting();
}
Also used : Domain(oracle.kubernetes.weblogic.domain.v1.Domain)

Example 39 with Domain

use of org.openstack4j.model.identity.v3.Domain in project weblogic-kubernetes-operator by oracle.

the class HealthCheckHelper method verifyDomainUidUniqueness.

/**
 * Verify that domain UIDs are unique.
 *
 * @throws ApiException exception for k8s API
 */
private HashMap<String, Domain> verifyDomainUidUniqueness() throws ApiException {
    CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
    HashMap<String, Domain> domainUIDMap = new HashMap<>();
    for (String namespace : targetNamespaces) {
        DomainList domainList = factory.create().listDomain(namespace);
        LOGGER.info(MessageKeys.NUMBER_OF_DOMAINS_IN_NAMESPACE, domainList.getItems().size(), namespace);
        // Verify that the domain UID is unique within the k8s cluster.
        for (Domain domain : domainList.getItems()) {
            Domain domain2 = domainUIDMap.put(domain.getSpec().getDomainUID(), domain);
            // Domain UID already exist if not null
            if (domain2 != null) {
                logHealthCheckEvent(MessageKeys.DOMAIN_UID_UNIQUENESS_FAILED, domain.getSpec().getDomainUID(), domain.getMetadata().getName(), domain2.getMetadata().getName());
            }
        }
    }
    return domainUIDMap;
}
Also used : HashMap(java.util.HashMap) DomainList(oracle.kubernetes.weblogic.domain.v1.DomainList) Domain(oracle.kubernetes.weblogic.domain.v1.Domain)

Example 40 with Domain

use of org.openstack4j.model.identity.v3.Domain in project weblogic-kubernetes-operator by oracle.

the class IngressHelperTest method setUp.

@Before
public void setUp() throws ApiException {
    // make sure test bed is clean
    tearDown();
    // Create domain
    Domain domain = new Domain();
    V1ObjectMeta metadata = new V1ObjectMeta();
    metadata.setName("domianIngressHelperTest");
    metadata.setNamespace(namespace);
    domain.setMetadata(metadata);
    DomainSpec spec = new DomainSpec();
    spec.setDomainName("base_domain");
    spec.setDomainUID(domainUID);
    domain.setSpec(spec);
    info = new DomainPresenceInfo(domain);
    // Create scan
    WlsDomainConfig scan = new WlsDomainConfig();
    WlsServerConfig server1Scan = new WlsServerConfig(server1Name, server1Port, server1Name, null);
    WlsServerConfig server2Scan = new WlsServerConfig(server2Name, server2Port, server2Name, null);
    scan.getServerConfigs().put(server1Name, server1Scan);
    scan.getServerConfigs().put(server2Name, server2Scan);
    WlsClusterConfig cluster1Scan = new WlsClusterConfig(clusterName);
    cluster1Scan.getServerConfigs().add(server1Scan);
    cluster1Scan.getServerConfigs().add(server2Scan);
    scan.getClusterConfigs().put(clusterName, cluster1Scan);
    info.setScan(scan);
    ServerKubernetesObjects sko = new ServerKubernetesObjects();
    V1Service service = new V1Service();
    V1ObjectMeta sm = new V1ObjectMeta();
    sm.setName(service1Name);
    sm.setNamespace(namespace);
    service.setMetadata(sm);
    V1ServiceSpec ss = new V1ServiceSpec();
    V1ServicePort port = new V1ServicePort();
    port.setPort(server1Port);
    ss.addPortsItem(port);
    service.setSpec(ss);
    sko.getService().set(service);
    info.getServers().put(server1Name, sko);
    sko = new ServerKubernetesObjects();
    service = new V1Service();
    sm = new V1ObjectMeta();
    sm.setName(service2Name);
    sm.setNamespace(namespace);
    service.setMetadata(sm);
    ss = new V1ServiceSpec();
    port = new V1ServicePort();
    port.setPort(server2Port);
    ss.addPortsItem(port);
    service.setSpec(ss);
    sko.getService().set(service);
    info.getServers().put(server2Name, sko);
    engine = new Engine("IngressHelperTest");
}
Also used : V1ServicePort(io.kubernetes.client.models.V1ServicePort) WlsServerConfig(oracle.kubernetes.operator.wlsconfig.WlsServerConfig) DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) V1ObjectMeta(io.kubernetes.client.models.V1ObjectMeta) WlsClusterConfig(oracle.kubernetes.operator.wlsconfig.WlsClusterConfig) V1ServiceSpec(io.kubernetes.client.models.V1ServiceSpec) V1Service(io.kubernetes.client.models.V1Service) Domain(oracle.kubernetes.weblogic.domain.v1.Domain) WlsDomainConfig(oracle.kubernetes.operator.wlsconfig.WlsDomainConfig) Engine(oracle.kubernetes.operator.work.Engine) Before(org.junit.Before)

Aggregations

Domain (oracle.kubernetes.weblogic.domain.v1.Domain)33 Type (java.lang.reflect.Type)14 ProgressRequestBody (io.kubernetes.client.ProgressRequestBody)7 ProgressResponseBody (io.kubernetes.client.ProgressResponseBody)7 DomainSpec (oracle.kubernetes.weblogic.domain.v1.DomainSpec)7 Domain (org.openstack4j.model.identity.v3.Domain)7 V1ObjectMeta (io.kubernetes.client.models.V1ObjectMeta)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 ApiException (io.kubernetes.client.ApiException)3 V1Service (io.kubernetes.client.models.V1Service)3 HashMap (java.util.HashMap)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 CallBuilderFactory (oracle.kubernetes.operator.helpers.CallBuilderFactory)3 Packet (oracle.kubernetes.operator.work.Packet)3 Test (org.junit.Test)3 HttpUserAgentTest (com.meterware.pseudoserver.HttpUserAgentTest)2 V1ConfigMap (io.kubernetes.client.models.V1ConfigMap)2 V1ServiceList (io.kubernetes.client.models.V1ServiceList)2 List (java.util.List)2