Esempio n. 1
0
    def do_create_flavor(self, account, flavor):
        """Create new flavor.
           AWS has fixed set of AWS types and so we map flavor to existing instance type
           and create local flavor for the same.

        Arguments:
            account - a cloud account
            flavor - flavor of the VM

        Returns:
            flavor id (with EC2 instance type included in id)
        """
        drv = self._get_driver(account)
        inst_type = drv.map_flavor_to_instance_type(name      = flavor.name,
			         ram       = flavor.vm_flavor.memory_mb,
			         vcpus     = flavor.vm_flavor.vcpu_count,
			         disk      = flavor.vm_flavor.storage_gb)

        new_flavor = RwcalYang.FlavorInfoItem()
        new_flavor.name = flavor.name
        new_flavor.vm_flavor.memory_mb = flavor.vm_flavor.memory_mb
        new_flavor.vm_flavor.vcpu_count = flavor.vm_flavor.vcpu_count
        new_flavor.vm_flavor.storage_gb = flavor.vm_flavor.storage_gb
        new_flavor.id = inst_type + '-' + str(RwcalAWSPlugin.flavor_id)
        RwcalAWSPlugin.flavor_id = RwcalAWSPlugin.flavor_id+1
        self._flavor_list.append(new_flavor)
        return new_flavor.id
Esempio n. 2
0
 def _get_flavor_info_request(self):
     """
     Returns request object of type RwcalYang.FlavorInfoItem()
     """
     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.storage_gb = 40  # 40GB
     flavor.guest_epa.mempage_size = OpenStackTest.MemoryPageSize
     flavor.guest_epa.cpu_pinning_policy = OpenStackTest.CpuPolicy
     flavor.guest_epa.cpu_thread_pinning_policy = OpenStackTest.CpuThreadPolicy
     flavor.guest_epa.numa_node_policy.node_cnt = OpenStackTest.NumaNodeCount
     for i in range(OpenStackTest.NumaNodeCount):
         node = flavor.guest_epa.numa_node_policy.node.add()
         node.id = i
         if i == 0:
             node.vcpu = [0, 1]
         elif i == 1:
             node.vcpu = [2, 3]
         node.memory_mb = 8196
     dev = flavor.guest_epa.pcie_device.add()
     dev.device_id = OpenStackTest.PCIPassThroughAlias
     dev.count = 1
     return flavor
Esempio n. 3
0
 def do_get_flavor_list(self, account):
     """
     Return a list of flavors
     """
     vim_resources = RwcalYang.VimResources()
     for flavor in self.cal.flavors.values():
         f = RwcalYang.FlavorInfoItem()
         f.copy_from(flavor)
         vim_resources.flavorinfo_list.append(f)
     logger.debug("Returning list of flavor-info of size: %d",
                  len(vim_resources.flavorinfo_list))
     return vim_resources
Esempio n. 4
0
    def create_flavor(self):
        """
        Create Flavor suitable for rift_ping_pong VNF
        """
        flavor = RwcalYang.FlavorInfoItem()
        flavor.name = FLAVOR_NAME
        flavor.vm_flavor.memory_mb = 16384  # 16GB
        flavor.vm_flavor.vcpu_count = 4
        flavor.vm_flavor.storage_gb = 20  # 20 GB

        logger.info("Creating new flavor. Flavor Info: %s" %
                    str(flavor.vm_flavor))

        rc, flavor_id = self._cal.create_flavor(self._acct, flavor)
        assert rc == RwStatus.SUCCESS
        logger.info("Creating new flavor.......[Done]")
        return flavor_id
Esempio n. 5
0
def flavor_subcommand(driver, account, cmdargs):
    """Process the flavor subcommand"""
    if cmdargs.which == 'list':
        rc, sizes = driver.get_flavor_list(account)
        assert rc == RwStatus.SUCCESS
        for f in sizes.flavorinfo_list:
            rc, flv = driver.get_flavor(account, f.id)
            print(flv)
    elif cmdargs.which == 'create':
        account.openstack.key = 'admin'
        flavor = RwcalYang.FlavorInfoItem()
        flavor.name = cmdargs.flavor_name
        flavor.vm_flavor.memory_mb = cmdargs.memory_size
        flavor.vm_flavor.vcpu_count = cmdargs.vcpu_count
        flavor.vm_flavor.storage_gb = cmdargs.disc_size
        if cmdargs.hugepages_kilo:
            flavor.guest_epa.mempage_size = cmdargs.hugepages_kilo
        if cmdargs.numa_nodes:
            flavor.guest_epa.numa_node_policy.node_cnt = cmdargs.numa_nodes
        if cmdargs.dedicated_cpu:
            flavor.guest_epa.cpu_pinning_policy = 'DEDICATED'
        if cmdargs.pci_count:
            dev = flavor.guest_epa.pcie_device.add()
            dev.device_id = 'PCI_%dG_ALIAS' % (cmdargs.pci_speed)
            dev.count = cmdargs.pci_count
        if cmdargs.colleto:
            dev = flavor.guest_epa.pcie_device.add()
            dev.device_id = 'COLETO_VF_ALIAS'
            dev.count = cmdargs.colleto
        if cmdargs.trusted_host:
            flavor.guest_epa.trusted_execution = True

        rc, flavor_id = driver.create_flavor(account, flavor)
        assert rc == RwStatus.SUCCESS

        print("created flavor %s id %s" % (cmdargs.flavor_name, flavor_id))

    elif cmdargs.which == 'delete':
        account.openstack.key = 'admin'
        rc, sizes = driver.get_flavor_list(account)
        assert rc == RwStatus.SUCCESS
        for f in sizes.flavorinfo_list:
            if f.name == cmdargs.flavor_name:
                rc = driver.delete_flavor(account, f.id)
                assert rc == RwStatus.SUCCESS
Esempio n. 6
0
    def _fill_flavor_info(flavor_info):
        """Create a GI object from flavor info dictionary

        Converts Flavor information dictionary object returned by openstack
        driver into Protobuf Gi Object

        Arguments:
            flavor_info: Flavor information from openstack

        Returns:
             Object of class FlavorInfoItem
        """
        flavor = RwcalYang.FlavorInfoItem()
        flavor.name                       = flavor_info.name
        flavor.id                         = flavor_info.id
        flavor.vm_flavor.memory_mb = flavor_info.vm_flavor.memory_mb
        flavor.vm_flavor.vcpu_count = flavor_info.vm_flavor.vcpu_count
        flavor.vm_flavor.storage_gb = flavor_info.vm_flavor.storage_gb
        return flavor
Esempio n. 7
0
    def create_default_resources(self, account):
        """
        Create default resources
        """
        link_list = []
        ### Add virtual links
        #for i in range(1):
        #    vlink = RwcalYang.VirtualLinkReqParams()
        #    vlink.name = 'link-'+str(i)
        #    vlink.subnet = '10.0.0.0/24'
        #    rs, vlink_id = self.do_create_virtual_link(account, vlink)
        #    assert vlink_id != ''
        #    logger.debug("Creating static virtual-link with name: %s", vlink.name)
        #    link_list.append(vlink_id)

        #### Add VDUs
        #for i in range(8):
        #    vdu = RwcalYang.VDUInitParams()
        #    vdu.name = 'vdu-'+str(i)
        #    vdu.node_id = str(i)
        #    vdu.image_id = self.get_uuid('image-'+str(i))
        #    vdu.flavor_id = self.get_uuid('flavor'+str(i))
        #    vdu.vm_flavor.vcpu_count = 4
        #    vdu.vm_flavor.memory_mb = 4096*2
        #    vdu.vm_flavor.storage_gb = 40
        #    for j in range(2):
        #        c = vdu.connection_points.add()
        #        c.name = vdu.name+'-port-'+str(j)
        #        c.virtual_link_id = link_list[j]
        #    rs, vdu_id = self.do_create_vdu(account, vdu)
        #    assert vdu_id != ''
        #    logger.debug("Creating static VDU with name: %s", vdu.name)

        for i in range(2):
            flavor = RwcalYang.FlavorInfoItem()
            flavor.name = 'flavor-' + str(i)
            flavor.vm_flavor.vcpu_count = 4
            flavor.vm_flavor.memory_mb = 4096 * 2
            flavor.vm_flavor.storage_gb = 40
            rc, flavor_id = self.do_create_flavor(account, flavor)

        for i in range(2):
            image = RwcalYang.ImageInfoItem()
            image.name = "rwimage"
            image.id = self.get_uuid('image-' + str(i))
            image.checksum = self.get_uuid('rwimage' + str(i))
            image.location = "/dev/null"
            rc, image_id = self.do_create_image(account, image)

        image = RwcalYang.ImageInfoItem()
        image.name = "Fedora-x86_64-20-20131211.1-sda.qcow2"
        image.id = self.get_uuid(image.name)
        image.checksum = self.get_uuid(image.name)
        image.location = "/dev/null"
        rc, image_id = self.do_create_image(account, image)

        image = RwcalYang.ImageInfoItem()
        image.name = "Fedora-x86_64-20-20131211.1-sda-ping.qcow2"
        image.id = self.get_uuid(image.name)
        image.checksum = self.get_uuid(image.name)
        image.location = "/dev/null"
        rc, image_id = self.do_create_image(account, image)

        image = RwcalYang.ImageInfoItem()
        image.name = "Fedora-x86_64-20-20131211.1-sda-pong.qcow2"
        image.id = self.get_uuid(image.name)
        image.checksum = self.get_uuid(image.name)
        image.location = "/dev/null"
        rc, image_id = self.do_create_image(account, image)