Package netapp.manage

Examples of netapp.manage.NaElement


     * @return -- the snapshot schedule
     * @throws ServerException
     */
    private String returnSnapshotSchedule(NetappVolumeVO vol) throws ServerException{

    NaElement xi = new NaElement("snapshot-get-schedule");
    xi.addNewChild("volume", vol.getVolumeName());
    NaServer s = null;
    try {
      s = getServer(vol.getIpAddress(), vol.getUsername(), vol.getPassword());
      NaElement xo = s.invokeElem(xi);
      String weeks = xo.getChildContent("weeks");
      String days = xo.getChildContent("days");
      String hours = xo.getChildContent("hours");
      String minutes = xo.getChildContent("minutes");
      String whichHours = xo.getChildContent("which-hours");
      String whichMinutes = xo.getChildContent("which-minutes");
     
      StringBuilder sB = new StringBuilder();
      sB.append(weeks).append(" ").append(days).append(" ").append(hours).append("@").append(whichHours).append(" ").append(minutes).append("@").append(whichMinutes);
      return sB.toString();
    } catch (NaException nae) {
View Full Code Here


   */
    @Override
  public long returnAvailableVolumeSize(String volName, String userName, String password, String serverIp) throws ServerException
    long availableSize = 0;

    NaElement xi = new NaElement("volume-list-info");
    xi.addNewChild("volume", volName);
    NaServer s = null;
    String volumeState = null;
    try {
      s = getServer(serverIp, userName, password);
      NaElement xo = s.invokeElem(xi);
      List volList = xo.getChildByName("volumes").getChildren();
      Iterator volIter = volList.iterator();
      while(volIter.hasNext()){
        NaElement volInfo=(NaElement)volIter.next();
        availableSize = volInfo.getChildLongValue("size-available", -1);
        volumeState = volInfo.getChildContent("state");
      }
     
      if (volumeState != null) {
        return volumeState.equalsIgnoreCase("online") ? availableSize : -1; //return -1 if volume is offline
      }
View Full Code Here

       
        //update lun name
        lun.setLunName(lunName.toString());
        _lunDao.update(lun.getId(), lun);
       
        NaElement xi;
        NaElement xi1;

        long lSizeBytes = 1L*lunSize*1024*1024*1024; //This prevents integer overflow
        Long lunSizeBytes = new Long(lSizeBytes);
       
        s = getServer(selectedVol.getIpAddress(), selectedVol.getUsername(),selectedVol.getPassword());

        //create lun
        xi = new NaElement("lun-create-by-size");
        xi.addNewChild("ostype","linux");
        xi.addNewChild("path",exportPath.toString());
        xi.addNewChild("size", (lunSizeBytes.toString()));
       
        s.invokeElem(xi)

        try
        {
          //now create an igroup
        xi1 = new NaElement("igroup-create");
        xi1.addNewChild("initiator-group-name", lunName .toString());
        xi1.addNewChild("initiator-group-type", "iscsi");
        xi1.addNewChild("os-type", "linux");
        s.invokeElem(xi1);
        }catch(NaAPIFailedException e)
        {
          if(e.getErrno() == 9004)
          {
            //igroup already exists hence no error
            s_logger.warn("Igroup already exists");
          }
        }

        //get target iqn
      NaElement xi4 = new NaElement("iscsi-node-get-name");
      NaElement xo = s.invokeElem(xi4);
      String iqn = xo.getChildContent("node-name");
     
      lun.setTargetIqn(iqn);
      _lunDao.update(lun.getId(), lun);
     
      //create lun mapping
      //now map the lun to the igroup
      NaElement xi3 = new NaElement("lun-map");
      xi3.addNewChild("force", "true");
      xi3.addNewChild("initiator-group", lunName.toString());
      xi3.addNewChild("path", lun.getPath() + lun.getLunName());
     
      xi3.addNewChild("lun-id", lunIdStr);
      s.invokeElem(xi3);
       
        txn.commit();
        //set the result
        result[0] = lunName.toString();//lunname
View Full Code Here

      if(s_logger.isDebugEnabled())
        s_logger.debug("Request --> destroyLun "+":serverIp:"+vol.getIpAddress());
     
      try {
        //Unmap lun
        NaElement xi2 = new NaElement("lun-unmap");
        xi2.addNewChild("initiator-group", lunName);
        xi2.addNewChild("path", lun.getPath()+lun.getLunName());
        s.invokeElem(xi2);
      } catch (NaAPIFailedException naf) {
        if(naf.getErrno()==9016)
          s_logger.warn("no map exists excpn 9016 caught in deletelun, continuing with delete");
      }

      //destroy lun
      NaElement xi = new NaElement("lun-destroy");
      xi.addNewChild("force","true");
      xi.addNewChild("path", lun.getPath()+lun.getLunName());
      s.invokeElem(xi);
     
      //destroy igroup
      NaElement xi1 = new NaElement("igroup-destroy");
      //xi1.addNewChild("force","true");
      xi1.addNewChild("initiator-group-name",lunName);
      s.invokeElem(xi1);
     
      _lunDao.remove(lun.getId());
      txn.commit();
    } catch(UnknownHostException uhe) {
View Full Code Here

   * @param lunName -- lun name
   */
    @Override
  public void disassociateLun(String iGroup, String lunName) throws ServerException, InvalidParameterValueException
  {
    NaElement xi;
    LunVO lun = _lunDao.findByName(lunName);
   
    if(lun == null)
      throw new InvalidParameterValueException("Cannot find LUN " + lunName);
   
    NetappVolumeVO vol = _volumeDao.findById(lun.getVolumeId());
    NaServer s = null;
    try {
      s = getServer(vol.getIpAddress(), vol.getUsername(), vol.getPassword());
     
      if(s_logger.isDebugEnabled())
        s_logger.debug("Request --> disassociateLun "+":serverIp:"+vol.getIpAddress());
     
      xi = new NaElement("igroup-remove");
      xi.addNewChild("force", "true");
      xi.addNewChild("initiator", iGroup);
      xi.addNewChild("initiator-group-name", lunName);   
      s.invokeElem(xi);
     
    } catch(UnknownHostException uhe) {
      throw new ServerException("Failed to disassociate lun", uhe);
    } catch ( IOException ioe) {
View Full Code Here

   */
    @Override
  public String[] associateLun(String guestIqn, String lunName) throws ServerException, InvalidParameterValueException

  {
    NaElement xi2;

    //get lun id from path
    String[] splitLunName = lunName.split("-");
    String[] returnVal = new String[3];
    if(splitLunName.length != 2)
      throw new InvalidParameterValueException("The lun id is malformed");
   
    String lunIdStr = splitLunName[1];

    Long lId = new Long(lunIdStr);
   
    LunVO lun = _lunDao.findById(lId);
   
    if(lun == null)
      throw new InvalidParameterValueException("Cannot find LUN " + lunName);
   
    NetappVolumeVO vol = _volumeDao.findById(lun.getVolumeId());

    //assert(vol != null);
   
    returnVal[0] = lunIdStr;
    returnVal[1] = lun.getTargetIqn();
    returnVal[2] = vol.getIpAddress();
   
    NaServer s = null;
   
    try
    {
      s = getServer(vol.getIpAddress(), vol.getUsername(), vol.getPassword());
     
      if(s_logger.isDebugEnabled())
        s_logger.debug("Request --> associateLun "+":serverIp:"+vol.getIpAddress());
     
      //add iqn to the group
      xi2 = new NaElement("igroup-add");
      xi2.addNewChild("force", "true");
      xi2.addNewChild("initiator", guestIqn);
      xi2.addNewChild("initiator-group-name", lunName);   
      s.invokeElem(xi2);
           
      return returnVal;
    catch (UnknownHostException uhe) {
      s_logger.warn("Unable to associate LUN " , uhe);
View Full Code Here

TOP

Related Classes of netapp.manage.NaElement

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.