Skip to content

Conversation

Ctesias
Copy link

@Ctesias Ctesias commented Mar 21, 2017

Problem: the hp3parclient doesn't see vlan-tagged iscsi ports because
the WSAPI API doesn't provide that port data from the '/ports' endpoint.
This is bad for two reasons: it disables users from making use of the client
when they have vlan-tagged iscsi ports and it stops the Openstack Cinder
driver from connecting servers to 3par nodes for making volumes.

Solution: I added code to getPorts() to execute the 'showport -iscsivlans'
command when SSH is set up and then create cloned dictionaries of the physical
ports in the port list with the IP/vlan address information switched out. To
facilitate parsing of the ssh command I created the ShowportParser which is
extensible if needed.

old workflow: get ports from WASPI '/ports' -> return ports
new workflow: get ports from WSAPI '/ports' ->
if SSH is enabled, run 'showport -iscsivlans' ->
search the ports list for physical ports with the same information as the vlan ports ->
make copies of those ports and append them to the list of ports ->
update the members count->
return ports.

Problem: the hp3parclient doesn't see vlan-tagged iscsi ports because
the WSAPI API doesn't provide that port data from the '/ports' endpoint.
This is bad for two reasons: it disables users from making use of the client
when they have vlan-tagged iscsi ports and it stops the Openstack Cinder
driver from connecting servers to 3par nodes for making volumes.

Solution: I added code to getPorts() to execute the 'showport -iscsivlans'
command when SSH is set up and then create cloned dictionaries of the physical
ports in the port list with the IP/vlan address information switched out.  To
facilitate parsing of the ssh command I created the ShowportParser which is
extensible if needed.

old workflow: get ports from WASPI '/ports' -> return ports
new workflow: get ports from WSAPI '/ports' ->
	      if SSH is enabled, run 'showport -iscsivlans' ->
	      search the ports list for physical ports with the same information as the vlan ports ->
	      make copies of those ports and append them to the list of ports ->
              update the members count->
	      return ports.
@@ -38,7 +39,7 @@
from urllib2 import quote

from hp3parclient import exceptions, http, ssh

from showport_parser import ShowportParser
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my local test environment, i had to change this line to
from hpe3parclient import showport_parser

And later create the ShowportParser class using

port_parser = showport_parser.ShowportParser() to resolve the module import error.

Can you please check on your setup ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which version of python are you using? This code works for me in my env

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On python 2.7 , this is the error :
port_parser = showport_parser.ShowportParser()
NameError: global name 'showport_parser' is not defined

I have tested using the below code

import os
import sys
import hpe3parclient
from hpe3parclient import client
from hpe3parclient import exceptions as hpexceptions

#array_ip = raw_input("enter the ip address of array:")
#array_user = raw_input("enter array user:")
#array_secret = raw_input("enter array secret:")

array_ip = "192.168.67.7"
array_user = "3paradm"
array_secret = "3pardata"

#ping the array first
response = os.system("ping -c 1 " + array_ip)

#and then check the response...
if response == 0:
      print array_ip, 'is reachable!'
else:
      print array_ip, 'is unreachable!'
      sys.exit(1)

if array_user and array_secret:

        #proceed validating the client
        hp3par_api_url = 'https://%s:8080/api/v1'%(array_ip)
        cl = client.HPE3ParClient(hp3par_api_url)
        client_version = hpe3parclient.version

        try:
                cl.login(array_user,array_secret)
                cl.setSSHOptions(array_ip,array_user,array_secret)
                output = cl._run(['showversion','-b'])
                #vv_create_output = cl.createVolume('ecostor_vv1','FC_r6', 10000)
                #print 'Volume %s ' % (vv_create_output)a
                print(' showversion %s ' % output)
                output = cl.getPorts()
                print (' PORTS : %s ' % output)
        except hpexceptions.HTTPForbidden as ex:
                print "Error: Failed to login to 3PAR "+array_ip+" with user "+array_user+"  and secret "+array_secret+". Exception: "+str(ex)
                sys.exit(1)

        cl.logout()
else:
        print "invalid username or password"

@wdurairaj
Copy link
Collaborator

Thanks for your pull request on adding support for querying iscsi vlan tags. Please check the review comment given above.

@hpe-storage
Copy link
Collaborator

Closing this PR and will re-open again to trigger a travis CI build explicitly.

@hpe-storage
Copy link
Collaborator

Changes in this PR will be referenced in #59 , since we have to do some additional fixes on top of this original PR.

wdurairaj pushed a commit to wdurairaj/python-3parclient that referenced this pull request Jul 8, 2019
wdurairaj pushed a commit to wdurairaj/python-3parclient that referenced this pull request Jul 8, 2019
wdurairaj pushed a commit to wdurairaj/python-3parclient that referenced this pull request Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants