Examples of CiscoNexusVSMDeviceVO


Examples of com.cloud.network.CiscoNexusVSMDeviceVO

    }   

    @Override
    @ActionEvent(eventType = EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_ENABLE, eventDescription = "deleting VSM", async = true
    public CiscoNexusVSMDeviceVO enableCiscoNexusVSM(EnableCiscoNexusVSMCmd cmd) {
      CiscoNexusVSMDeviceVO result;
      result = enableCiscoNexusVSM(cmd.getCiscoNexusVSMDeviceId());
      return result;
    }
View Full Code Here

Examples of com.cloud.network.CiscoNexusVSMDeviceVO

    }
   
    @Override
    @ActionEvent(eventType = EventTypes.EVENT_EXTERNAL_SWITCH_MGMT_DEVICE_DISABLE, eventDescription = "deleting VSM", async = true)
    public CiscoNexusVSMDeviceVO disableCiscoNexusVSM(DisableCiscoNexusVSMCmd cmd) {
      CiscoNexusVSMDeviceVO result;
      result = disableCiscoNexusVSM(cmd.getCiscoNexusVSMDeviceId());
      return result;
    }
View Full Code Here

Examples of com.cloud.network.CiscoNexusVSMDeviceVO

      Long clusterId = cmd.getClusterId();
      Long zoneId = cmd.getZoneId();
      List<CiscoNexusVSMDeviceVO> result = new ArrayList<CiscoNexusVSMDeviceVO>();
      if (clusterId != null && clusterId.longValue() != 0) {       
        // Find the VSM associated with this clusterId and return a list.
        CiscoNexusVSMDeviceVO vsm = getCiscoVSMbyClusId(cmd.getClusterId());
        if (vsm == null) {
            throw new CloudRuntimeException("No Cisco VSM associated with specified Cluster Id");
          }
        // Else, add it to a list and return the list.
        result.add(vsm);
        return result;
      }     
      // Else if there is only a zoneId defined, get a list of all vmware clusters
      // in the zone, and then for each cluster, pull the VSM and prepare a list.
      if (zoneId != null && zoneId.longValue() != 0) {
        ManagementService ref = cmd.getMgmtServiceRef();     
        List<? extends Cluster> clusterList = ref.searchForClusters(zoneId, cmd.getStartIndex(), cmd.getPageSizeVal(), "VMware");
     
        if (clusterList.size() == 0) {
          throw new CloudRuntimeException("No VMWare clusters found in the specified zone!");
        }
        // Else, iterate through each vmware cluster, pull its VSM if it has one, and add to the list.
        for (Cluster clus : clusterList) {
          CiscoNexusVSMDeviceVO vsm = getCiscoVSMbyClusId(clus.getId());
          if (vsm != null)
            result.add(vsm);
        }
        return result;
      }
View Full Code Here

Examples of com.cloud.network.CiscoNexusVSMDeviceVO

        return cmdList;
    }

    @DB
    public Pair<Boolean, Long> validateAndAddVsm(String vsmIp, String vsmUser, String vsmPassword, long clusterId, String clusterName) throws ResourceInUseException {
        CiscoNexusVSMDeviceVO vsm = null;
        boolean vsmAdded = false;
        Long vsmId = 0L;
        if(vsmIp != null && vsmUser != null && vsmPassword != null) {
            NetconfHelper netconfClient;
            try {
                netconfClient = new NetconfHelper(vsmIp, vsmUser, vsmPassword);
                netconfClient.disconnect();
            } catch (CloudRuntimeException e) {
                String msg = "Invalid credentials supplied for user " + vsmUser + " for Cisco Nexus 1000v VSM at " + vsmIp;
                s_logger.error(msg);
                _clusterDao.remove(clusterId);
                throw new CloudRuntimeException(msg);
            }

            Transaction txn;

            // If VSM already exists and is mapped to a cluster, fail this operation.
            vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
            if(vsm != null) {
                List<ClusterVSMMapVO> clusterList = _clusterVSMDao.listByVSMId(vsm.getId());
                if (clusterList != null && !clusterList.isEmpty()) {
                    s_logger.error("Failed to add cluster: specified Nexus VSM is already associated with another cluster");
                    ResourceInUseException ex = new ResourceInUseException("Failed to add cluster: specified Nexus VSM is already associated with another cluster with specified Id");
                    // get clusterUuid to report error
                    ClusterVO cluster = _clusterDao.findById(clusterList.get(0).getClusterId());
                    ex.addProxyObject(cluster.getUuid());
                    _clusterDao.remove(clusterId);
                    throw ex;
                }
            }
            // persist credentials to database if the VSM entry is not already in the db.
            if (_vsmDao.getVSMbyIpaddress(vsmIp) == null) {
                vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword);
                txn = Transaction.currentTxn();
                try {
                    txn.start();
                    vsm = _vsmDao.persist(vsm);
                    txn.commit();
                } catch (Exception e) {
                    txn.rollback();
                    s_logger.error("Failed to persist Cisco Nexus 1000v VSM details to database. Exception: " + e.getMessage());
                    throw new CloudRuntimeException(e.getMessage());
                }
            }
            // Create a mapping between the cluster and the vsm.
            vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
            if (vsm != null) {
                ClusterVSMMapVO connectorObj = new ClusterVSMMapVO(clusterId, vsm.getId());
                txn = Transaction.currentTxn();
                try {
                    txn.start();
                    _clusterVSMDao.persist(connectorObj);
                    txn.commit();
                } catch (Exception e) {
                    txn.rollback();
                    s_logger.error("Failed to associate Cisco Nexus 1000v VSM with cluster: " + clusterName + ". Exception: " + e.getMessage());
                    _vsmDao.remove(vsm.getId()); // Removing VSM from virtual_supervisor_module table because association with cluster failed.
                    // Cluster would be deleted from cluster table by callee.
                    throw new CloudRuntimeException(e.getMessage());
                }
            }
        } else {
            String msg;
            msg = "The global parameter " + Config.VmwareUseNexusVSwitch.toString() +
                    " is set to \"true\". Following mandatory parameters are not specified. ";
            if(vsmIp == null) {
                msg += "vsmipaddress: Management IP address of Cisco Nexus 1000v dvSwitch. ";
            }
            if(vsmUser == null) {
                msg += "vsmusername: Name of a user account with admin privileges over Cisco Nexus 1000v dvSwitch. ";
            }
            if(vsmPassword == null) {
                if(vsmUser != null) {
                    msg += "vsmpassword: Password of user account " + vsmUser + ". ";
                } else {
                    msg += "vsmpassword: Password of user account with admin privileges over Cisco Nexus 1000v dvSwitch. ";
                }
            }
            s_logger.error(msg);
            // Cleaning up the cluster record as addCluster operation failed because of invalid credentials of Nexus dvSwitch.
            _clusterDao.remove(clusterId);
            throw new CloudRuntimeException(msg);
        }
        if (vsm != null) {
            vsmAdded = true;
            vsmId = vsm.getId();
        }
        return new Pair<Boolean, Long>(vsmAdded, vsmId);
    }
View Full Code Here

Examples of com.cloud.network.CiscoNexusVSMDeviceVO

        return _routerExtraPublicNics;
    }

    @Override
    public Map<String, String> getNexusVSMCredentialsByClusterId(Long clusterId) {
        CiscoNexusVSMDeviceVO nexusVSM = null;
        ClusterVSMMapVO vsmMapVO = null;

        vsmMapVO = _vsmMapDao.findByClusterId(clusterId);
        long vsmId = 0;
        if (vsmMapVO != null) {
            vsmId = vsmMapVO.getVsmId();
            s_logger.info("vsmId is " + vsmId);
            nexusVSM = _nexusDao.findById(vsmId);
            s_logger.info("Fetching nexus vsm credentials from database.");
        }
        else {
            s_logger.info("Found empty vsmMapVO.");
            return null;
        }

        Map<String, String> nexusVSMCredentials = new HashMap<String, String>();
        if (nexusVSM != null) {
            nexusVSMCredentials.put("vsmip", nexusVSM.getipaddr());
            nexusVSMCredentials.put("vsmusername", nexusVSM.getUserName());
            nexusVSMCredentials.put("vsmpassword", nexusVSM.getPassword());
            s_logger.info("Successfully fetched the credentials of Nexus VSM.");
        }
        return nexusVSMCredentials;
    }
View Full Code Here

Examples of com.cloud.network.CiscoNexusVSMDeviceVO

        when(_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.CiscoVnmc)).thenReturn(true);

        ClusterVSMMapVO clusterVsmMap = mock(ClusterVSMMapVO.class);
        when(_clusterVsmMapDao.findByClusterId(anyLong())).thenReturn(clusterVsmMap);

        CiscoNexusVSMDeviceVO vsmDevice = mock(CiscoNexusVSMDeviceVO.class);
        when(vsmDevice.getUserName()).thenReturn("foo");
        when(vsmDevice.getPassword()).thenReturn("bar");
        when(vsmDevice.getipaddr()).thenReturn("1.2.3.4");
        when(_vsmDeviceDao.findById(anyLong())).thenReturn(vsmDevice);

        HostVO hostVO = mock(HostVO.class);
        when(hostVO.getId()).thenReturn(1L);
        when(_hostDao.findById(anyLong())).thenReturn(hostVO);
View Full Code Here

Examples of com.cloud.network.CiscoNexusVSMDeviceVO

            if (clusterVsmMap == null) {
                s_logger.error("Vmware cluster " + asaCluster.getName() + " has no Cisco Nexus VSM device associated with it");
                return false;
            }

            CiscoNexusVSMDeviceVO vsmDevice = _vsmDeviceDao.findById(clusterVsmMap.getVsmId());
            if (vsmDevice == null) {
                s_logger.error("Unable to load details of Cisco Nexus VSM device associated with cluster " + asaCluster.getName());
                return false;
            }

            CiscoVnmcControllerVO ciscoVnmcDevice = devices.get(0);
            HostVO ciscoVnmcHost = _hostDao.findById(ciscoVnmcDevice.getHostId());
            _hostDao.loadDetails(ciscoVnmcHost);
            Account owner = context.getAccount();
            PublicIp sourceNatIp = _networkMgr.assignSourceNatIpAddressToGuestNetwork(owner, network);
            String vlan = network.getBroadcastUri().getHost();
            long vlanId = Long.parseLong(vlan);

            List<VlanVO> vlanVOList = _vlanDao.listVlansByPhysicalNetworkId(network.getPhysicalNetworkId());
            List<String> publicGateways = new ArrayList<String>();
            for (VlanVO vlanVO : vlanVOList) {
                publicGateways.add(vlanVO.getVlanGateway());
            }

            // due to VNMC limitation of not allowing source NAT ip as the outside ip of firewall,
            // an additional public ip needs to acquired for assigning as firewall outside ip.
            // In case there are already additional ip addresses available (network restart) use one
            // of them such that it is not the source NAT ip
            IpAddress outsideIp = null;
            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), null);
            for (IPAddressVO ip : publicIps) {
                if (!ip.isSourceNat()) {
                    outsideIp = ip;
                    break;
                }
            }
            if (outsideIp == null) { // none available, acquire one
                try {
                    Account caller = UserContext.current().getCaller();
                    long callerUserId = UserContext.current().getCallerUserId();
                    outsideIp = _networkMgr.allocateIp(owner, false, caller, callerUserId, zone);
                } catch (ResourceAllocationException e) {
                    s_logger.error("Unable to allocate additional public Ip address. Exception details " + e);
                    return false;
                }

                try {
                    outsideIp = _networkMgr.associateIPToGuestNetwork(outsideIp.getId(), network.getId(), true);
                } catch (ResourceAllocationException e) {
                    s_logger.error("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr() + " to network with vlan " + vlanId + ". Exception details " + e);
                    return false;
                }
            }

            // create logical edge firewall in VNMC
            String gatewayNetmask = NetUtils.getCidrNetmask(network.getCidr());
            // due to ASA limitation of allowing single subnet to be assigned to firewall interfaces,
            // all public ip addresses must be from same subnet, this essentially means single public subnet in zone
            if (!createLogicalEdgeFirewall(vlanId, network.getGateway(), gatewayNetmask,
                    outsideIp.getAddress().addr(), sourceNatIp.getNetmask(), publicGateways, ciscoVnmcHost.getId())) {
                s_logger.error("Failed to create logical edge firewall in Cisco VNMC device for network " + network.getName());
                return false;
            }

            // create stuff in VSM for ASA device
            if (!configureNexusVsmForAsa(vlanId, network.getGateway(),
                    vsmDevice.getUserName(), vsmDevice.getPassword(), vsmDevice.getipaddr(),
                    assignedAsa.getInPortProfile(), ciscoVnmcHost.getId())) {
                s_logger.error("Failed to configure Cisco Nexus VSM " + vsmDevice.getipaddr() +
                        " for ASA device for network " + network.getName());
                return false;
            }

            // configure source NAT
View Full Code Here

Examples of com.cloud.network.CiscoNexusVSMDeviceVO

        return _routerExtraPublicNics;
    }

    @Override
    public Map<String, String> getNexusVSMCredentialsByClusterId(Long clusterId) {
        CiscoNexusVSMDeviceVO nexusVSM = null;
        ClusterVSMMapVO vsmMapVO = null;

        vsmMapVO = _vsmMapDao.findByClusterId(clusterId);
        long vsmId = 0;
        if (vsmMapVO != null) {
            vsmId = vsmMapVO.getVsmId();
            s_logger.info("vsmId is " + vsmId);
            nexusVSM = _nexusDao.findById(vsmId);
            s_logger.info("Fetching nexus vsm credentials from database.");
        }
        else {
            s_logger.info("Found empty vsmMapVO.");
            return null;
        }

        Map<String, String> nexusVSMCredentials = new HashMap<String, String>();
        if (nexusVSM != null) {
            nexusVSMCredentials.put("vsmip", nexusVSM.getipaddr());
            nexusVSMCredentials.put("vsmusername", nexusVSM.getUserName());
            nexusVSMCredentials.put("vsmpassword", nexusVSM.getPassword());
            s_logger.info("Successfully fetched the credentials of Nexus VSM.");
        }
        return nexusVSMCredentials;
    }
View Full Code Here

Examples of com.cloud.network.CiscoNexusVSMDeviceVO

        return _routerExtraPublicNics;
    }

    @Override
    public Map<String, String> getNexusVSMCredentialsByClusterId(Long clusterId) {
        CiscoNexusVSMDeviceVO nexusVSM = null;
        ClusterVSMMapVO vsmMapVO = null;

        vsmMapVO = _vsmMapDao.findByClusterId(clusterId);
        long vsmId = 0;
        if (vsmMapVO != null) {
            vsmId = vsmMapVO.getVsmId();
            s_logger.info("vsmId is " + vsmId);
            nexusVSM = _nexusDao.findById(vsmId);
            s_logger.info("Fetching nexus vsm credentials from database.");
        } else {
            s_logger.info("Found empty vsmMapVO.");
            return null;
        }

        Map<String, String> nexusVSMCredentials = new HashMap<String, String>();
        if (nexusVSM != null) {
            nexusVSMCredentials.put("vsmip", nexusVSM.getipaddr());
            nexusVSMCredentials.put("vsmusername", nexusVSM.getUserName());
            nexusVSMCredentials.put("vsmpassword", nexusVSM.getPassword());
            s_logger.info("Successfully fetched the credentials of Nexus VSM.");
        }
        return nexusVSMCredentials;
    }
View Full Code Here

Examples of com.cloud.network.CiscoNexusVSMDeviceVO

            if (clusterVsmMap == null) {
                s_logger.error("Vmware cluster " + asaCluster.getName() + " has no Cisco Nexus VSM device associated with it");
                throw new CloudRuntimeException("Vmware cluster " + asaCluster.getName() + " has no Cisco Nexus VSM device associated with it");
            }

            CiscoNexusVSMDeviceVO vsmDevice = _vsmDeviceDao.findById(clusterVsmMap.getVsmId());
            if (vsmDevice == null) {
                s_logger.error("Unable to load details of Cisco Nexus VSM device associated with cluster " + asaCluster.getName());
                throw new CloudRuntimeException("Unable to load details of Cisco Nexus VSM device associated with cluster " + asaCluster.getName());
            }

            CiscoVnmcControllerVO ciscoVnmcDevice = devices.get(0);
            HostVO ciscoVnmcHost = _hostDao.findById(ciscoVnmcDevice.getHostId());
            _hostDao.loadDetails(ciscoVnmcHost);
            Account owner = context.getAccount();
            PublicIp sourceNatIp = _ipAddrMgr.assignSourceNatIpAddressToGuestNetwork(owner, network);
            long vlanId = Long.parseLong(BroadcastDomainType.getValue(network.getBroadcastUri()));

            List<VlanVO> vlanVOList = _vlanDao.listVlansByPhysicalNetworkId(network.getPhysicalNetworkId());
            List<String> publicGateways = new ArrayList<String>();
            for (VlanVO vlanVO : vlanVOList) {
                publicGateways.add(vlanVO.getVlanGateway());
            }

            // due to VNMC limitation of not allowing source NAT ip as the outside ip of firewall,
            // an additional public ip needs to acquired for assigning as firewall outside ip.
            // In case there are already additional ip addresses available (network restart) use one
            // of them such that it is not the source NAT ip
            IpAddress outsideIp = null;
            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), null);
            for (IPAddressVO ip : publicIps) {
                if (!ip.isSourceNat()) {
                    outsideIp = ip;
                    break;
                }
            }
            if (outsideIp == null) { // none available, acquire one
                try {
                    Account caller = CallContext.current().getCallingAccount();
                    long callerUserId = CallContext.current().getCallingUserId();
                    outsideIp = _ipAddrMgr.allocateIp(owner, false, caller, callerUserId, zone, true);
                } catch (ResourceAllocationException e) {
                    s_logger.error("Unable to allocate additional public Ip address. Exception details " + e);
                    throw new CloudRuntimeException("Unable to allocate additional public Ip address. Exception details " + e);
                }

                try {
                    outsideIp = _ipAddrMgr.associateIPToGuestNetwork(outsideIp.getId(), network.getId(), true);
                } catch (ResourceAllocationException e) {
                    s_logger.error("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr() + " to network with vlan " + vlanId +
                        ". Exception details " + e);
                    throw new CloudRuntimeException("Unable to assign allocated additional public Ip " + outsideIp.getAddress().addr() + " to network with vlan " +
                        vlanId + ". Exception details " + e);
                }
            }

            // create logical edge firewall in VNMC
            String gatewayNetmask = NetUtils.getCidrNetmask(network.getCidr());
            // due to ASA limitation of allowing single subnet to be assigned to firewall interfaces,
            // all public ip addresses must be from same subnet, this essentially means single public subnet in zone
            if (!createLogicalEdgeFirewall(vlanId, network.getGateway(), gatewayNetmask, outsideIp.getAddress().addr(), sourceNatIp.getNetmask(), publicGateways,
                ciscoVnmcHost.getId())) {
                s_logger.error("Failed to create logical edge firewall in Cisco VNMC device for network " + network.getName());
                throw new CloudRuntimeException("Failed to create logical edge firewall in Cisco VNMC device for network " + network.getName());
            }

            // create stuff in VSM for ASA device
            if (!configureNexusVsmForAsa(vlanId, network.getGateway(), vsmDevice.getUserName(), vsmDevice.getPassword(), vsmDevice.getipaddr(),
                assignedAsa.getInPortProfile(), ciscoVnmcHost.getId())) {
                s_logger.error("Failed to configure Cisco Nexus VSM " + vsmDevice.getipaddr() + " for ASA device for network " + network.getName());
                throw new CloudRuntimeException("Failed to configure Cisco Nexus VSM " + vsmDevice.getipaddr() + " for ASA device for network " + network.getName());
            }

            // configure source NAT
            if (!configureSourceNat(vlanId, network.getCidr(), sourceNatIp, ciscoVnmcHost.getId())) {
                s_logger.error("Failed to configure source NAT in Cisco VNMC device for network " + network.getName());
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.