-
Notifications
You must be signed in to change notification settings - Fork 72
Added functionality to grab vlan-tagged iscsi ports with getPorts() #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"
Thanks for your pull request on adding support for querying iscsi vlan tags. Please check the review comment given above. |
Closing this PR and will re-open again to trigger a travis CI build explicitly. |
Changes in this PR will be referenced in #59 , since we have to do some additional fixes on top of this original PR. |
Fixing volume inspect problem , issue hpe-storage#30
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.