All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ovirt.engine.sdk4.internal.services.HostServiceImpl Maven / Gradle / Ivy

There is a newer version: 4.5.1
Show newest version
/*
Copyright (c) 2015 Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package org.ovirt.engine.sdk4.internal.services;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.String;
import java.math.BigInteger;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.util.EntityUtils;
import org.ovirt.api.metamodel.runtime.xml.XmlReader;
import org.ovirt.api.metamodel.runtime.xml.XmlWriter;
import org.ovirt.engine.sdk4.Error;
import org.ovirt.engine.sdk4.Service;
import org.ovirt.engine.sdk4.builders.ActionBuilder;
import org.ovirt.engine.sdk4.builders.ClusterBuilder;
import org.ovirt.engine.sdk4.builders.HostBuilder;
import org.ovirt.engine.sdk4.builders.HostNicBuilder;
import org.ovirt.engine.sdk4.builders.IscsiDetailsBuilder;
import org.ovirt.engine.sdk4.builders.NetworkAttachmentBuilder;
import org.ovirt.engine.sdk4.builders.NetworkLabelBuilder;
import org.ovirt.engine.sdk4.builders.SshBuilder;
import org.ovirt.engine.sdk4.internal.HttpConnection;
import org.ovirt.engine.sdk4.internal.xml.XmlActionWriter;
import org.ovirt.engine.sdk4.internal.xml.XmlHostReader;
import org.ovirt.engine.sdk4.internal.xml.XmlHostWriter;
import org.ovirt.engine.sdk4.services.AssignedAffinityLabelsService;
import org.ovirt.engine.sdk4.services.AssignedPermissionsService;
import org.ovirt.engine.sdk4.services.AssignedTagsService;
import org.ovirt.engine.sdk4.services.FenceAgentsService;
import org.ovirt.engine.sdk4.services.HostDevicesService;
import org.ovirt.engine.sdk4.services.HostHooksService;
import org.ovirt.engine.sdk4.services.HostNicsService;
import org.ovirt.engine.sdk4.services.HostNumaNodesService;
import org.ovirt.engine.sdk4.services.HostService;
import org.ovirt.engine.sdk4.services.HostStorageService;
import org.ovirt.engine.sdk4.services.KatelloErrataService;
import org.ovirt.engine.sdk4.services.NetworkAttachmentsService;
import org.ovirt.engine.sdk4.services.StatisticsService;
import org.ovirt.engine.sdk4.services.StorageServerConnectionExtensionsService;
import org.ovirt.engine.sdk4.services.UnmanagedNetworksService;
import org.ovirt.engine.sdk4.types.Action;
import org.ovirt.engine.sdk4.types.Cluster;
import org.ovirt.engine.sdk4.types.Host;
import org.ovirt.engine.sdk4.types.HostNic;
import org.ovirt.engine.sdk4.types.IscsiDetails;
import org.ovirt.engine.sdk4.types.NetworkAttachment;
import org.ovirt.engine.sdk4.types.NetworkLabel;
import org.ovirt.engine.sdk4.types.PowerManagement;
import org.ovirt.engine.sdk4.types.Ssh;
import org.ovirt.engine.sdk4.types.StorageDomain;

public class HostServiceImpl extends ServiceImpl implements HostService {
    
    public HostServiceImpl(HttpConnection connection, String path) {
        super(connection, path);
    }
    
    private class ActivateRequestImpl implements ActivateRequest {
        private Boolean async;
        public ActivateRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        public ActivateResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/activate");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new ActivateResponseImpl();
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class ActivateResponseImpl implements ActivateResponse {
    }
    
    public ActivateRequest activate() {
        return new ActivateRequestImpl();
    }
    
    private class ApproveRequestImpl implements ApproveRequest {
        private Boolean async;
        public ApproveRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        private Cluster cluster;
        public ApproveRequest cluster(Cluster cluster) {
            this.cluster = cluster;
            return this;
        }
        
        public ApproveRequest cluster(ClusterBuilder cluster) {
            this.cluster = cluster.build();
            return this;
        }
        
        public ApproveResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/approve");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                action.cluster(cluster);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new ApproveResponseImpl();
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class ApproveResponseImpl implements ApproveResponse {
    }
    
    public ApproveRequest approve() {
        return new ApproveRequestImpl();
    }
    
    private class CommitNetConfigRequestImpl implements CommitNetConfigRequest {
        private Boolean async;
        public CommitNetConfigRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        public CommitNetConfigResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/commitnetconfig");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new CommitNetConfigResponseImpl();
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class CommitNetConfigResponseImpl implements CommitNetConfigResponse {
    }
    
    public CommitNetConfigRequest commitNetConfig() {
        return new CommitNetConfigRequestImpl();
    }
    
    private class DeactivateRequestImpl implements DeactivateRequest {
        private Boolean async;
        public DeactivateRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        private String reason;
        public DeactivateRequest reason(String reason) {
            this.reason = reason;
            return this;
        }
        
        private Boolean stopGlusterService;
        public DeactivateRequest stopGlusterService(Boolean stopGlusterService) {
            this.stopGlusterService = stopGlusterService;
            return this;
        }
        
        public DeactivateResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/deactivate");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                action.reason(reason);
                action.stopGlusterService(stopGlusterService);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new DeactivateResponseImpl();
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class DeactivateResponseImpl implements DeactivateResponse {
    }
    
    public DeactivateRequest deactivate() {
        return new DeactivateRequestImpl();
    }
    
    private class EnrollCertificateRequestImpl implements EnrollCertificateRequest {
        private Boolean async;
        public EnrollCertificateRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        public EnrollCertificateResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/enrollcertificate");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new EnrollCertificateResponseImpl();
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class EnrollCertificateResponseImpl implements EnrollCertificateResponse {
    }
    
    public EnrollCertificateRequest enrollCertificate() {
        return new EnrollCertificateRequestImpl();
    }
    
    private class FenceRequestImpl implements FenceRequest {
        private Boolean async;
        public FenceRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        private String fenceType;
        public FenceRequest fenceType(String fenceType) {
            this.fenceType = fenceType;
            return this;
        }
        
        public FenceResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/fence");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                action.fenceType(fenceType);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new FenceResponseImpl(action.powerManagement());
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class FenceResponseImpl implements FenceResponse {
        private PowerManagement powerManagement;
        
        public FenceResponseImpl(PowerManagement powerManagement) {
            this.powerManagement = powerManagement;
        }
        
        public PowerManagement powerManagement() {
            return powerManagement;
        }
        
    }
    
    public FenceRequest fence() {
        return new FenceRequestImpl();
    }
    
    private class ForceSelectSpmRequestImpl implements ForceSelectSpmRequest {
        private Boolean async;
        public ForceSelectSpmRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        public ForceSelectSpmResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/forceselectspm");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new ForceSelectSpmResponseImpl();
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class ForceSelectSpmResponseImpl implements ForceSelectSpmResponse {
    }
    
    public ForceSelectSpmRequest forceSelectSpm() {
        return new ForceSelectSpmRequestImpl();
    }
    
    private class GetRequestImpl implements GetRequest {
        private Boolean filter;
        public GetRequest filter(Boolean filter) {
            this.filter = filter;
            return this;
        }
        
        public GetResponse send() {
            HttpGet request = null;
            try {
                URIBuilder uriBuilder = new URIBuilder(getConnection().getUrl() + getPath());
                if (filter != null) {
                    uriBuilder.addParameter("filter", XmlWriter.renderBoolean(filter));
                }
                request = new HttpGet(uriBuilder.build());
            }
            catch (URISyntaxException ex) {
                throw new Error("Failed to build URL", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (
              response.getStatusLine().getStatusCode() == 200
            ) {
                try (
                  XmlReader reader = new XmlReader(response.getEntity().getContent())
                ) {
                    return new GetResponseImpl(XmlHostReader.readOne(reader));
                }
                catch (IOException ex) {
                    throw new Error("Failed to read response", ex);
                }
                finally {
                    EntityUtils.consumeQuietly(response.getEntity());
                }
            }
            else {
                checkFault(response);
                return new GetResponseImpl(null);
            }
        }
        
    }
    
    private class GetResponseImpl implements GetResponse {
        private Host host;
        
        public GetResponseImpl(Host host) {
            this.host = host;
        }
        
        public Host host() {
            return host;
        }
        
    }
    
    public GetRequest get() {
        return new GetRequestImpl();
    }
    
    private class InstallRequestImpl implements InstallRequest {
        private Boolean async;
        public InstallRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        private Boolean deployHostedEngine;
        public InstallRequest deployHostedEngine(Boolean deployHostedEngine) {
            this.deployHostedEngine = deployHostedEngine;
            return this;
        }
        
        private Host host;
        public InstallRequest host(Host host) {
            this.host = host;
            return this;
        }
        
        public InstallRequest host(HostBuilder host) {
            this.host = host.build();
            return this;
        }
        
        private String image;
        public InstallRequest image(String image) {
            this.image = image;
            return this;
        }
        
        private String rootPassword;
        public InstallRequest rootPassword(String rootPassword) {
            this.rootPassword = rootPassword;
            return this;
        }
        
        private Ssh ssh;
        public InstallRequest ssh(Ssh ssh) {
            this.ssh = ssh;
            return this;
        }
        
        public InstallRequest ssh(SshBuilder ssh) {
            this.ssh = ssh.build();
            return this;
        }
        
        private Boolean undeployHostedEngine;
        public InstallRequest undeployHostedEngine(Boolean undeployHostedEngine) {
            this.undeployHostedEngine = undeployHostedEngine;
            return this;
        }
        
        public InstallResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/install");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                action.deployHostedEngine(deployHostedEngine);
                action.host(host);
                action.image(image);
                action.rootPassword(rootPassword);
                action.ssh(ssh);
                action.undeployHostedEngine(undeployHostedEngine);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new InstallResponseImpl();
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class InstallResponseImpl implements InstallResponse {
    }
    
    public InstallRequest install() {
        return new InstallRequestImpl();
    }
    
    private class IscsiDiscoverRequestImpl implements IscsiDiscoverRequest {
        private Boolean async;
        public IscsiDiscoverRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        private IscsiDetails iscsi;
        public IscsiDiscoverRequest iscsi(IscsiDetails iscsi) {
            this.iscsi = iscsi;
            return this;
        }
        
        public IscsiDiscoverRequest iscsi(IscsiDetailsBuilder iscsi) {
            this.iscsi = iscsi.build();
            return this;
        }
        
        public IscsiDiscoverResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/iscsidiscover");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                action.iscsi(iscsi);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new IscsiDiscoverResponseImpl(action.iscsiTargets());
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class IscsiDiscoverResponseImpl implements IscsiDiscoverResponse {
        private List iscsiTargets;
        
        public IscsiDiscoverResponseImpl(List iscsiTargets) {
            this.iscsiTargets = iscsiTargets;
        }
        
        public List iscsiTargets() {
            return iscsiTargets;
        }
        
    }
    
    public IscsiDiscoverRequest iscsiDiscover() {
        return new IscsiDiscoverRequestImpl();
    }
    
    private class IscsiLoginRequestImpl implements IscsiLoginRequest {
        private Boolean async;
        public IscsiLoginRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        private IscsiDetails iscsi;
        public IscsiLoginRequest iscsi(IscsiDetails iscsi) {
            this.iscsi = iscsi;
            return this;
        }
        
        public IscsiLoginRequest iscsi(IscsiDetailsBuilder iscsi) {
            this.iscsi = iscsi.build();
            return this;
        }
        
        public IscsiLoginResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/iscsilogin");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                action.iscsi(iscsi);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new IscsiLoginResponseImpl();
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class IscsiLoginResponseImpl implements IscsiLoginResponse {
    }
    
    public IscsiLoginRequest iscsiLogin() {
        return new IscsiLoginRequestImpl();
    }
    
    private class RefreshRequestImpl implements RefreshRequest {
        private Boolean async;
        public RefreshRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        public RefreshResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/refresh");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new RefreshResponseImpl();
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class RefreshResponseImpl implements RefreshResponse {
    }
    
    public RefreshRequest refresh() {
        return new RefreshRequestImpl();
    }
    
    private class RemoveRequestImpl implements RemoveRequest {
        private Boolean async;
        public RemoveRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        public RemoveResponse send() {
            HttpDelete request = null;
            try {
                URIBuilder uriBuilder = new URIBuilder(getConnection().getUrl() + getPath());
                if (async != null) {
                    uriBuilder.addParameter("async", XmlWriter.renderBoolean(async));
                }
                request = new HttpDelete(uriBuilder.build());
            }
            catch (URISyntaxException ex) {
                throw new Error("Failed to build URL", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (
              response.getStatusLine().getStatusCode() == 200
            ) {
                EntityUtils.consumeQuietly(response.getEntity());
                return new RemoveResponseImpl();
            }
            else {
                checkFault(response);
                return new RemoveResponseImpl();
            }
        }
        
    }
    
    private class RemoveResponseImpl implements RemoveResponse {
    }
    
    public RemoveRequest remove() {
        return new RemoveRequestImpl();
    }
    
    private class SetupNetworksRequestImpl implements SetupNetworksRequest {
        private Boolean async;
        public SetupNetworksRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        private Boolean checkConnectivity;
        public SetupNetworksRequest checkConnectivity(Boolean checkConnectivity) {
            this.checkConnectivity = checkConnectivity;
            return this;
        }
        
        private BigInteger connectivityTimeout;
        public SetupNetworksRequest connectivityTimeout(BigInteger connectivityTimeout) {
            this.connectivityTimeout = connectivityTimeout;
            return this;
        }
        
        public SetupNetworksRequest connectivityTimeout(Integer connectivityTimeout) {
            this.connectivityTimeout = BigInteger.valueOf(connectivityTimeout);
            return this;
        }
        
        public SetupNetworksRequest connectivityTimeout(Long connectivityTimeout) {
            this.connectivityTimeout = BigInteger.valueOf(connectivityTimeout);
            return this;
        }
        
        private List modifiedBonds;
        public SetupNetworksRequest modifiedBonds(List modifiedBonds) {
            this.modifiedBonds = modifiedBonds;
            return this;
        }
        
        public SetupNetworksRequest modifiedBonds(HostNic... modifiedBonds) {
            this.modifiedBonds = Arrays.asList(modifiedBonds);
            return this;
        }
        
        public SetupNetworksRequest modifiedBonds(HostNicBuilder... modifiedBonds) {
            this.modifiedBonds = new ArrayList<>(modifiedBonds.length);
            for (HostNicBuilder element : modifiedBonds) {
                this.modifiedBonds.add(element.build());
            }
            return this;
        }
        
        private List modifiedLabels;
        public SetupNetworksRequest modifiedLabels(List modifiedLabels) {
            this.modifiedLabels = modifiedLabels;
            return this;
        }
        
        public SetupNetworksRequest modifiedLabels(NetworkLabel... modifiedLabels) {
            this.modifiedLabels = Arrays.asList(modifiedLabels);
            return this;
        }
        
        public SetupNetworksRequest modifiedLabels(NetworkLabelBuilder... modifiedLabels) {
            this.modifiedLabels = new ArrayList<>(modifiedLabels.length);
            for (NetworkLabelBuilder element : modifiedLabels) {
                this.modifiedLabels.add(element.build());
            }
            return this;
        }
        
        private List modifiedNetworkAttachments;
        public SetupNetworksRequest modifiedNetworkAttachments(List modifiedNetworkAttachments) {
            this.modifiedNetworkAttachments = modifiedNetworkAttachments;
            return this;
        }
        
        public SetupNetworksRequest modifiedNetworkAttachments(NetworkAttachment... modifiedNetworkAttachments) {
            this.modifiedNetworkAttachments = Arrays.asList(modifiedNetworkAttachments);
            return this;
        }
        
        public SetupNetworksRequest modifiedNetworkAttachments(NetworkAttachmentBuilder... modifiedNetworkAttachments) {
            this.modifiedNetworkAttachments = new ArrayList<>(modifiedNetworkAttachments.length);
            for (NetworkAttachmentBuilder element : modifiedNetworkAttachments) {
                this.modifiedNetworkAttachments.add(element.build());
            }
            return this;
        }
        
        private List removedBonds;
        public SetupNetworksRequest removedBonds(List removedBonds) {
            this.removedBonds = removedBonds;
            return this;
        }
        
        public SetupNetworksRequest removedBonds(HostNic... removedBonds) {
            this.removedBonds = Arrays.asList(removedBonds);
            return this;
        }
        
        public SetupNetworksRequest removedBonds(HostNicBuilder... removedBonds) {
            this.removedBonds = new ArrayList<>(removedBonds.length);
            for (HostNicBuilder element : removedBonds) {
                this.removedBonds.add(element.build());
            }
            return this;
        }
        
        private List removedLabels;
        public SetupNetworksRequest removedLabels(List removedLabels) {
            this.removedLabels = removedLabels;
            return this;
        }
        
        public SetupNetworksRequest removedLabels(NetworkLabel... removedLabels) {
            this.removedLabels = Arrays.asList(removedLabels);
            return this;
        }
        
        public SetupNetworksRequest removedLabels(NetworkLabelBuilder... removedLabels) {
            this.removedLabels = new ArrayList<>(removedLabels.length);
            for (NetworkLabelBuilder element : removedLabels) {
                this.removedLabels.add(element.build());
            }
            return this;
        }
        
        private List removedNetworkAttachments;
        public SetupNetworksRequest removedNetworkAttachments(List removedNetworkAttachments) {
            this.removedNetworkAttachments = removedNetworkAttachments;
            return this;
        }
        
        public SetupNetworksRequest removedNetworkAttachments(NetworkAttachment... removedNetworkAttachments) {
            this.removedNetworkAttachments = Arrays.asList(removedNetworkAttachments);
            return this;
        }
        
        public SetupNetworksRequest removedNetworkAttachments(NetworkAttachmentBuilder... removedNetworkAttachments) {
            this.removedNetworkAttachments = new ArrayList<>(removedNetworkAttachments.length);
            for (NetworkAttachmentBuilder element : removedNetworkAttachments) {
                this.removedNetworkAttachments.add(element.build());
            }
            return this;
        }
        
        private List synchronizedNetworkAttachments;
        public SetupNetworksRequest synchronizedNetworkAttachments(List synchronizedNetworkAttachments) {
            this.synchronizedNetworkAttachments = synchronizedNetworkAttachments;
            return this;
        }
        
        public SetupNetworksRequest synchronizedNetworkAttachments(NetworkAttachment... synchronizedNetworkAttachments) {
            this.synchronizedNetworkAttachments = Arrays.asList(synchronizedNetworkAttachments);
            return this;
        }
        
        public SetupNetworksRequest synchronizedNetworkAttachments(NetworkAttachmentBuilder... synchronizedNetworkAttachments) {
            this.synchronizedNetworkAttachments = new ArrayList<>(synchronizedNetworkAttachments.length);
            for (NetworkAttachmentBuilder element : synchronizedNetworkAttachments) {
                this.synchronizedNetworkAttachments.add(element.build());
            }
            return this;
        }
        
        public SetupNetworksResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/setupnetworks");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                action.checkConnectivity(checkConnectivity);
                action.connectivityTimeout(connectivityTimeout);
                action.modifiedBonds(modifiedBonds);
                action.modifiedLabels(modifiedLabels);
                action.modifiedNetworkAttachments(modifiedNetworkAttachments);
                action.removedBonds(removedBonds);
                action.removedLabels(removedLabels);
                action.removedNetworkAttachments(removedNetworkAttachments);
                action.synchronizedNetworkAttachments(synchronizedNetworkAttachments);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new SetupNetworksResponseImpl();
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class SetupNetworksResponseImpl implements SetupNetworksResponse {
    }
    
    public SetupNetworksRequest setupNetworks() {
        return new SetupNetworksRequestImpl();
    }
    
    private class UnregisteredStorageDomainsDiscoverRequestImpl implements UnregisteredStorageDomainsDiscoverRequest {
        private Boolean async;
        public UnregisteredStorageDomainsDiscoverRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        private IscsiDetails iscsi;
        public UnregisteredStorageDomainsDiscoverRequest iscsi(IscsiDetails iscsi) {
            this.iscsi = iscsi;
            return this;
        }
        
        public UnregisteredStorageDomainsDiscoverRequest iscsi(IscsiDetailsBuilder iscsi) {
            this.iscsi = iscsi.build();
            return this;
        }
        
        public UnregisteredStorageDomainsDiscoverResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/unregisteredstoragedomainsdiscover");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                action.iscsi(iscsi);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new UnregisteredStorageDomainsDiscoverResponseImpl(action.storageDomains());
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class UnregisteredStorageDomainsDiscoverResponseImpl implements UnregisteredStorageDomainsDiscoverResponse {
        private List storageDomains;
        
        public UnregisteredStorageDomainsDiscoverResponseImpl(List storageDomains) {
            this.storageDomains = storageDomains;
        }
        
        public List storageDomains() {
            return storageDomains;
        }
        
    }
    
    public UnregisteredStorageDomainsDiscoverRequest unregisteredStorageDomainsDiscover() {
        return new UnregisteredStorageDomainsDiscoverRequestImpl();
    }
    
    private class UpdateRequestImpl implements UpdateRequest {
        private Boolean async;
        public UpdateRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        private Host host;
        public UpdateRequest host(Host host) {
            this.host = host;
            return this;
        }
        
        public UpdateRequest host(HostBuilder host) {
            this.host = host.build();
            return this;
        }
        
        public UpdateResponse send() {
            HttpPut request = null;
            try {
                URIBuilder uriBuilder = new URIBuilder(getConnection().getUrl() + getPath());
                if (async != null) {
                    uriBuilder.addParameter("async", XmlWriter.renderBoolean(async));
                }
                request = new HttpPut(uriBuilder.build());
            }
            catch (URISyntaxException ex) {
                throw new Error("Failed to build URL", ex);
            }
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                XmlHostWriter.writeOne(host, xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to parse response", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (
              response.getStatusLine().getStatusCode() == 200
            ) {
                try (
                  XmlReader reader = new XmlReader(response.getEntity().getContent())
                ) {
                    return new UpdateResponseImpl(XmlHostReader.readOne(reader));
                }
                catch (IOException ex) {
                    throw new Error("Failed to read response", ex);
                }
                finally {
                    EntityUtils.consumeQuietly(response.getEntity());
                }
            }
            else {
                checkFault(response);
                return new UpdateResponseImpl(null);
            }
        }
        
    }
    
    private class UpdateResponseImpl implements UpdateResponse {
        private Host host;
        
        public UpdateResponseImpl(Host host) {
            this.host = host;
        }
        
        public Host host() {
            return host;
        }
        
    }
    
    public UpdateRequest update() {
        return new UpdateRequestImpl();
    }
    
    private class UpgradeRequestImpl implements UpgradeRequest {
        private Boolean async;
        public UpgradeRequest async(Boolean async) {
            this.async = async;
            return this;
        }
        
        public UpgradeResponse send() {
            HttpPost request = new HttpPost(getConnection().getUrl() + getPath() + "/upgrade");
            try (
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              XmlWriter xmlWriter = new XmlWriter(output, true)
            ) {
                ActionBuilder action = new ActionBuilder();
                action.async(async);
                XmlActionWriter.writeOne(action.build(), xmlWriter);
                xmlWriter.flush();
                request.setEntity(new ByteArrayEntity(output.toByteArray()));
            }
            catch (IOException ex) {
                throw new Error("Failed to write request", ex);
            }
            
            HttpResponse response = getConnection().send(request);
            if (response.getStatusLine().getStatusCode() == 200) {
                Action action = checkAction(response);
                EntityUtils.consumeQuietly(response.getEntity());
                return new UpgradeResponseImpl();
            }
            else {
                checkFault(response);
                return null;
            }
        }
        
    }
    
    private class UpgradeResponseImpl implements UpgradeResponse {
    }
    
    public UpgradeRequest upgrade() {
        return new UpgradeRequestImpl();
    }
    
    public AssignedAffinityLabelsService affinityLabelsService() {
        return new AssignedAffinityLabelsServiceImpl(getConnection(), getPath() + "/affinitylabels");
    }
    
    public HostDevicesService devicesService() {
        return new HostDevicesServiceImpl(getConnection(), getPath() + "/devices");
    }
    
    public FenceAgentsService fenceAgentsService() {
        return new FenceAgentsServiceImpl(getConnection(), getPath() + "/fenceagents");
    }
    
    public HostHooksService hooksService() {
        return new HostHooksServiceImpl(getConnection(), getPath() + "/hooks");
    }
    
    public KatelloErrataService katelloErrataService() {
        return new KatelloErrataServiceImpl(getConnection(), getPath() + "/katelloerrata");
    }
    
    public NetworkAttachmentsService networkAttachmentsService() {
        return new NetworkAttachmentsServiceImpl(getConnection(), getPath() + "/networkattachments");
    }
    
    public HostNicsService nicsService() {
        return new HostNicsServiceImpl(getConnection(), getPath() + "/nics");
    }
    
    public HostNumaNodesService numaNodesService() {
        return new HostNumaNodesServiceImpl(getConnection(), getPath() + "/numanodes");
    }
    
    public AssignedPermissionsService permissionsService() {
        return new AssignedPermissionsServiceImpl(getConnection(), getPath() + "/permissions");
    }
    
    public StatisticsService statisticsService() {
        return new StatisticsServiceImpl(getConnection(), getPath() + "/statistics");
    }
    
    public HostStorageService storageService() {
        return new HostStorageServiceImpl(getConnection(), getPath() + "/storage");
    }
    
    public StorageServerConnectionExtensionsService storageConnectionExtensionsService() {
        return new StorageServerConnectionExtensionsServiceImpl(getConnection(), getPath() + "/storageconnectionextensions");
    }
    
    public AssignedTagsService tagsService() {
        return new AssignedTagsServiceImpl(getConnection(), getPath() + "/tags");
    }
    
    public UnmanagedNetworksService unmanagedNetworksService() {
        return new UnmanagedNetworksServiceImpl(getConnection(), getPath() + "/unmanagednetworks");
    }
    
    public Service service(String path) {
        if (path == null) {
            return this;
        }
        
        if (path.equals("affinitylabels")) {
            return affinityLabelsService();
        }
        if (path.startsWith("affinitylabels/")) {
            return affinityLabelsService().service(path.substring(15));
        }
        if (path.equals("devices")) {
            return devicesService();
        }
        if (path.startsWith("devices/")) {
            return devicesService().service(path.substring(8));
        }
        if (path.equals("fenceagents")) {
            return fenceAgentsService();
        }
        if (path.startsWith("fenceagents/")) {
            return fenceAgentsService().service(path.substring(12));
        }
        if (path.equals("hooks")) {
            return hooksService();
        }
        if (path.startsWith("hooks/")) {
            return hooksService().service(path.substring(6));
        }
        if (path.equals("katelloerrata")) {
            return katelloErrataService();
        }
        if (path.startsWith("katelloerrata/")) {
            return katelloErrataService().service(path.substring(14));
        }
        if (path.equals("networkattachments")) {
            return networkAttachmentsService();
        }
        if (path.startsWith("networkattachments/")) {
            return networkAttachmentsService().service(path.substring(19));
        }
        if (path.equals("nics")) {
            return nicsService();
        }
        if (path.startsWith("nics/")) {
            return nicsService().service(path.substring(5));
        }
        if (path.equals("numanodes")) {
            return numaNodesService();
        }
        if (path.startsWith("numanodes/")) {
            return numaNodesService().service(path.substring(10));
        }
        if (path.equals("permissions")) {
            return permissionsService();
        }
        if (path.startsWith("permissions/")) {
            return permissionsService().service(path.substring(12));
        }
        if (path.equals("statistics")) {
            return statisticsService();
        }
        if (path.startsWith("statistics/")) {
            return statisticsService().service(path.substring(11));
        }
        if (path.equals("storage")) {
            return storageService();
        }
        if (path.startsWith("storage/")) {
            return storageService().service(path.substring(8));
        }
        if (path.equals("storageconnectionextensions")) {
            return storageConnectionExtensionsService();
        }
        if (path.startsWith("storageconnectionextensions/")) {
            return storageConnectionExtensionsService().service(path.substring(28));
        }
        if (path.equals("tags")) {
            return tagsService();
        }
        if (path.startsWith("tags/")) {
            return tagsService().service(path.substring(5));
        }
        if (path.equals("unmanagednetworks")) {
            return unmanagedNetworksService();
        }
        if (path.startsWith("unmanagednetworks/")) {
            return unmanagedNetworksService().service(path.substring(18));
        }
        throw new Error("The path " + path + " doesn't correspond to any service");
    }
    
    public String toString() {
        return "HostService:" + getPath();
    }
    
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy