Examples of CiscoNexusVSMDeviceVO


Examples of com.cloud.network.CiscoNexusVSMDeviceVO

        return cmdList;
    }

    @DB
    public Pair<Boolean, Long> validateAndAddVsm(final String vsmIp, final String vsmUser, final String vsmPassword, final 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.
            vsm = Transaction.execute(new TransactionCallback<CiscoNexusVSMDeviceVO>() {
                @Override
                public CiscoNexusVSMDeviceVO doInTransaction(TransactionStatus status) {
                    CiscoNexusVSMDeviceVO vsm = null;
                    if (_vsmDao.getVSMbyIpaddress(vsmIp) == null) {
                        vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword);
                        vsm = _vsmDao.persist(vsm);
                    }
                    // Create a mapping between the cluster and the vsm.
                    vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
                    if (vsm != null) {
                        ClusterVSMMapVO connectorObj = new ClusterVSMMapVO(clusterId, vsm.getId());
                        _clusterVSMDao.persist(connectorObj);
                    }
                    return vsm;
                }
            });

        } 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
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.