Examples of ServerResource


Examples of com.cloud.resource.ServerResource

        if (dns == null) {
            dns = zone.getDns2();
        }
        params.put("dns", dns);

        ServerResource resource = null;
        try {
            if (cmd.getDhcpType().equalsIgnoreCase(BaremetalDhcpType.DNSMASQ.toString())) {
                resource = new BaremetalDnsmasqResource();
                resource.configure("Dnsmasq resource", params);
            } else if (cmd.getDhcpType().equalsIgnoreCase(BaremetalDhcpType.DHCPD.toString())) {
                resource = new BaremetalDhcpdResource();
                resource.configure("Dhcpd resource", params);
            } else {
                throw new CloudRuntimeException("Unsupport DHCP server type: " + cmd.getDhcpType());
            }
        } catch (Exception e) {
            s_logger.debug(e);
View Full Code Here

Examples of com.cloud.resource.ServerResource

        params.put("password", cmd.getPassword());

        Map<String, Object> hostdetails = new HashMap<String,Object>();
        hostdetails.putAll(params);

        ServerResource resource = new CiscoVnmcResource();
        Transaction txn = Transaction.currentTxn();
        try {
            resource.configure(cmd.getHost(), hostdetails);

            Host host = _resourceMgr.addHost(zoneId, resource, Host.Type.ExternalFirewall, params);
            if (host != null) {
                txn.start();
View Full Code Here

Examples of com.cloud.resource.ServerResource

    }

    @Override
    @DB
    public NiciraNvpDeviceVO addNiciraNvpDevice(AddNiciraNvpDeviceCmd cmd) {
        ServerResource resource = new NiciraNvpResource();
        String deviceName = Network.Provider.NiciraNvp.getName();
        NetworkDevice networkDevice = NetworkDevice.getNetworkDevice(deviceName);
        Long physicalNetworkId = cmd.getPhysicalNetworkId();
        NiciraNvpDeviceVO niciraNvpDevice = null;
       
        PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
        if (physicalNetwork == null) {
            throw new InvalidParameterValueException("Could not find phyical network with ID: " + physicalNetworkId);
        }
        long zoneId = physicalNetwork.getDataCenterId();

        PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(), networkDevice.getNetworkServiceProvder());
        if (ntwkSvcProvider == null) {
            throw new CloudRuntimeException("Network Service Provider: " + networkDevice.getNetworkServiceProvder() +
                    " is not enabled in the physical network: " + physicalNetworkId + "to add this device");
        } else if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown) {
            throw new CloudRuntimeException("Network Service Provider: " + ntwkSvcProvider.getProviderName() +
                    " is in shutdown state in the physical network: " + physicalNetworkId + "to add this device");
        }
       
        if (_niciraNvpDao.listByPhysicalNetwork(physicalNetworkId).size() != 0) {
            throw new CloudRuntimeException("A NiciraNvp device is already configured on this physical network");
        }
       
        Map<String, String> params = new HashMap<String,String>();
        params.put("guid", UUID.randomUUID().toString());
        params.put("zoneId", String.valueOf(physicalNetwork.getDataCenterId()));
        params.put("physicalNetworkId", String.valueOf(physicalNetwork.getId()));
        params.put("name", "Nicira Controller - " + cmd.getHost());
        params.put("ip", cmd.getHost());
        params.put("adminuser", cmd.getUsername());
        params.put("adminpass", cmd.getPassword());
        params.put("transportzoneuuid", cmd.getTransportzoneUuid());
        params.put("transportzoneisotype", physicalNetwork.getIsolationMethods().get(0).toLowerCase()); // FIXME What to do with multiple isolation types

        Map<String, Object> hostdetails = new HashMap<String,Object>();
        hostdetails.putAll(params);
       
       
        Transaction txn = Transaction.currentTxn();
        try {
            resource.configure(cmd.getHost(), hostdetails);
           
            Host host = _resourceMgr.addHost(zoneId, resource, Host.Type.L2Networking, params);
            if (host != null) {
                txn.start();
               
View Full Code Here

Examples of com.cloud.resource.ServerResource

            try {
                impl = Class.forName(name);
                final Constructor<?> constructor = impl
                        .getDeclaredConstructor();
                constructor.setAccessible(true);
                ServerResource resource = (ServerResource) constructor
                        .newInstance();
                launchAgent(getNextAgentId(), resource);
            } catch (final ClassNotFoundException e) {
                throw new ConfigurationException("Resource class not found: "
                        + name + " due to: " + e.toString());
View Full Code Here

Examples of com.cloud.resource.ServerResource

            Class<?> impl;
            try {
                impl = Class.forName(name);
                final Constructor<?> constructor = impl.getDeclaredConstructor();
                constructor.setAccessible(true);
                ServerResource resource = (ServerResource)constructor.newInstance();
                launchAgent(getNextAgentId(), resource);
            } catch (final ClassNotFoundException e) {
              throw new ConfigurationException("Resource class not found: " + name);
            } catch (final SecurityException e) {
              throw new ConfigurationException("Security excetion when loading resource: " + name);
View Full Code Here

Examples of com.cloud.resource.ServerResource

    protected class PingTask implements Runnable {
        @Override
        public synchronized void run() {
            try {
                ServerResource resource = _resource;

                if (resource != null) {
                    PingCommand cmd = resource.getCurrentStatus(_id);
                    if (cmd == null) {
                        s_logger.warn("Unable to get current status on " + _id);
                        _mgr.disconnectWithInvestigation(DirectAgentAttache.this, Event.AgentDisconnected);
                        return;
                    }
View Full Code Here

Examples of com.cloud.resource.ServerResource

        @Override
        public void run() {
            long seq = _req.getSequence();
            try {
                ServerResource resource = _resource;
                Command[] cmds = _req.getCommands();
                boolean stopOnError = _req.stopOnError();

                if (s_logger.isDebugEnabled()) {
                    s_logger.debug(log(seq, "Executing request"));
                }
                ArrayList<Answer> answers = new ArrayList<Answer>(cmds.length);
                for (int i = 0; i < cmds.length; i++) {
                    Answer answer = null;
                    try {
                        if (resource != null) {
                            answer = resource.executeRequest(cmds[i]);
                        } else {
                            answer = new Answer(cmds[i], false, "Agent is disconnected");
                        }
                    } catch (Exception e) {
                        s_logger.warn(log(seq, "Exception Caught while executing command"), e);
View Full Code Here

Examples of org.astrogrid.samp.httpd.ServerResource

        public HttpServer.Response serveRequest(HttpServer.Request request) {
            String path = request.getUrl();
            if (!path.startsWith(basePath_)) {
                return null;
            }
            final ServerResource resource =
                    resourceMap_.get(path);
            if (resource == EXPIRED) {
                return HttpServer.createErrorResponse(410, "Gone");
            } else if (resource != null) {
                Map<String,String> hdrMap = new HashMap<String,String>();
                hdrMap.put("Content-Type", resource.getContentType());
                long contentLength = resource.getContentLength();
                if (contentLength >= 0) {
                    hdrMap.put("Content-Length",
                            Long.toString(contentLength));
                }
                String method = request.getMethod();
                if (method.equals("HEAD")) {
                    return new HttpServer.Response(200, "OK", hdrMap) {
                        public void writeBody(OutputStream out) {
                        }
                    };
                } else if (method.equals("GET")) {
                    return new HttpServer.Response(200, "OK", hdrMap) {
                        public void writeBody(OutputStream out)
                                throws IOException {
                            resource.writeBody(out);
                        }
                    };
                } else {
                    return HttpServer
                            .createErrorResponse(405, "Unsupported method");
View Full Code Here

Examples of org.astrogrid.samp.httpd.ServerResource

         *
         * @param table table
         * @return servable resource
         */
        private ServerResource createResource(final StarTable table) {
            return new ServerResource() {
                public long getContentLength() {
                    return -1L;
                }

                public String getContentType() {
View Full Code Here

Examples of org.restlet.resource.ServerResource


    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable
    {
        ServerResource resource = (ServerResource) invocation.getThis();
        securityCheck.check(resource.getRequest(), resource.getResponse());
        return invocation.proceed();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.