本文整理汇总了Python中tacker.tests.utils.read_file函数的典型用法代码示例。如果您正苦于以下问题:Python read_file函数的具体用法?Python read_file怎么用?Python read_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _test_vnf_with_monitoring
def _test_vnf_with_monitoring(self, vnfd_file, vnf_name):
data = dict()
data['tosca'] = read_file(vnfd_file)
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id']
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
# Verify vnf goes from ACTIVE->DEAD->ACTIVE states
self.verify_vnf_restart(vnfd_instance, vnf_instance)
# Delete vnf_instance with vnf_id
vnf_id = vnf_instance['vnf']['id']
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, ("Failed to delete vnf %s after the monitor test" %
vnf_id)
# Delete vnfd_instance
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, ("Failed to delete vnfd %s after the monitor test" %
vnfd_id)
开发者ID:DorChen,项目名称:tacker,代码行数:32,代码来源:test_vnf_monitoring.py
示例2: _test_vnf_with_monitoring
def _test_vnf_with_monitoring(self, vnfd_file, vnf_name):
data = dict()
data["tosca"] = read_file(vnfd_file)
toscal = data["tosca"]
tosca_arg = {"vnfd": {"attributes": {"vnfd": toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance["vnfd"]["id"]
vnf_arg = {"vnf": {"vnfd_id": vnfd_id, "name": vnf_name}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
# Verify vnf goes from ACTIVE->DEAD->ACTIVE states
self.verify_vnf_restart(vnfd_instance, vnf_instance)
# Delete vnf_instance with vnf_id
vnf_id = vnf_instance["vnf"]["id"]
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, "Failed to delete vnf %s after the monitor test" % vnf_id
# Delete vnfd_instance
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "Failed to delete vnfd %s after the monitor test" % vnfd_id
开发者ID:liujyg,项目名称:tacker,代码行数:30,代码来源:test_vnf_monitoring.py
示例3: test_assign_floatingip_to_vdu
def test_assign_floatingip_to_vdu(self):
vnfd_file = 'sample_tosca_assign_floatingip_to_vdu.yaml'
vnf_name = 'Assign Floating IP to VDU'
values_str = read_file(vnfd_file)
template = yaml.safe_load(values_str)
vnf_arg = {'vnf': {'vnfd_template': template, 'name': vnf_name}}
self.connect_public_and_private_nw_with_router()
vnf_instance = self.client.create_vnf(body=vnf_arg)
vnf_id = vnf_instance['vnf']['id']
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
self.addCleanup(self.client.delete_vnf, vnf_id)
self.wait_until_vnf_active(
vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
vnf_show_out = self.client.show_vnf(vnf_id)['vnf']
self.assertIsNotNone(vnf_show_out['mgmt_ip_address'])
stack_id = vnf_show_out['instance_id']
fip_res = self.get_heat_stack_resource(stack_id, 'FIP1')
floating_ip_address = fip_res['attributes']['floating_ip_address']
self.assertIsNotNone(floating_ip_address)
fip_port_id = fip_res['attributes']['port_id']
port_res = self.get_heat_stack_resource(stack_id, 'CP1')
port_id = port_res['attributes']['id']
self.assertEqual(fip_port_id, port_id)
开发者ID:openstack,项目名称:tacker,代码行数:27,代码来源:test_tosca_vnf_floatingip.py
示例4: test_create_delete_vnf_tosca_no_monitoring
def test_create_delete_vnf_tosca_no_monitoring(self):
vnfd_name = 'tosca_vnfd_with_auto_image'
input_yaml = read_file('sample-tosca-vnfd-image.yaml')
tosca_dict = yaml.safe_load(input_yaml)
tosca_arg = {'vnfd': {'name': vnfd_name, 'attributes': {'vnfd':
tosca_dict}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id']
vnf_name = 'tosca_vnf_with_auto_image'
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
self.validate_vnf_instance(vnfd_instance, vnf_instance)
vnf_id = vnf_instance['vnf']['id']
self.wait_until_vnf_active(
vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf'][
'mgmt_ip_address'])
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
servers = self.novaclient().servers.list()
vdu_server = None
for server in servers:
if 'VDU1_image_func' in server.name:
vdu_server = server
break
self.assertIsNotNone(vdu_server)
image_id = vdu_server.image["id"]
nova_images = self.novaclient().images
image = nova_images.get(image_id)
self.assertIsNotNone(image)
self.assertEqual(True, "VNFImage_image_func" in image.name)
# Delete vnf_instance with vnf_id
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, "vnf Delete failed"
self.wait_until_vnf_delete(vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
self.verify_vnf_crud_events(vnf_id, evt_constants.RES_EVT_DELETE,
evt_constants.PENDING_DELETE, cnt=2)
# Delete vnfd_instance
self.addCleanup(self.client.delete_vnfd, vnfd_id)
self.assertRaises(exceptions.NotFound, nova_images.delete,
[image_id])
开发者ID:openstack,项目名称:tacker,代码行数:60,代码来源:test_tosca_vnf.py
示例5: _test_vnf_with_monitoring
def _test_vnf_with_monitoring(self, vnfd_file, vnf_name):
data = dict()
data['tosca'] = read_file(vnfd_file)
toscal = data['tosca']
tosca_arg = {'vnfd': {'name': vnf_name,
'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id']
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
# Verify vnf goes from ACTIVE->DEAD->ACTIVE states
self.verify_vnf_restart(vnfd_instance, vnf_instance)
# Delete vnf_instance with vnf_id
vnf_id = vnf_instance['vnf']['id']
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, ("Failed to delete vnf %s after the monitor test" %
vnf_id)
# Verify VNF monitor events captured for states, ACTIVE and DEAD
vnf_state_list = [evt_constants.ACTIVE, evt_constants.DEAD]
self.verify_vnf_monitor_events(vnf_id, vnf_state_list)
# Delete vnfd_instance
self.addCleanup(self.client.delete_vnfd, vnfd_id)
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
开发者ID:pineunity,项目名称:tacker,代码行数:35,代码来源:test_vnf_monitoring.py
示例6: _test_create_delete_vim
def _test_create_delete_vim(self, vim_file, name, description, vim_type,
version=None):
data = yaml.load(read_file(vim_file))
password = data['password']
username = data['username']
project_name = data['project_name']
auth_url = data['auth_url']
vim_arg = {'vim': {'name': name, 'description': description,
'type': vim_type,
'auth_url': auth_url,
'auth_cred': {'username': username,
'password': password},
'vim_project': {'name': project_name}}}
# Register vim
vim_res = self.client.create_vim(vim_arg)
vim_obj = vim_res['vim']
vim_id = vim_obj['id']
self.verify_vim(vim_obj, data, name, description, version)
# Read vim
vim_show_res = self.client.show_vim(vim_id)
self.verify_vim(vim_show_res['vim'], data, name, description, version)
# Delete vim
try:
self.client.delete_vim(vim_id)
except Exception:
self.assertFalse(True, "Failed to delete vim %s" % vim_id)
开发者ID:oglok,项目名称:tacker,代码行数:31,代码来源:test_vim.py
示例7: _test_vnf_create
def _test_vnf_create(self, vnfd_instance, vnf_name, vnf_value_file):
# Create the vnf with values
vnfd_id = vnfd_instance['vnfd']['id']
values_str = read_file(vnf_value_file)
# Create vnf with values file
vnf_dict = dict()
vnf_dict = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name,
'attributes': {'param_values': values_str}}}
vnf_instance = self.client.create_vnf(body=vnf_dict)
self.validate_vnf_instance(vnfd_instance, vnf_instance)
vnf_id = vnf_instance['vnf']['id']
vnf_current_status = self.wait_until_vnf_active(
vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual('ACTIVE', vnf_current_status)
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
vnf_instance = self.client.show_vnf(vnf_id)
# Verify values dictionary is same as param values from vnf_show
input_dict = yaml.load(values_str)
param_values = vnf_instance['vnf']['attributes']['param_values']
param_values_dict = yaml.load(param_values)
self.assertEqual(input_dict, param_values_dict)
return vnf_instance
开发者ID:Urban123,项目名称:tacker,代码行数:27,代码来源:test_vnfm_param.py
示例8: heatclient
def heatclient(cls):
data = yaml.load(read_file('local-vim.yaml'))
data['auth_url'] = data['auth_url'] + '/v3'
domain_name = data.pop('domain_name')
data['user_domain_name'] = domain_name
data['project_domain_name'] = domain_name
return clients.OpenstackClients(auth_attr=data).heat
开发者ID:pineunity,项目名称:tacker,代码行数:7,代码来源:base.py
示例9: _test_create_nsd
def _test_create_nsd(self, tosca_nsd_file, nsd_name):
input_yaml = read_file(tosca_nsd_file)
tosca_dict = yaml.safe_load(input_yaml)
tosca_arg = {'nsd': {'name': nsd_name,
'attributes': {'nsd': tosca_dict}}}
nsd_instance = self.client.create_nsd(body=tosca_arg)
self.assertIsNotNone(nsd_instance)
return nsd_instance['nsd']['id']
开发者ID:openstack,项目名称:tacker,代码行数:8,代码来源:test_nfvo.py
示例10: test_create_delete_vnf_with_multiple_vdus
def test_create_delete_vnf_with_multiple_vdus(self):
data = dict()
input_yaml = read_file('sample-vnfd-multi-vdu.yaml')
data['tosca'] = input_yaml
toscal = data['tosca']
vnfd_name = 'sample-vnfd-multi-vdu'
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id']
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name':
"test_vnf_with_multiple_vdus"}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
vnf_id = vnf_instance['vnf']['id']
self.wait_until_vnf_active(vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual('ACTIVE',
self.client.show_vnf(vnf_id)['vnf']['status'])
self.validate_vnf_instance(vnfd_instance, vnf_instance)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
# Validate mgmt_url with input yaml file
mgmt_url = self.client.show_vnf(vnf_id)['vnf']['mgmt_url']
self.assertIsNotNone(mgmt_url)
mgmt_dict = yaml.load(str(mgmt_url))
input_dict = yaml.load(input_yaml)
self.assertEqual(len(input_dict['vdus'].keys()), len(mgmt_dict.keys()))
for vdu in input_dict['vdus'].keys():
self.assertIsNotNone(mgmt_dict[vdu])
self.assertEqual(True, utils.is_valid_ipv4(mgmt_dict[vdu]))
# Delete vnf_instance with vnf_id
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, "vnf Delete of test_vnf_with_multiple_vdus failed"
self.wait_until_vnf_delete(vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
self.verify_vnf_crud_events(vnf_id, evt_constants.RES_EVT_DELETE,
evt_constants.PENDING_DELETE, cnt=2)
# Delete vnfd_instance
self.addCleanup(self.client.delete_vnfd, vnfd_id)
开发者ID:K-OpenNet,项目名称:OPNFV-StateMon,代码行数:57,代码来源:test_vnf_multiple_vdu.py
示例11: _test_create_vnf
def _test_create_vnf(self, vnfd_file, vnf_name,
template_source="onboarded"):
input_yaml = read_file(vnfd_file)
tosca_dict = yaml.safe_load(input_yaml)
tosca_arg = {'vnfd': {'name': vnf_name,
'attributes': {'vnfd': tosca_dict}}}
if template_source == "onboarded":
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id']
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
self.validate_vnf_instance(vnfd_instance, vnf_instance)
if template_source == 'inline':
# create vnf directly from template
vnf_arg = {'vnf': {'vnfd_template': tosca_dict, 'name': vnf_name}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
vnfd_id = vnf_instance['vnf']['vnfd_id']
vnf_id = vnf_instance['vnf']['id']
self.wait_until_vnf_active(
vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
vnf_show_out = self.client.show_vnf(vnf_id)['vnf']
self.assertIsNotNone(vnf_show_out['mgmt_ip_address'])
prop_dict = tosca_dict['topology_template']['node_templates'][
'CP1']['properties']
# Verify if ip_address is static, it is same as in show_vnf
if prop_dict.get('ip_address'):
mgmt_ip_address_input = prop_dict.get('ip_address')
mgmt_info = yaml.safe_load(
vnf_show_out['mgmt_ip_address'])
self.assertEqual(mgmt_ip_address_input, mgmt_info['VDU1'])
# Verify anti spoofing settings
stack_id = vnf_show_out['instance_id']
template_dict = tosca_dict['topology_template']['node_templates']
for field in template_dict.keys():
prop_dict = template_dict[field]['properties']
if prop_dict.get('anti_spoofing_protection'):
self.verify_antispoofing_in_stack(stack_id=stack_id,
resource_name=field)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE, cnt=2)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
return vnfd_id, vnf_id
开发者ID:openstack,项目名称:tacker,代码行数:57,代码来源:test_tosca_vnf_block_storage.py
示例12: test_create_delete_tosca_vnf_with_multiple_vdus
def test_create_delete_tosca_vnf_with_multiple_vdus(self):
input_yaml = read_file("sample-tosca-vnfd-multi-vdu.yaml")
tosca_dict = yaml.safe_load(input_yaml)
vnfd_name = "sample-tosca-vnfd-multi-vdu"
tosca_arg = {"vnfd": {"name": vnfd_name, "attributes": {"vnfd": tosca_dict}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance["vnfd"]["id"]
vnf_arg = {"vnf": {"vnfd_id": vnfd_id, "name": "test_tosca_vnf_with_multiple_vdus"}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
vnf_id = vnf_instance["vnf"]["id"]
self.wait_until_vnf_active(vnf_id, constants.VNF_CIRROS_CREATE_TIMEOUT, constants.ACTIVE_SLEEP_TIME)
self.assertEqual("ACTIVE", self.client.show_vnf(vnf_id)["vnf"]["status"])
self.validate_vnf_instance(vnfd_instance, vnf_instance)
self.verify_vnf_crud_events(
vnf_id,
evt_constants.RES_EVT_CREATE,
evt_constants.PENDING_CREATE,
vnf_instance["vnf"][evt_constants.RES_EVT_CREATED_FLD],
)
self.verify_vnf_crud_events(vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
# Validate mgmt_url with input yaml file
mgmt_url = self.client.show_vnf(vnf_id)["vnf"]["mgmt_url"]
self.assertIsNotNone(mgmt_url)
mgmt_dict = yaml.load(str(mgmt_url))
input_dict = yaml.load(input_yaml)
toscautils.updateimports(input_dict)
tosca = tosca_template.ToscaTemplate(parsed_params={}, a_file=False, yaml_dict_tpl=input_dict)
vdus = toscautils.findvdus(tosca)
self.assertEqual(len(vdus), len(mgmt_dict.keys()))
for vdu in vdus:
self.assertIsNotNone(mgmt_dict[vdu.name])
self.assertEqual(True, utils.is_valid_ipv4(mgmt_dict[vdu.name]))
# Delete vnf_instance with vnf_id
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, "vnf Delete of test_vnf_with_multiple_vdus failed"
self.wait_until_vnf_delete(vnf_id, constants.VNF_CIRROS_DELETE_TIMEOUT)
self.verify_vnf_crud_events(vnf_id, evt_constants.RES_EVT_DELETE, evt_constants.PENDING_DELETE, cnt=2)
# Delete vnfd_instance
self.addCleanup(self.client.delete_vnfd, vnfd_id)
开发者ID:K-OpenNet,项目名称:OPNFV-StateMon,代码行数:56,代码来源:test_tosca_vnf_multiple_vdu.py
示例13: test_create_delete_tosca_vnf_with_multiple_vdus
def test_create_delete_tosca_vnf_with_multiple_vdus(self):
data = dict()
input_yaml = read_file('sample-tosca-vnfd-multi-vdu.yaml')
data['tosca'] = input_yaml
toscal = data['tosca']
vnfd_name = 'sample-tosca-vnfd-multi-vdu'
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id']
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name':
"test_tosca_vnf_with_multiple_vdus"}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
vnf_id = vnf_instance['vnf']['id']
self.wait_until_vnf_active(vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual('ACTIVE',
self.client.show_vnf(vnf_id)['vnf']['status'])
self.validate_vnf_instance(vnfd_instance, vnf_instance)
# Validate mgmt_url with input yaml file
mgmt_url = self.client.show_vnf(vnf_id)['vnf']['mgmt_url']
self.assertIsNotNone(mgmt_url)
mgmt_dict = yaml.load(str(mgmt_url))
input_dict = yaml.load(input_yaml)
toscautils.updateimports(input_dict)
tosca = ToscaTemplate(parsed_params={}, a_file=False,
yaml_dict_tpl=input_dict)
vdus = toscautils.findvdus(tosca)
self.assertEqual(len(vdus), len(mgmt_dict.keys()))
for vdu in vdus:
self.assertIsNotNone(mgmt_dict[vdu.name])
self.assertEqual(True, utils.is_valid_ipv4(mgmt_dict[vdu.name]))
# Delete vnf_instance with vnf_id
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, "vnf Delete of test_vnf_with_multiple_vdus failed"
# Delete vnfd_instance
self.addCleanup(self.client.delete_vnfd, vnfd_id)
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
开发者ID:bharaththiruveedula,项目名称:tacker,代码行数:55,代码来源:test_tosca_vnf_multiple_vdu.py
示例14: _test_create_vnf
def _test_create_vnf(self, vnfd_file, vnf_name):
data = dict()
values_str = read_file(vnfd_file)
data['tosca'] = values_str
toscal = data['tosca']
tosca_arg = {'vnfd': {'name': vnf_name,
'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id']
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
self.validate_vnf_instance(vnfd_instance, vnf_instance)
vnf_id = vnf_instance['vnf']['id']
self.wait_until_vnf_active(
vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
vnf_show_out = self.client.show_vnf(vnf_id)['vnf']
self.assertIsNotNone(vnf_show_out['mgmt_url'])
input_dict = yaml.load(values_str)
prop_dict = input_dict['topology_template']['node_templates'][
'CP1']['properties']
# Verify if ip_address is static, it is same as in show_vnf
if prop_dict.get('ip_address'):
mgmt_url_input = prop_dict.get('ip_address')
mgmt_info = yaml.load(
vnf_show_out['mgmt_url'])
self.assertEqual(mgmt_url_input, mgmt_info['VDU1'])
# Verify anti spoofing settings
stack_id = vnf_show_out['instance_id']
template_dict = input_dict['topology_template']['node_templates']
for field in template_dict.keys():
prop_dict = template_dict[field]['properties']
if prop_dict.get('anti_spoofing_protection'):
self.verify_antispoofing_in_stack(stack_id=stack_id,
resource_name=field)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
return vnfd_id, vnf_id
开发者ID:K-OpenNet,项目名称:OPNFV-StateMon,代码行数:53,代码来源:test_tosca_vnf.py
示例15: _test_create_tosca_vnfd
def _test_create_tosca_vnfd(self, tosca_vnfd_file, vnfd_name):
input_yaml = read_file(tosca_vnfd_file)
tosca_dict = yaml.safe_load(input_yaml)
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': tosca_dict}}}
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertEqual(vnfd_instance['vnfd']['name'], vnfd_name)
self.assertIsNotNone(vnfd_instance)
vnfds = self.client.list_vnfds().get('vnfds')
self.assertIsNotNone(vnfds, "List of vnfds are Empty after Creation")
return vnfd_instance['vnfd']['id']
开发者ID:openstack,项目名称:tacker,代码行数:12,代码来源:test_nfvo.py
示例16: _test_create_delete_vnf
def _test_create_delete_vnf(self, vnf_name, vnfd_name, vim_id=None):
data = dict()
data['tosca'] = read_file('sample_cirros_vnf_no_monitoring.yaml')
toscal = data['tosca']
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id']
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
if vim_id:
vnf_arg['vnf']['vim_id'] = vim_id
vnf_instance = self.client.create_vnf(body=vnf_arg)
self.validate_vnf_instance(vnfd_instance, vnf_instance)
vnf_id = vnf_instance['vnf']['id']
self.wait_until_vnf_active(
vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
if vim_id:
self.assertEqual(vim_id, vnf_instance['vnf']['vim_id'])
# Get vnf details when vnf is in active state
vnf_details = self.client.list_vnf_resources(vnf_id)['resources'][0]
self.assertIn('name', vnf_details)
self.assertIn('id', vnf_details)
self.assertIn('type', vnf_details)
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.PENDING_CREATE,
vnf_instance['vnf'][evt_constants.RES_EVT_CREATED_FLD])
self.verify_vnf_crud_events(
vnf_id, evt_constants.RES_EVT_CREATE, evt_constants.ACTIVE)
# Delete vnf_instance with vnf_id
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, "vnf Delete failed"
self.wait_until_vnf_delete(vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
self.verify_vnf_crud_events(vnf_id, evt_constants.RES_EVT_DELETE,
evt_constants.PENDING_DELETE, cnt=2)
# Delete vnfd_instance
self.addCleanup(self.client.delete_vnfd, vnfd_id)
开发者ID:K-OpenNet,项目名称:OPNFV-StateMon,代码行数:53,代码来源:test_vnf.py
示例17: _test_vnfd_create
def _test_vnfd_create(self, vnfd_file):
yaml_input = dict()
yaml_input['tosca'] = read_file(vnfd_file)
toscal = yaml_input['tosca']
req_dict = {'vnfd': {'attributes': {'vnfd': toscal}}}
# Create vnfd
vnfd_instance = self.client.create_vnfd(body=req_dict)
self.assertIsNotNone(vnfd_instance)
vnfd_id = vnfd_instance['vnfd']['id']
self.assertIsNotNone(vnfd_id)
return vnfd_instance
开发者ID:DorChen,项目名称:tacker,代码行数:12,代码来源:test_vnfm_param.py
示例18: _test_create_delete_ns
def _test_create_delete_ns(self, nsd_file, ns_name,
template_source='onboarded'):
vnfd1_id = self._test_create_tosca_vnfd(
'test-ns-vnfd1.yaml',
'test-ns-vnfd1')
vnfd2_id = self._test_create_tosca_vnfd(
'test-ns-vnfd2.yaml',
'test-ns-vnfd2')
if template_source == 'onboarded':
nsd_id = self._test_create_nsd(
nsd_file,
'test-ns-nsd')
ns_arg = {'ns': {
'nsd_id': nsd_id,
'name': ns_name,
'attributes': {"param_values": {
"nsd": {
"vl2_name": "net0",
"vl1_name": "net_mgmt"}}}}}
ns_instance = self.client.create_ns(body=ns_arg)
ns_id = ns_instance['ns']['id']
if template_source == 'inline':
input_yaml = read_file(nsd_file)
template = yaml.safe_load(input_yaml)
ns_arg = {'ns': {
'name': ns_name,
'attributes': {"param_values": {
"nsd": {
"vl2_name": "net0",
"vl1_name": "net_mgmt"}}},
'nsd_template': template}}
ns_instance = self.client.create_ns(body=ns_arg)
ns_id = ns_instance['ns']['id']
self._wait_until_ns_status(ns_id, 'ACTIVE',
constants.NS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
ns_show_out = self.client.show_ns(ns_id)['ns']
self.assertIsNotNone(ns_show_out['mgmt_ip_addresses'])
try:
self.client.delete_ns(ns_id)
except Exception as e:
print("Exception:", e)
assert False, "ns Delete failed"
if template_source == 'onboarded':
self._wait_until_ns_delete(ns_id, constants.NS_DELETE_TIMEOUT)
self._test_delete_nsd(nsd_id)
self._test_delete_vnfd(vnfd1_id)
self._test_delete_vnfd(vnfd2_id)
开发者ID:openstack,项目名称:tacker,代码行数:52,代码来源:test_nfvo.py
示例19: test_create_delete_vnf_tosca_no_monitoring
def test_create_delete_vnf_tosca_no_monitoring(self):
data = dict()
vnfd_name = 'tosca_vnfd_with_auto_flavor'
data['tosca'] = read_file('sample-tosca-vnfd-flavor.yaml')
toscal = data['tosca']
tosca_arg = {'vnfd': {'name': vnfd_name, 'attributes': {'vnfd':
toscal}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
# Create vnf with vnfd_id
vnf_name = 'tosca_vnf_with_auto_flavor'
vnfd_id = vnfd_instance['vnfd']['id']
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
self.validate_vnf_instance(vnfd_instance, vnf_instance)
vnf_id = vnf_instance['vnf']['id']
vnf_current_status = self.wait_until_vnf_active(
vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual(vnf_current_status, 'ACTIVE')
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
servers = self.novaclient().servers.list()
vdu_server = None
for server in servers:
if 'VDU1_flavor_func' in server.name:
vdu_server = server
break
self.assertIsNotNone(vdu_server)
flavor_id = server.flavor["id"]
nova_flavors = self.novaclient().flavors
flavor = nova_flavors.get(flavor_id)
self.assertIsNotNone(flavor)
self.assertEqual(True, "VDU1_flavor_func_flavor" in flavor.name)
# Delete vnf_instance with vnf_id
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, "vnf Delete failed"
# Delete vnfd_instance
self.addCleanup(self.client.delete_vnfd, vnfd_id)
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
self.assertRaises(exceptions.NotFound, nova_flavors.delete,
[flavor_id])
开发者ID:Urban123,项目名称:tacker,代码行数:52,代码来源:test_tosca_vnf.py
示例20: test_create_delete_vnf_monitoring
def test_create_delete_vnf_monitoring(self):
data = dict()
data['tosca'] = read_file(
'sample_vnfd_no_param_monitoring_respawn.yaml')
toscal = data['tosca']
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
#Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
self.assertIsNotNone(vnfd_instance)
##Create vnf with vnfd_id
vnfd_id = vnfd_instance['vnfd']['id']
vnf_name = 'test_vnf_with_user_data_respawn'
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
vnf_instance = self.client.create_vnf(body = vnf_arg)
self.assertIsNotNone(vnf_instance)
self.assertIsNotNone(vnf_instance['vnf']['id'])
self.assertIsNotNone(vnf_instance['vnf']['instance_id'])
self.assertEqual(vnf_instance['vnf']['vnfd_id'], vnfd_instance[
'vnfd']['id'])
##Verify vnf is in ACTIVE state, then DEAD state and back ACTIVE again
vnf_id = vnf_instance['vnf']['id']
vnf_current_status = self.wait_until_vnf_active(vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual(vnf_current_status, 'ACTIVE')
vnf_current_status = self.wait_until_vnf_dead(vnf_id,
constants.VNF_CIRROS_DEAD_TIMEOUT,
constants.DEAD_SLEEP_TIME)
self.assertEqual(vnf_current_status, 'DEAD')
vnf_current_status = self.wait_until_vnf_active(vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual(vnf_current_status, 'ACTIVE')
##Delete vnf_instance with vnf_id
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, "vnf Delete failed after the monitor test"
##Delete vnfd_instance
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete failed after the monitor test"
开发者ID:chrisopal,项目名称:tacker,代码行数:52,代码来源:test_vnf_monitoring.py
注:本文中的tacker.tests.utils.read_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论