Deal with flake8 errors in tempest

Change-Id: I69f02ce3a589d3854b0508c56b77758a4cf013bd
Signed-off-by: Zhijiang Hu <hu.zhijiang@zte.com.cn>
This commit is contained in:
Zhijiang Hu 2016-09-22 03:48:38 -04:00 committed by Zhou Ya
parent caa9c11e4a
commit 73d88a9f76
7 changed files with 332 additions and 300 deletions

View File

@ -4,6 +4,7 @@ import uuid
class FakeLogicNetwork():
# 1----------------------------------------------------------
def fake_network_parameters(self):
return {
'base_mac': 'fa:16:3e:00:00:00',
@ -102,7 +103,6 @@ class FakeLogicNetwork():
'gateway': '172.16.1.1',
'name': 'subnet10'}]
def fake_router_parameters2(self):
return [{
'description': 'router1',
@ -119,44 +119,45 @@ class FakeLogicNetwork():
# 3-------------------------------------------------------------
def fake_private_network_parameters(self):
return {
'name' : 'phynet2',
'description' : 'phynet2',
'network_type':'DATAPLANE',
'type':'custom',
'vlan_start':'101',
'vlan_end':'1001',
'ml2_type':'ovs'
'name': 'phynet2',
'description': 'phynet2',
'network_type': 'DATAPLANE',
'type': 'custom',
'vlan_start': '101',
'vlan_end': '1001',
'ml2_type': 'ovs'
}
def fake_private_network_parameters1(self):
return {
'name' : 'phynet3',
'description' : 'phynet3',
'network_type':'DATAPLANE',
'type':'custom',
'vlan_start':'101',
'vlan_end':'2000',
'ml2_type':'ovs'
'name': 'phynet3',
'description': 'phynet3',
'network_type': 'DATAPLANE',
'type': 'custom',
'vlan_start': '101',
'vlan_end': '2000',
'ml2_type': 'ovs'
}
def fake_private_network_parameters2(self):
return {
'name' : 'phynet1',
'description' : 'phynet1',
'network_type':'DATAPLANE',
'type':'custom',
'vlan_start':'101',
'vlan_end':'2000',
'ml2_type':'ovs'
'name': 'phynet1',
'description': 'phynet1',
'network_type': 'DATAPLANE',
'type': 'custom',
'vlan_start': '101',
'vlan_end': '2000',
'ml2_type': 'ovs'
}
class FakeDiscoverHosts():
# 1----------------------------------------------------------
daisy_data = [{'description': 'default',
'name': '4c09b4b2788a',
'ipmi_addr': '10.43.203.230',
'ipmi_user':'albert',
'ipmi_passwd':'superuser',
'ipmi_user': 'albert',
'ipmi_passwd': 'superuser',
'interfaces': [{'name': 'enp132s0f0',
"mac": '4c:09:b4:b2:78:8a',
"ip": '99.99.1.60',
@ -168,8 +169,8 @@ class FakeDiscoverHosts():
{'description': 'default',
'name': '4c09b4b2798a',
'ipmi_addr': '10.43.203.231',
'ipmi_user':'albert',
'ipmi_passwd':'superuser',
'ipmi_user': 'albert',
'ipmi_passwd': 'superuser',
'interfaces': [{'name': 'enp132s0f0',
"mac": '4c:09:b4:b2:79:8a',
"ip": '99.99.1.61',
@ -181,8 +182,8 @@ class FakeDiscoverHosts():
{'description': 'default',
'name': '4c09b4b2808a',
'ipmi_addr': '10.43.203.232',
'ipmi_user':'albert',
'ipmi_passwd':'superuser',
'ipmi_user': 'albert',
'ipmi_passwd': 'superuser',
'interfaces': [{'name': 'enp132s0f0',
"mac": '4c:09:b4:b2:80:8a',
"ip": '99.99.1.62',
@ -192,128 +193,160 @@ class FakeDiscoverHosts():
'os_status': 'init',
'dmi_uuid': '03000200-0400-0500-0006-000700080009'}]
ironic_disk_data = [{'uuid':'03000200-0400-0500-0006-000700080009',
ironic_disk_data = \
[{'uuid': '03000200-0400-0500-0006-000700080009',
'mac': '4c:09:b4:b2:78:8a',
'patch':[{'op': 'add',
'patch': [{'op': 'add',
'path': '/disks/sda',
'value': {'disk': 'pci-0000:01:00.0-sas-0x500003956831a6da-lun-0',
'extra': ['scsi-3500003956831a6d8', 'wwn-0x500003956831a6d8'],
'value': {
'disk':
'pci-0000:01:00.0-sas-0x500003956831a6da-lun-0',
'extra': ['scsi-3500003956831a6d8',
'wwn-0x500003956831a6d8'],
'model': '',
'name': 'sda',
'removable': '',
'size': ' 200127266816 bytes'}}]},
{'uuid':'03000200-0400-0500-0006-000700080009',
{'uuid': '03000200-0400-0500-0006-000700080009',
'mac': '4c:09:b4:b2:79:8a',
'patch':[{'op': 'add',
'patch':
[{'op': 'add',
'path': '/disks/sda',
'value': {'disk': 'pci-0000:01:00.0-sas-0x500003956831a6da-lun-0',
'extra': ['scsi-3500003956831a6d8', 'wwn-0x500003956831a6d8'],
'value':
{'disk': 'pci-0000:01:00.0-sas-0x500003956831a6da-lun-0',
'extra': ['scsi-3500003956831a6d8',
'wwn-0x500003956831a6d8'],
'model': '',
'name': 'sda',
'removable': '',
'size': ' 200127266816 bytes'}}]},
{'uuid':'03000200-0400-0500-0006-000700080009',
{'uuid': '03000200-0400-0500-0006-000700080009',
'mac': '4c:09:b4:b2:80:8a',
'patch':[{'op': 'add',
'patch': [{'op': 'add',
'path': '/disks/sda',
'value': {'disk': 'pci-0000:01:00.0-sas-0x500003956831a6da-lun-0',
'extra': ['scsi-3500003956831a6d8', 'wwn-0x500003956831a6d8'],
'value':
{'disk': 'pci-0000:01:00.0-sas-'
'0x500003956831a6da-lun-0',
'extra': ['scsi-3500003956831a6d8',
'wwn-0x500003956831a6d8'],
'model': '',
'name': 'sda',
'removable': '',
'size': ' 200127266816 bytes'}}]}]
ironic_memory_data = [{'uuid':'03000200-0400-0500-0006-000700080009',
ironic_memory_data = [{'uuid': '03000200-0400-0500-0006-000700080009',
'mac': '4c:09:b4:b2:78:8a',
'patch':[{'path': '/memory/total',
'patch': [{'path': '/memory/total',
'value': ' 1850020 kB',
'op': 'add'},
{'path': '/memory/phy_memory_1',
'value': {'slots': ' 2',
'devices_1': {'frequency': '',
'type': ' DIMM SDRAM',
'value':
{'slots': ' 2',
'devices_1':
{'frequency': '',
'type':
' DIMM SDRAM',
'size': ' 4096 MB'},
'maximum_capacity': ' 4 GB',
'devices_2': {'frequency': ' 3 ns',
'type': ' DIMM SDRAM',
'type':
' DIMM SDRAM',
'size': ' 8192 MB'}},
'op': 'add'},
]},
{'uuid':'03000200-0400-0500-0006-000700080009',
{'uuid': '03000200-0400-0500-0006-000700080009',
'mac': '4c:09:b4:b2:79:8a',
'patch':[{'path': '/memory/total',
'patch': [{'path': '/memory/total',
'value': ' 1850020 kB',
'op': 'add'},
{'path': '/memory/phy_memory_1',
'value': {'slots': ' 3',
'devices_1': {'frequency': '',
'devices_1':
{'frequency': '',
'type': ' DIMM SDRAM',
'size': ' 4096 MB'},
'maximum_capacity': ' 4 GB',
'devices_2': {'frequency': ' 3 ns',
'devices_2': {
'frequency': ' 3 ns',
'type': ' DIMM SDRAM',
'size': ' 8192 MB'}},
'op': 'add'},
]},
{'uuid':'03000200-0400-0500-0006-000700080009',
{'uuid': '03000200-0400-0500-0006-000700080009',
'mac': '4c:09:b4:b2:80:8a',
'patch':[{'path': '/memory/total',
'patch': [{'path': '/memory/total',
'value': ' 1850020 kB',
'op': 'add'},
{'path': '/memory/phy_memory_1',
'value': {'slots': ' 3',
'devices_1': {'frequency': '',
'devices_1': {
'frequency': '',
'type': ' DIMM SDRAM',
'size': ' 4096 MB'},
'maximum_capacity': ' 4 GB',
'devices_2': {'frequency': ' 3 ns',
'devices_2': {
'frequency': ' 3 ns',
'type': ' DIMM SDRAM',
'size': ' 8192 MB'}},
'op': 'add'},
]}]
ironic_cpu_data = [{'uuid':'03000200-0400-0500-0006-000700080009',
ironic_cpu_data = \
[{'uuid': '03000200-0400-0500-0006-000700080009',
'mac': '4c:09:b4:b2:78:8a',
'patch':[{'path': '/cpu/real',
'patch': [{'path': '/cpu/real',
'value': 1,
'op': 'add'},
{'path': '/cpu/total',
'value': 2,
'op': 'add'},
{'path': '/cpu/spec_1',
'value': {'model': ' Pentium(R) Dual-Core CPU E5700 @ 3.00GHz' , 'frequency': 3003},
'value': {'model': ' Pentium(R) Dual-Core CPU '
' E5700 @ 3.00GHz',
'frequency': 3003},
'op': 'add'},
{'path': '/cpu/spec_2',
'value': {'model': ' Pentium(R) Dual-Core CPU E5700 @ 3.00GHz', 'frequency': 3003},
'value': {'model': ' Pentium(R) Dual-Core CPU '
' E5700 @ 3.00GHz',
'frequency': 3003},
'op': 'add'}
]},
{'uuid':'03000200-0400-0500-0006-000700080009',
{'uuid': '03000200-0400-0500-0006-000700080009',
'mac': '4c:09:b4:b2:79:8a',
'patch':[{'path': '/cpu/real',
'patch': [{'path': '/cpu/real',
'value': 1,
'op': 'add'},
{'path': '/cpu/total',
'value': 2,
'op': 'add'},
{'path': '/cpu/spec_1',
'value': {'model': ' Pentium(R) Dual-Core CPU E5700 @ 3.00GHz' , 'frequency': 3003},
'value':
{'model': ' Pentium(R) Dual-Core CPU '
' E5700 @ 3.00GHz',
'frequency': 3003},
'op': 'add'},
{'path': '/cpu/spec_2',
'value': {'model': ' Pentium(R) Dual-Core CPU E5700 @ 3.00GHz', 'frequency': 3003},
'value': {'model': ' Pentium(R) Dual-Core CPU '
' E5700 @ 3.00GHz',
'frequency': 3003},
'op': 'add'}
]},
{'uuid':'03000200-0400-0500-0006-000700080009',
{'uuid': '03000200-0400-0500-0006-000700080009',
'mac': '4c:09:b4:b2:80:8a',
'patch':[{'path': '/cpu/real',
'patch': [{'path': '/cpu/real',
'value': 1,
'op': 'add'},
{'path': '/cpu/total',
'value': 2,
'op': 'add'},
{'path': '/cpu/spec_1',
'value': {'model': ' Pentium(R) Dual-Core CPU E5700 @ 3.00GHz' , 'frequency': 3003},
'value': {'model': ' Pentium(R) Dual-Core CPU '
' E5700 @ 3.00GHz',
'frequency': 3003},
'op': 'add'},
{'path': '/cpu/spec_2',
'value': {'model': ' Pentium(R) Dual-Core CPU E5700 @ 3.00GHz', 'frequency': 3003},
'value': {'model': ' Pentium(R) Dual-Core CPU '
' E5700 @ 3.00GHz',
'frequency': 3003},
'op': 'add'}
]}]

View File

@ -30,8 +30,8 @@ list_migrations = {
'dest_node': {'type': 'string'},
'dest_compute': {'type': 'string'},
'dest_host': {'type': 'string'},
#zfl : tecs 1.0 old_instance_type_id is None
#'old_instance_type_id': {'type': 'integer'},
# zfl : tecs 1.0 old_instance_type_id is None
# 'old_instance_type_id': {'type': 'integer'},
'new_instance_type_id': {'type': 'integer'},
'created_at': {'type': 'string'},
'updated_at': {'type': ['string', 'null']}

View File

@ -27,16 +27,17 @@ class RemoteClient(object):
# NOTE(afazekas): It should always get an address instead of server
def __init__(self, server, username, password=None, pkey=None):
#zfl: use server's generated adminpass can't ssh,so
#if password is a generated one, use CONF.compute.image_ssh_password instead;
#if password is specified by use, just use it
# zfl: use server's generated adminpass can't ssh,so
# if password is a generated one,
# use CONF.compute.image_ssh_password instead;
# if password is specified by use, just use it
if password is not None and password.startswith('opencos'):
self.password = password[len('opencos'):]
else:
self.password = CONF.compute.image_ssh_password
self.ssh_timeout = CONF.compute.ssh_timeout
#network = CONF.compute.network_for_ssh
# network = CONF.compute.network_for_ssh
network = CONF.compute.fixed_network_name
self.ip_version = CONF.compute.ip_version_for_ssh
self.ssh_channel_timeout = CONF.compute.ssh_channel_timeout
@ -44,7 +45,8 @@ class RemoteClient(object):
self.ip_address = server
else:
self.addresses = server['addresses'][network]
#zfl look for network backwards (first floating ip,then internal ip)
# zfl look for network backwards (first floating ip,then internal
# ip)
for address in self.addresses[::-1]:
if address['version'] == self.ip_version:
self.ip_address = address['addr']

View File

@ -27,7 +27,8 @@ def exectime(func):
def newfunc(*args, **args2):
t0 = time.time()
f = func(*args, **args2)
print "\n\n@====exectime====%.3fs taken for {%s}\n\n" % (time.time() - t0, func.__name__)
print "\n\n@====exectime====%.3fs taken for {%s}\n\n" \
% (time.time() - t0, func.__name__)
return f
return newfunc
# zfl add end
@ -87,14 +88,15 @@ class TempestException(Exception):
log_result + \
"\n\n===possiblelog end===\n\n\n"
except Exception as e:
print "ZTE ===zfl : error ==" , e
print "ZTE ===zfl : error ==", e
traceback.print_exc()
# else:
# print "\n========zfl,exception call __str__ again"
#zfl add end: get related opencos log
# zfl add end: get related opencos log
return self._error_string
class RestClientException(TempestException,
testtools.TestCase.failureException):
pass
@ -227,6 +229,7 @@ class InvalidStructure(TempestException):
class CommandFailed(Exception):
def __init__(self, returncode, cmd, output, stderr):
super(CommandFailed, self).__init__()
self.returncode = returncode

View File

@ -13,10 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
import errno
import json
import os
import time
import urllib
@ -53,9 +50,6 @@ class DaisyClientJSON(service_client.ServiceClient):
self.dscv = disable_ssl_certificate_validation
self.ca_certs = ca_certs
def _get_http(self):
return glance_http.HTTPClient(auth_provider=self.auth_provider,
filters=self.filters,

View File

@ -85,7 +85,7 @@ class TokenClientJSON(rest_client.RestClient):
resp, resp_body = self.raw_request(url, method,
headers=headers, body=body)
self._log_request(method, url, resp, req_body=body) #zfl add
self._log_request(method, url, resp, req_body=body) # zfl add
if resp.status in [401, 403]:
resp_body = json.loads(resp_body)