예제 #1
0
    def __init__(self, log, loop, dts, ping_pong, cloud_account_name):
        self.dts = dts
        self.log = log
        self.loop = loop
        self.ref = None

        self.nsr_config = rwnsryang.YangData_Nsr_NsInstanceConfig()

        nsr = rwnsryang.YangData_Nsr_NsInstanceConfig_Nsr()
        nsr.id = str(uuid.uuid4())
        nsr.name = "ns1.{}".format(nsr.id)
        nsr.nsd_ref = ping_pong.nsd_id
        nsr.cloud_account = cloud_account_name

        inputs = nsryang.YangData_Nsr_NsInstanceConfig_Nsr_InputParameter()
        inputs.xpath = "/nsd:nsd-catalog/nsd:nsd[nsd:id={}]/nsd:name".format(
            ping_pong.nsd_id)
        inputs.value = "inigo montoya"

        fast_cpu = {'metadata_key': 'FASTCPU', 'metadata_value': 'True'}
        self.create_nsd_placement_group_map(nsr,
                                            group_name='Orcus',
                                            cloud_type='openstack',
                                            construct_type='host_aggregate',
                                            construct_value=[fast_cpu])

        fast_storage = {'metadata_key': 'FASTSSD', 'metadata_value': 'True'}
        self.create_nsd_placement_group_map(nsr,
                                            group_name='Quaoar',
                                            cloud_type='openstack',
                                            construct_type='host_aggregate',
                                            construct_value=[fast_storage])

        fast_cpu = {'metadata_key': 'BLUE_HW', 'metadata_value': 'True'}
        self.create_vnfd_placement_group_map(nsr,
                                             group_name='Eris',
                                             vnfd_id=ping_pong.ping_vnfd_id,
                                             cloud_type='openstack',
                                             construct_type='host_aggregate',
                                             construct_value=[fast_cpu])

        fast_storage = {'metadata_key': 'YELLOW_HW', 'metadata_value': 'True'}
        self.create_vnfd_placement_group_map(nsr,
                                             group_name='Weywot',
                                             vnfd_id=ping_pong.pong_vnfd_id,
                                             cloud_type='openstack',
                                             construct_type='host_aggregate',
                                             construct_value=[fast_storage])

        nsr.input_parameter.append(inputs)

        self._nsr = nsr
        self.nsr_config.nsr.append(nsr)

        self._ready_event = asyncio.Event(loop=self.loop)
        asyncio.ensure_future(self.register(), loop=loop)
예제 #2
0
def create_nsr_from_nsd_id(nsd_id):
    nsr = RwNsrYang.YangData_Nsr_NsInstanceConfig_Nsr()
    nsr.id = str(uuid.uuid4())
    nsr.name = "nsr_name"
    nsr.short_name = "nsr_short_name"
    nsr.description = "This is a description"
    nsr.nsd_ref = nsd_id
    nsr.admin_status = "ENABLED"
    nsr.cloud_account = "cloud_account_name"

    return nsr
예제 #3
0
def create_nsr_from_nsd_id(nsd_id):
    nsr = RwNsrYang.YangData_Nsr_NsInstanceConfig_Nsr()
    nsr.id = str(uuid.uuid4())
    nsr.name = "pingpong_{}".format(datetime.datetime.now().strftime("%Y%m%d_%H%M%S"))
    nsr.short_name = "nsr_short_name"
    nsr.description = "This is a description"
    nsr.nsd_ref = nsd_id
    nsr.admin_status = "ENABLED"
    nsr.cloud_account = "openstack"

    param = NsrYang.YangData_Nsr_NsInstanceConfig_Nsr_InputParameter()
    param.xpath = '/nsd:nsd-catalog/nsd:nsd/nsd:vendor'
    param.value = "rift-o-matic"

    nsr.input_parameter.append(param)

    return nsr
예제 #4
0
def create_nsr(nsd_id, input_param_list, cloud_account_name):
    """
    Create the NSR record object

    Arguments:
         nsd_id             -  NSD id
         input_param_list - list of input-parameter objects

    Return:
         NSR object
    """
    nsr = RwNsrYang.YangData_Nsr_NsInstanceConfig_Nsr()

    nsr.id = str(uuid.uuid4())
    nsr.name = rift.auto.mano.resource_name(nsr.id)
    nsr.short_name = "nsr_short_name"
    nsr.description = "This is a description"
    nsr.nsd_ref = nsd_id
    nsr.admin_status = "ENABLED"
    nsr.input_parameter.extend(input_param_list)
    nsr.cloud_account = cloud_account_name

    return nsr