Package com.cloud.hypervisor.vmware.mo

Examples of com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO


            try {
                _serviceContext = VmwareContextFactory.create(_vCenterAddress, _username, _password);
                VmwareHypervisorHost hyperHost = getHyperHost(_serviceContext, cmd);
                assert(hyperHost instanceof HostMO);
               
                HostFirewallSystemMO firewallMo = ((HostMO)hyperHost).getHostFirewallSystemMO();
                boolean bRefresh = false;
                if(firewallMo != null) {
                  HostFirewallInfo firewallInfo = firewallMo.getFirewallInfo();
                  if(firewallInfo != null) {
                    for(HostFirewallRuleset rule : firewallInfo.getRuleset()) {
                      if("vncServer".equalsIgnoreCase(rule.getKey())) {
                        bRefresh = true;
                        firewallMo.enableRuleset("vncServer");
                      } else if("gdbserver".equalsIgnoreCase(rule.getKey())) {
                        bRefresh = true;
                        firewallMo.enableRuleset("gdbserver");
                      }
                    }
                  }
                 
                  if(bRefresh)
                    firewallMo.refreshFirewall();
                }
            } catch (Exception e) {
                s_logger.error("Unable to connect to vSphere server: " + _vCenterAddress, e);
                throw new CloudRuntimeException("Unable to connect to vSphere server: " + _vCenterAddress);
            }
View Full Code Here


    }


    private void prepareHost(HostMO hostMo, String privateTrafficLabel) throws Exception {
        // For ESX host, we need to enable host firewall to allow VNC access
        HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
        if(firewallMo != null) {
            if(hostMo.getHostType() == VmwareHostType.ESX) {
                firewallMo.enableRuleset("vncServer");
                firewallMo.refreshFirewall();
            }
        }

        // prepare at least one network on the vswitch to enable OVF importing
        String vSwitchName = privateTrafficLabel;
View Full Code Here

            }
        }

        // For ESX host, we need to enable host firewall to allow VNC access
        HostMO hostMo = new HostMO(serviceContext, morHost);
        HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
        if(firewallMo != null) {
            firewallMo.enableRuleset("vncServer");
            firewallMo.refreshFirewall();
        }
        return morHost;
    }
View Full Code Here

    }


    private void prepareHost(HostMO hostMo, String privateTrafficLabel) throws Exception {
        // For ESX host, we need to enable host firewall to allow VNC access
        HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
        if(firewallMo != null) {
            if(hostMo.getHostType() == VmwareHostType.ESX) {
                firewallMo.enableRuleset("vncServer");
                firewallMo.refreshFirewall();
            }
        }

        // prepare at least one network on the vswitch to enable OVF importing
        String vSwitchName = privateTrafficLabel;
View Full Code Here

            }
        }

        // For ESX host, we need to enable host firewall to allow VNC access
        HostMO hostMo = new HostMO(serviceContext, morHost);
        HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
        if(firewallMo != null) {
            firewallMo.enableRuleset("vncServer");
            firewallMo.refreshFirewall();
        }
        return morHost;
    }
View Full Code Here

        return _netMgr.getDefaultManagementTrafficLabel(dcId, hypervisorType);
    }

    private void prepareHost(HostMO hostMo, String privateTrafficLabel) throws Exception {
        // For ESX host, we need to enable host firewall to allow VNC access
        HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
        if (firewallMo != null) {
            if (hostMo.getHostType() == VmwareHostType.ESX) {
                firewallMo.enableRuleset("vncServer");
                firewallMo.refreshFirewall();
            }
        }

        // prepare at least one network on the vswitch to enable OVF importing
        String vSwitchName = privateTrafficLabel;
View Full Code Here

            try {
                _serviceContext = VmwareContextFactory.create(_vCenterAddress, _username, _password);
                VmwareHypervisorHost hyperHost = getHyperHost(_serviceContext, cmd);
                assert(hyperHost instanceof HostMO);
               
                HostFirewallSystemMO firewallMo = ((HostMO)hyperHost).getHostFirewallSystemMO();
                boolean bRefresh = false;
                if(firewallMo != null) {
                  HostFirewallInfo firewallInfo = firewallMo.getFirewallInfo();
                  if(firewallInfo != null) {
                    for(HostFirewallRuleset rule : firewallInfo.getRuleset()) {
                      if("vncServer".equalsIgnoreCase(rule.getKey())) {
                        bRefresh = true;
                        firewallMo.enableRuleset("vncServer");
                      } else if("gdbserver".equalsIgnoreCase(rule.getKey())) {
                        bRefresh = true;
                        firewallMo.enableRuleset("gdbserver");
                      }
                    }
                  }
                 
                  if(bRefresh)
                    firewallMo.refreshFirewall();
                }
            } catch (Exception e) {
                s_logger.error("Unable to connect to vSphere server: " + _vCenterAddress, e);
                throw new CloudRuntimeException("Unable to connect to vSphere server: " + _vCenterAddress);
            }
View Full Code Here

                ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
                assert(hosts != null);

                // For ESX host, we need to enable host firewall to allow VNC access
                HostMO hostMo = new HostMO(serviceContext, hosts[0]);
                HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
                if(firewallMo != null) {
                if(hostMo.getHostType() == VmwareHostType.ESX) {
                   
                      firewallMo.enableRuleset("vncServer");
                      firewallMo.refreshFirewall();
                }
                }

                // prepare at least one network on the vswitch to enable OVF importing
                String vlanId = null;
                if(privateTrafficLabel != null) {
                  String[] tokens = privateTrafficLabel.split(",");
                  if(tokens.length == 2)
                    vlanId = tokens[1];
                }

                if(!_nexusVSwitchActive) {
                  HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
                }
                else {
                    s_logger.info("Preparing Network on " + privateTrafficLabel);
                    HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
                }
                returnedHostList.add(hosts[0]);
                return returnedHostList;
            } else if(mor.getType().equals("ClusterComputeResource")) {
                ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
                assert(hosts != null);
               
                if(hosts.length > _maxHostsPerCluster) {
                  String msg = "vCenter cluster size is too big (current configured cluster size: " + _maxHostsPerCluster + ")";
                  s_logger.error(msg);
                  throw new DiscoveredWithErrorException(msg);
                }
               
                for(ManagedObjectReference morHost: hosts) {
                    // For ESX host, we need to enable host firewall to allow VNC access
                    HostMO hostMo = new HostMO(serviceContext, morHost);
                    HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
                    if(firewallMo != null) {
                    if(hostMo.getHostType() == VmwareHostType.ESX) {
                          firewallMo.enableRuleset("vncServer");
                          firewallMo.refreshFirewall();
                    }
                    }

                    String vlanId = null;
                    if(privateTrafficLabel != null) {
                        String[] tokens = privateTrafficLabel.split(",");
                        if(tokens.length == 2)
                            vlanId = tokens[1];
                    }
                   
                   
                    s_logger.info("Calling prepareNetwork : " + hostMo.getContext().toString());
                    // prepare at least one network on the vswitch to enable OVF importing
                    if(!_nexusVSwitchActive) {
                      HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
                    }
                    else {
                        s_logger.info("Preparing Network on " + privateTrafficLabel);
                        HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
                    }
                    returnedHostList.add(morHost);
                }
                return returnedHostList;
            } else if(mor.getType().equals("HostSystem")) {
                // For ESX host, we need to enable host firewall to allow VNC access
                HostMO hostMo = new HostMO(serviceContext, mor);
                HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
                if(firewallMo != null) {
                if(hostMo.getHostType() == VmwareHostType.ESX) {
                      firewallMo.enableRuleset("vncServer");
                      firewallMo.refreshFirewall();
                }
                }

                String vlanId = null;
                if(privateTrafficLabel != null) {
View Full Code Here

            }
        }

        // For ESX host, we need to enable host firewall to allow VNC access
        HostMO hostMo = new HostMO(serviceContext, morHost);
        HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
        if(firewallMo != null) {
            firewallMo.enableRuleset("vncServer");
            firewallMo.refreshFirewall();
        }
        return morHost;
    }
View Full Code Here

            try {
                _serviceContext = VmwareContextFactory.create(_vCenterAddress, _username, _password);
                VmwareHypervisorHost hyperHost = getHyperHost(_serviceContext, cmd);
                assert(hyperHost instanceof HostMO);

                HostFirewallSystemMO firewallMo = ((HostMO)hyperHost).getHostFirewallSystemMO();
                boolean bRefresh = false;
                if(firewallMo != null) {
                    HostFirewallInfo firewallInfo = firewallMo.getFirewallInfo();
                    if(firewallInfo != null && firewallInfo.getRuleset() != null) {
                        for(HostFirewallRuleset rule : firewallInfo.getRuleset()) {
                            if("vncServer".equalsIgnoreCase(rule.getKey())) {
                                bRefresh = true;
                                firewallMo.enableRuleset("vncServer");
                            } else if("gdbserver".equalsIgnoreCase(rule.getKey())) {
                                bRefresh = true;
                                firewallMo.enableRuleset("gdbserver");
                            }
                        }
                    }

                    if(bRefresh)
                        firewallMo.refreshFirewall();
                }
            } catch (Exception e) {
                s_logger.error("Unable to connect to vSphere server: " + _vCenterAddress, e);
                throw new CloudRuntimeException("Unable to connect to vSphere server: " + _vCenterAddress);
            }
View Full Code Here

TOP

Related Classes of com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO

Copyright © 2018 www.massapicom. 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.