vsg-test:
Adding method header comments to utility functions of VSG test module.
Change-Id: I2cd1f50a9249df68bad7fc0deed1506aca1fe8f7
diff --git a/src/test/utils/VSGAccess.py b/src/test/utils/VSGAccess.py
index 3d138df..40148ab 100644
--- a/src/test/utils/VSGAccess.py
+++ b/src/test/utils/VSGAccess.py
@@ -28,6 +28,12 @@
except:
pass
+ '''
+ @method: get_nova_credentials_v2
+ @Description: Get nova credentials
+ @params:
+ returns credential from env
+ '''
@classmethod
def get_nova_credentials_v2(cls):
credential = {}
@@ -37,12 +43,24 @@
credential['project_id'] = os.environ['OS_TENANT_NAME']
return credential
+ '''
+ @method: get_compute_nodes
+ @Description: Get the list of compute nodes
+ @params:
+ returns node list
+ '''
@classmethod
def get_compute_nodes(cls):
credentials = cls.get_nova_credentials_v2()
nvclient = nova_client.Client('2', **credentials)
return nvclient.hypervisors.list()
+ '''
+ @method: get_vsgs
+ @Description: Get list of vsg's running in compute node
+ @params: status of vsg
+ returns vsg wrappers
+ '''
@classmethod
def get_vsgs(cls, active = True):
credentials = cls.get_nova_credentials_v2()
@@ -55,6 +73,12 @@
vsg_wrappers.append(VSGWrapper(vsg))
return vsg_wrappers
+ '''
+ @method: open_mgmt
+ @Description: Bringing up Interface for access to management
+ @params: intf = "Interface to open"
+ returns Gateway
+ '''
@classmethod
def open_mgmt(cls, intf = 'eth0'):
if intf in cls.interface_map:
@@ -72,6 +96,13 @@
return current_gw
return None
+ '''
+ @method: close_mgmt
+ @Description: Bringing up gateway deleting default
+ @params: intf = "Interface to open"
+ dict2 = retrieved data from GET method
+ returns: NA
+ '''
@classmethod
def close_mgmt(cls, restore_gw, intf = 'eth0'):
if restore_gw:
@@ -83,6 +114,12 @@
for cmd in cmds:
os.system(cmd)
+ '''
+ @method: health_check
+ @Description: Check if vsgs are reachable
+ @params:
+ returns True
+ '''
@classmethod
def health_check(cls):
'''Returns 0 if all active vsgs are reachable through the compute node'''
@@ -93,6 +130,12 @@
unreachable = filter(lambda st: st == False, vsg_status)
return len(unreachable) == 0
+ '''
+ @method: get_vcpe_vsg
+ @Description: Getting vsg vm instance info from given vcpe
+ @params: vcpe = "vcpe name"
+ returns vsg
+ '''
@classmethod
def get_vcpe_vsg(cls, vcpe):
'''Find the vsg hosting the vcpe service'''
@@ -106,6 +149,13 @@
return vsg
return None
+ '''
+ @method: save_vcpe_config
+ @Description: Saving vcpe config with lan & wan side info
+ @params: vsg
+ vcpe
+ returns True
+ '''
@classmethod
def save_vcpe_config(cls, vsg, vcpe):
if vcpe not in cls.vcpe_map:
@@ -135,6 +185,15 @@
return True
+ '''
+ @method: restore_vcpe_config
+ @Description: Restoring saved config for lan & wan
+ @params: vcpe
+ gw
+ wan
+ lan
+ returns True/False
+ '''
@classmethod
def restore_vcpe_config(cls, vcpe, gw = True, wan = False, lan = False):
if vcpe in cls.vcpe_map:
@@ -159,28 +218,58 @@
return ret_status
return False
+ '''
+ @method: get_vcpe_gw
+ @Description: Get gw of vcpe from created map
+ @params: vcpe
+ returns gw
+ '''
@classmethod
def get_vcpe_gw(cls, vcpe):
if vcpe in cls.vcpe_map:
return cls.vcpe_map[vcpe]['gw']
return None
+ '''
+ @method: get_vcpe_wan
+ @Description:
+ @params:
+ return wan side of vcpe
+ '''
@classmethod
def get_vcpe_wan(cls, vcpe):
if vcpe in cls.vcpe_map:
return cls.vcpe_map[vcpe]['wan']
return None
+ '''
+ @method: get_vcpe_lan
+ @Description:
+ @params:
+ returns True if contents of dict1 exists in dict2
+ '''
@classmethod
def get_vcpe_lan(cls, vcpe):
if vcpe in cls.vcpe_map:
return cls.vcpe_map[vcpe]['lan']
return None
+ '''
+ @method: vcpe_wan_up
+ @Description:
+ @params:
+ returns status
+ '''
@classmethod
def vcpe_wan_up(cls, vcpe):
return cls.restore_vcpe_config(vcpe)
+ '''
+ @method: vcpe_lan_up
+ @Description:
+ @params:
+ returns status
+ '''
@classmethod
def vcpe_lan_up(cls, vcpe, vsg = None):
if vsg is None:
@@ -191,6 +280,12 @@
st, _ = vsg.run_cmd(cmd, timeout = 30)
return st
+ '''
+ @method: vcpe_port_down
+ @Description:
+ @params:
+ returns status
+ '''
#we cannot access compute node if the vcpe port gets dhcp as default would be through fabric
@classmethod
def vcpe_port_down(cls, vcpe, port, vsg = None):
@@ -207,14 +302,32 @@
return False
return st
+ '''
+ @method: vcpe_wan_down
+ @Description:
+ @params:
+ returns status
+ '''
@classmethod
def vcpe_wan_down(cls, vcpe, vsg = None):
return cls.vcpe_port_down(vcpe, 'eth0', vsg = vsg)
+ '''
+ @method: vcpe_lan_down
+ @Description:
+ @params:
+ returns status
+ '''
@classmethod
def vcpe_lan_down(cls, vcpe, vsg = None):
return cls.vcpe_port_down(vcpe, 'eth1', vsg = vsg)
+ '''
+ @method: save_interface_config
+ @Description:
+ @params:
+ returns NA
+ '''
@classmethod
def save_interface_config(cls, intf):
if intf not in cls.interface_map:
@@ -232,6 +345,12 @@
for cmd in cmds:
os.system(cmd)
+ '''
+ @method: restore_interface_config
+ @Description:
+ @params:
+ returns NA
+ '''
#open up access to compute node
@classmethod
def restore_interface_config(cls, intf, vcpe = None):
@@ -251,6 +370,12 @@
for cmd in cmds:
os.system(cmd)
+ '''
+ @method: vcpe_get_dhcp
+ @Description: Get DHCP from vcpe dhcp interface.
+ @params:
+ returns vcpe ip
+ '''
@classmethod
def vcpe_get_dhcp(cls, vcpe, mgmt = 'eth0'):
'''Get DHCP from vcpe dhcp interface.'''
@@ -286,9 +411,21 @@
self.compute_node = self.get_compute_node()
self.ip = self.get_ip()
+ '''
+ @method: get_compute_node
+ @Description:
+ @params:
+ returns compute node name
+ '''
def get_compute_node(self):
return self.vsg._info['OS-EXT-SRV-ATTR:hypervisor_hostname']
+ '''
+ @method: get_ip
+ @Description:
+ @params:
+ returns ip of network
+ '''
def get_ip(self):
if 'management' in self.vsg.networks:
ips = self.vsg.networks['management']
@@ -296,6 +433,12 @@
return ips[0]
return None
+ '''
+ @method: run_cmd_compute
+ @Description:
+ @params:
+ returns Status & output
+ '''
def run_cmd_compute(self, cmd, timeout = 5):
ssh_agent = SSHTestAgent(self.compute_node)
st, output = ssh_agent.run_cmd(cmd, timeout = timeout)
@@ -306,6 +449,12 @@
return st, output
+ '''
+ @method: run_cmd
+ @Description:
+ @params:
+ returns status & output
+ '''
def run_cmd(self, cmd, timeout = 5, mgmt = 'eth0'):
last_gw = VSGAccess.open_mgmt(mgmt)
ssh_agent = SSHTestAgent(self.compute_node)
@@ -318,6 +467,12 @@
VSGAccess.close_mgmt(last_gw, mgmt)
return st, output
+ '''
+ @method: get_health
+ @Description:
+ @params:
+ returns Status
+ '''
def get_health(self):
if self.ip is None:
return True
@@ -327,6 +482,12 @@
log.info('VSG %s at IP %s is %s' %(self.name, self.ip, 'reachable' if st == True else 'unreachable'))
return st
+ '''
+ @method: check_access
+ @Description: validates access
+ @params:
+ returns Status
+ '''
def check_access(self):
if self.ip is None:
return True