-#
+#
# Copyright 2016 RIFT.IO Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
logger = logging.getLogger('rwcal-openstack')
#
-# Important information about openstack installation. This needs to be manually verified
+# Important information about openstack installation. This needs to be manually verified
#
openstack_info = {
'username' : 'pluto',
logger.error("ERROR:Cal plugin instantiation failed. Aborting tests")
else:
logger.info("Openstack Cal plugin successfully instantiated")
- return cal
+ return cal
class OpenStackTest(unittest.TestCase):
HostTrust = "trusted"
PCIPassThroughAlias = "PCI_10G_ALIAS"
SEG_ID = openstack_info['segmentation_id']
-
+
def setUp(self):
"""
Assumption:
logger.info("Openstack-CAL-Test: setUp")
self.cal = get_cal_plugin()
logger.info("Openstack-CAL-Test: setUpEND")
-
+
# First check for VM Flavor and Image and get the corresponding IDs
rc, rs = self.cal.get_flavor_list(self._acct)
self.assertEqual(rc, RwStatus.SUCCESS)
networks = [ network for network in rs.networkinfo_list if (network.network_name == 'rift.cal.unittest.network' or network.network_name == 'rift.cal.virtual_link') ]
for network in networks:
self.cal.delete_virtual_link(self._acct, network.network_id)
-
+
def tearDown(self):
logger.info("Openstack-CAL-Test: tearDown")
-
+
def _md5(fname, blksize=1048576):
hash_md5 = hashlib.md5()
hash_md5.update(chunk)
return hash_md5.hexdigest()
- @unittest.skip("Skipping test_list_flavors")
+ @unittest.skip("Skipping test_list_flavors")
def test_list_flavor(self):
"""
List existing flavors from openstack installation
rc, flv = self.cal.get_flavor(self._acct, flavor.id)
self.assertEqual(rc, RwStatus.SUCCESS)
self.assertEqual(flavor.id, flv.id)
-
- @unittest.skip("Skipping test_list_images")
+
+ @unittest.skip("Skipping test_list_images")
def test_list_images(self):
"""
List existing images from openstack installation
# rc, img = self.cal.get_image(self._acct, image.id)
# self.assertEqual(rc, RwStatus.SUCCESS)
# self.assertEqual(image.id, img.id)
-
- @unittest.skip("Skipping test_list_vms")
+
+ @unittest.skip("Skipping test_list_vms")
def test_list_vms(self):
"""
List existing VMs from openstack installation
for vm in rsp.vminfo_list:
rc, server = self.cal.get_vm(self._acct, vm.vm_id)
self.assertEqual(vm.vm_id, server.vm_id)
-
- @unittest.skip("Skipping test_list_networks")
+
+ @unittest.skip("Skipping test_list_networks")
def test_list_networks(self):
"""
List existing Network from openstack installation
for network in rsp.networkinfo_list:
rc, net = self.cal.get_network(self._acct, network.network_id)
self.assertEqual(network.network_id, net.network_id)
-
- @unittest.skip("Skipping test_list_ports")
+
+ @unittest.skip("Skipping test_list_ports")
def test_list_ports(self):
"""
List existing Ports from openstack installation
else:
time.sleep(2) # Sleep for a second
return rs
-
- @unittest.skip("Skipping test_create_delete_image")
+
+ @unittest.skip("Skipping test_create_delete_image")
def test_create_delete_image(self):
"""
Create/Query/Delete a new image in openstack installation
flavor = RwcalYang.FlavorInfoItem()
flavor.name = 'rift.cal.unittest.flavor'
flavor.vm_flavor.memory_mb = 16384 # 16GB
- flavor.vm_flavor.vcpu_count = 4
+ flavor.vm_flavor.vcpu_count = 4
flavor.vm_flavor.storage_gb = 40 # 40GB
flavor.guest_epa.mempage_size = OpenStackTest.MemoryPageSize
flavor.guest_epa.cpu_pinning_policy = OpenStackTest.CpuPolicy
node = flavor.guest_epa.numa_node_policy.node.add()
node.id = i
if i == 0:
- node.vcpu = [0,1]
+ vcpu = node.vcpu.add()
+ vcpu.id = 0
+ vcpu = node.vcpu.add()
+ vcpu.id = 1
elif i == 1:
- node.vcpu = [2,3]
+ vcpu = node.vcpu.add()
+ vcpu.id = 2
+ vcpu = node.vcpu.add()
+ vcpu.id = 3
node.memory_mb = 8196
dev = flavor.guest_epa.pcie_device.add()
dev.device_id = OpenStackTest.PCIPassThroughAlias
dev.count = 1
return flavor
-
- @unittest.skip("Skipping test_create_delete_flavor")
+
+ @unittest.skip("Skipping test_create_delete_flavor")
def test_create_delete_flavor(self):
"""
Create/Query/Delete a new flavor in openstack installation
if flavor_list:
rc = self.cal.delete_flavor(self._acct, flavor_list[0].id)
self.assertEqual(rc, RwStatus.SUCCESS)
-
+
flavor = self._get_flavor_info_request()
rc, flavor_id = self.cal.create_flavor(self._acct, flavor)
self.assertEqual(rc, RwStatus.SUCCESS)
-
+
logger.info("Openstack-CAL-Test: Created new flavor with flavor_id : %s" %(flavor_id))
rc, rs = self.cal.get_flavor(self._acct, flavor_id)
self.assertEqual(rc, RwStatus.SUCCESS)
def _check_vm_state(self, vm_id, expected_state):
"""
- Wait until VM reaches particular state (expected_state).
+ Wait until VM reaches particular state (expected_state).
"""
# Wait while VM goes to required state
if port_list:
for port_id in port_list:
port = vm.port_list.add()
- port.port_id = port_id
+ port.port_id = port_id
rc, vm_id = self.cal.create_vm(self._acct, vm)
self.assertEqual(rc, RwStatus.SUCCESS)
vm_list = [vm for vm in rs.vminfo_list if vm.vm_id == vm_id]
if not len(vm_list):
break
-
+
rc, rs = self.cal.get_vm_list(self._acct)
self.assertEqual(rc, RwStatus.SUCCESS)
vm_list = [vm for vm in rs.vminfo_list if vm.vm_id == vm_id]
self.assertEqual(rc, RwStatus.SUCCESS)
### Ensure that VM state is SHUTOFF
self._check_vm_state(vm_id, 'SHUTOFF')
-
-
+
+
def _start_vm(self, vm_id):
"""
Starts VM and performs validity checks
### Ensure that VM state is ACTIVE
self._check_vm_state(vm_id, 'ACTIVE')
-
+
def _reboot_vm(self, vm_id):
"""
Reboot VM and perform validity checks
logger.info("Openstack-CAL-Test: Starting VM(EPA) create/delete test")
flavor = self._get_flavor_info_request()
-
+
rc, flavor_id = self.cal.do_create_flavor(self._acct, flavor)
self.assertEqual(rc, RwStatus.SUCCESS)
flavor.id = flavor_id
flavors = nova.flavor_list()
self.assertTrue(len(flavors) > 1)
- @unittest.skip("Skipping test_vm_operations")
+ @unittest.skip("Skipping test_vm_operations")
def test_vm_operations(self):
"""
Primary goal: Create/Query/Delete VM in openstack installation.
### Delete the VM
self._delete_vm(vm_id)
-
+
def _get_network_info_request(self):
"""
Returns request object of type RwcalYang.NetworkInfoItem
logger.info("Openstack-CAL-Test: Deleting a network with id : %s. " %(net_id))
rc = self.cal.delete_network(self._acct, net_id)
self.assertEqual(rc, RwStatus.SUCCESS)
-
+
# Verify that network is no longer available via get_network_list API
rc, rs = self.cal.get_network_list(self._acct)
self.assertEqual(rc, RwStatus.SUCCESS)
network_info = [ network for network in rs.networkinfo_list if network.network_id == net_id ]
self.assertEqual(len(network_info), 0)
logger.info("Openstack-CAL-Test: Successfully deleted Network with id : %s" %(net_id))
-
-
- @unittest.skip("Skipping test_network_operations")
+
+
+ @unittest.skip("Skipping test_network_operations")
def test_network_operations(self):
"""
Create/Delete Networks
### Delete Port
self.cal.delete_port(self._acct, port_id)
-
+
rc, rs = self.cal.get_port_list(self._acct)
self.assertEqual(rc, RwStatus.SUCCESS)
port_list = [ port for port in rs.portinfo_list if port.port_id == port_id ]
self.assertEqual(rc, RwStatus.SUCCESS)
self.assertEqual(rs.port_state, expected_state)
logger.info("Openstack-CAL-Test: Port with port_id : %s reached expected state : %s" %(port_id, rs.port_state))
-
+
@unittest.skip("Skipping test_port_operations_with_vm")
def test_port_operations_with_vm(self):
"""
### Delete VM
self._delete_vm(vm_id)
-
+
### Delete Port
self._delete_port(port_id)
### Delete VM
self._delete_vm(vm_id)
-
+
### Delete Port
self._delete_port(port_id)
vlink.provider_network.segmentation_id = OpenStackTest.SEG_ID
OpenStackTest.SEG_ID += 1
return vlink
-
+
def _get_vdu_request_info(self, virtual_link_id):
"""
Returns object of type RwcalYang.VDUInitParams
c1 = vdu.connection_points_add.add()
c1.name = "c_modify1"
c1.virtual_link_id = virtual_link_id
-
- return vdu
-
+
+ return vdu
+
#@unittest.skip("Skipping test_create_delete_virtual_link_and_vdu")
def test_create_delete_virtual_link_and_vdu(self):
"""
self.assertEqual(rc, RwStatus.SUCCESS)
logger.info("Openstack-CAL-Test: Created virtual_link with Id: %s" %rsp)
vlink_id = rsp
-
+
#Check if virtual_link create is successful
rc, rsp = self.cal.get_virtual_link(self._acct, rsp)
self.assertEqual(rc, RwStatus.SUCCESS)
self.assertEqual(rs.state, 'active')
logger.info("Openstack-CAL-Test: VDU with id : %s reached expected state : %s" %(vdu_id, rs.state))
logger.info("Openstack-CAL-Test: VDUInfo: %s" %(rs))
-
+
vlink_req = self._get_virtual_link_request_info()
### Create another virtual_link
-#
+#
# Copyright 2016 RIFT.IO Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
self._vlr_id = str(uuid.uuid4())
self._state = VlRecordState.INIT
self._prev_state = None
-
+
@property
def xpath(self):
""" path for this object """
@asyncio.coroutine
def _create_vls(self, vld, cloud_account,om_datacenter):
"""Create a VLR in the cloud account specified using the given VLD
-
+
Args:
vld : VLD yang obj
cloud_account : Cloud account name
-
+
Returns:
VirtualLinkRecord
"""
rpc_op = NsrYang.YangOutput_Nsr_StartNetworkService.from_dict({
"nsr_id":str(uuid.uuid4())
})
-
+
if not ('name' in rpc_ip and 'nsd_ref' in rpc_ip and ('cloud_account' in rpc_ip or 'om_datacenter' in rpc_ip)):
self._log.error("Mandatory parameters name or nsd_ref or cloud account not found in start-network-service {}".format(rpc_ip))
-
+
self._log.debug("start-network-service RPC input: {}".format(rpc_ip))
try:
# Add used value to the pool
self._log.debug("RPC output: {}".format(rpc_op))
-
+
nsd_copy = self.nsm.get_nsd(rpc_ip.nsd_ref)
#if not self._manager:
# self._manager = yield from self._connect()
-
+
self._log.debug("Configuring ns-instance-config with name %s nsd-ref: %s",
rpc_ip.name, rpc_ip.nsd_ref)
def get_nsr_key_pairs(dts_member_reg, xact):
key_pairs = {}
for instance_cfg, keyspec in dts_member_reg.get_xact_elements(xact, include_keyspec=True):
- self._log.debug("Key pair received is {} KS: {}".format(instance_cfg, keyspec))
+ self._log.debug("Key pair received is {} KS: {}".format(instance_cfg, keyspec))
xpath = keyspec.to_xpath(RwNsrYang.get_schema())
key_pairs[instance_cfg.name] = instance_cfg
- return key_pairs
+ return key_pairs
def on_apply(dts, acg, xact, action, scratch):
"""Apply the configuration"""
# msg.nsr_id_ref,
# msg.scaling_group_name_ref,
# msg.instance_id)
-
+
def nsr_update_cfg(self, nsr_id, msg):
nsr = self._nsrs[nsr_id]
nsr.nsr_cfg_msg= msg
self.create_nsd(nsd)
else:
self._log.debug("Updating NSD id = %s, nsd = %s", nsd.id, nsd)
- self._nsds[nsd.id].update(nsd)
+ self._nsds[nsd.id].update(nsd)
def delete_nsd(self, nsd_id):
""" Delete the Network service descriptor with the passed id """
""" Update the virtual network function descriptor """
self._log.debug("Update virtual network function descriptor- %s", vnfd)
- # Hack to remove duplicates from leaf-lists - to be fixed by RIFT-6511
- for ivld in vnfd.internal_vld:
- ivld.internal_connection_point_ref = list(set(ivld.internal_connection_point_ref))
if vnfd.id not in self._vnfds:
self._log.debug("No VNFD found - creating VNFD id = %s", vnfd.id)
-#
+#
# Copyright 2016 RIFT.IO Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
if (vlr.has_field('ip_profile_params')) and (vlr.ip_profile_params.has_field('security_group')):
cp_info['security_group'] = vlr.ip_profile_params.security_group
-
+
cp_list.append(cp_info)
for intf, cp, vlr in self._int_intf:
for ivld_msg in self.vnfd.msg.internal_vld:
self._log.debug("Creating internal vld:"
" %s, int_cp_ref = %s",
- ivld_msg, ivld_msg.internal_connection_point_ref
+ ivld_msg, ivld_msg.internal_connection_point
)
vlr = InternalVirtualLinkRecord(dts=self._dts,
log=self._log,
)
self._vlrs.append(vlr)
- for int_cp in ivld_msg.internal_connection_point_ref:
- if int_cp in self._vlr_by_cp:
+ for int_cp in ivld_msg.internal_connection_point:
+ if int_cp.id_ref in self._vlr_by_cp:
msg = ("Connection point %s already "
- " bound %s" % (int_cp, self._vlr_by_cp[int_cp]))
+ " bound %s" % (int_cp.id_ref, self._vlr_by_cp[int_cp.id_ref]))
raise InternalVirtualLinkRecordError(msg)
self._log.debug("Setting vlr %s to internal cp = %s",
- vlr, int_cp)
- self._vlr_by_cp[int_cp] = vlr
+ vlr, int_cp.id_ref)
+ self._vlr_by_cp[int_cp.id_ref] = vlr
@asyncio.coroutine
def instantiate_vls(self, xact, restart_mode=False):
if not vdur._state == VDURecordState.READY:
self._log.debug("VDUR state is not READY. current state is {}".format(vdur._state))
xact_info.respond_xpath(rsp_code=rwdts.XactRspCode.ACK)
- return
+ return
with self._dts.transaction() as new_xact:
resp = yield from vdur.read_resource(new_xact)
vdur_console = RwVnfrYang.YangData_RwVnfr_VnfrConsole_Vnfr_Vdur()
vdur_console = RwVnfrYang.YangData_RwVnfr_VnfrConsole_Vnfr_Vdur()
vdur_console.id = self._vdur_id
vdur_console.console_url = 'none'
-
+
xact_info.respond_xpath(rsp_code=rwdts.XactRspCode.ACK,
xpath=self.vnfr_vdu_console_xpath,
msg=vdur_console)
#raise VnfRecordError("Not supported operation %s" % action)
self._log.error("Not supported operation %s" % action)
xact_info.respond_xpath(rsp_code=rwdts.XactRspCode.ACK)
- return
-
+ return
+
self._log.debug("Registering for VNFR VDU using xpath: %s",
self.vnfr_vdu_console_xpath)
""" update the Virtual Network Function descriptor """
self._log.debug("Update virtual network function descriptor - %s", vnfd)
- # Hack to remove duplicates from leaf-lists - to be fixed by RIFT-6511
- for ivld in vnfd.internal_vld:
- ivld.internal_connection_point_ref = list(set(ivld.internal_connection_point_ref))
-
if vnfd.id not in self._vnfds:
self._log.debug("No VNFD found - creating VNFD id = %s", vnfd.id)
self.create_vnfd(vnfd)