/**
 * 
 * This software is licensed under the GNU General Public License v3 or later.
 * 
 * It is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package com.cloud.hypervisor.xen.resource;


import javax.ejb.Local;
import org.apache.log4j.Logger;
import org.apache.xmlrpc.XmlRpcException;

import com.cloud.hypervisor.xen.resource.CitrixResourceBase;
import com.xensource.xenapi.VM;
import com.cloud.resource.ServerResource;
import com.xensource.xenapi.Connection;
import com.xensource.xenapi.Types.XenAPIException;


@Local(value=ServerResource.class)
public class XenServerResource extends CitrixResourceBase {
    private static final Logger s_logger = Logger.getLogger(XenServerResource.class);
    
   
    public XenServerResource() {
        super();
    }
    
    @Override
    protected String getGuestOsType(String stdType, boolean bootFromCD) {
    	return CitrixHelper.getXenServerGuestOsType(stdType);
    }

    @Override
    protected void setMemory(Connection conn, VM vm, long memsize) throws XmlRpcException, XenAPIException {
        vm.setMemoryLimits(conn, memsize, memsize, memsize, memsize);
    }   
 
    @Override
    protected String getPatchPath() {
        return "scripts/vm/hypervisor/xenserver/xenserver56";
    }

}

@@ -850,16 +850,191 @@
 ption;%0A%0A
+import com.cloud.agent.api.Answer;%0Aimport com.cloud.agent.api.Command;%0Aimport com.cloud.agent.api.NetworkIngressRuleAnswer;%0Aimport com.cloud.agent.api.NetworkIngressRulesCmd;%0A
 import c
@@ -1086,16 +1086,16 @@
 ceBase;%0A
-
 import c
@@ -1439,20 +1439,16 @@
 );%0A    %0A
-   %0A
     publ
@@ -1506,32 +1506,296 @@
  %0A    @Override%0A
+    public Answer executeRequest(Command cmd) %7B       %0A        if (cmd instanceof NetworkIngressRulesCmd) %7B%0A            return execute((NetworkIngressRulesCmd) cmd);%0A        %7D else %7B%0A            return super.executeRequest(cmd);%0A        %7D%0A    %7D%0A    %0A    @Override%0A
     protected St
@@ -2170,24 +2170,24 @@
 tchPath() %7B%0A
-
         retu
@@ -2241,12 +2241,1544 @@
 %22;%0A    %7D
+ %0A    %0A    @Override%0A    protected boolean can_bridge_firewall() %7B   %0A        return Boolean.valueOf(callHostPlugin(%22vmops%22, %22can_bridge_firewall%22, %22host_uuid%22, _host.uuid));%0A    %7D%0A    %0A    private Answer execute(NetworkIngressRulesCmd cmd) %7B%0A        if (s_logger.isTraceEnabled()) %7B%0A            s_logger.trace(%22Sending network rules command to %22 + _host.ip);%0A        %7D%0A%0A        if (!_canBridgeFirewall) %7B%0A            s_logger.info(%22Host %22 + _host.ip + %22 cannot do bridge firewalling%22);%0A            return new NetworkIngressRuleAnswer(cmd, false, %22Host %22 + _host.ip + %22 cannot do bridge firewalling%22);%0A        %7D%0A      %0A        String result = callHostPlugin(%22vmops%22, %22network_rules%22,%0A                %22vmName%22, cmd.getVmName(),%0A                %22vmIP%22, cmd.getGuestIp(),%0A                %22vmMAC%22, cmd.getGuestMac(),%0A                %22vmID%22, Long.toString(cmd.getVmId()),%0A                %22signature%22, cmd.getSignature(),%0A                %22seqno%22, Long.toString(cmd.getSeqNum()),%0A                %22rules%22, cmd.stringifyRules());%0A%0A        if (result == null %7C%7C result.isEmpty() %7C%7C !Boolean.parseBoolean(result)) %7B%0A            s_logger.warn(%22Failed to program network rules for vm %22 + cmd.getVmName());%0A            return new NetworkIngressRuleAnswer(cmd, false, %22programming network rules failed%22);%0A        %7D else %7B%0A            s_logger.info(%22Programmed network rules for vm %22 + cmd.getVmName() + %22 guestIp=%22 + cmd.getGuestIp() + %22, numrules=%22 + cmd.getRuleSet().length);%0A            return new NetworkIngressRuleAnswer(cmd);%0A        %7D%0A    %7D
 %0A%0A%7D%0A

move network group to oss