def _upgrade_config(self, st, si):
        left_vn = si.params.get('left_virtual_network', None)
        right_vn = si.params.get('right_virtual_network', None)
        mgmt_vn = si.params.get('management_virtual_network', None)

        st_if_list = st.params.get('interface_type', [])
        itf_list = []
        for index in range(0, len(st_if_list)):
            st_if_type = st_if_list[index]['service_interface_type']
            if st_if_type == svc_info.get_left_if_str():
                itf = ServiceInstanceInterfaceType(virtual_network=left_vn)
            elif st_if_type == svc_info.get_right_if_str():
                itf = ServiceInstanceInterfaceType(virtual_network=right_vn)
            elif st_if_type == svc_info.get_management_if_str():
                itf = ServiceInstanceInterfaceType(virtual_network=mgmt_vn)
            itf_list.append(itf)

        si_obj = ServiceInstance()
        si_obj.uuid = si.uuid
        si_obj.fq_name = si.fq_name
        si_props = ServiceInstanceType(**si.params)
        si_props.set_interface_list(itf_list)
        si_obj.set_service_instance_properties(si_props)
        self._vnc_lib.service_instance_update(si_obj)
        self.logger.log_notice("SI %s config upgraded for interfaces" %
                (si_obj.get_fq_name_str()))
示例#2
0
    def _upgrade_config(self, st, si):
        left_vn = si.params.get('left_virtual_network', None)
        right_vn = si.params.get('right_virtual_network', None)
        mgmt_vn = si.params.get('management_virtual_network', None)
        other0_vn = si.params.get('other0_virtual_network', None)

        st_if_list = st.params.get('interface_type', [])
        itf_list = []
        for index in range(0, len(st_if_list)):
            st_if_type = st_if_list[index]['service_interface_type']
            if st_if_type == svc_info.get_left_if_str():
                itf = ServiceInstanceInterfaceType(virtual_network=left_vn)
            elif st_if_type == svc_info.get_right_if_str():
                itf = ServiceInstanceInterfaceType(virtual_network=right_vn)
            elif st_if_type == svc_info.get_management_if_str():
                itf = ServiceInstanceInterfaceType(virtual_network=mgmt_vn)
            elif st_if_type == svc_info.get_other0_if_str():
                itf = ServiceInstanceInterfaceType(virtual_network=other0_vn)
            itf_list.append(itf)

        si_obj = ServiceInstance()
        si_obj.uuid = si.uuid
        si_obj.fq_name = si.fq_name
        si_props = ServiceInstanceType(**si.params)
        si_props.set_interface_list(itf_list)
        si_obj.set_service_instance_properties(si_props)
        self._vnc_lib.service_instance_update(si_obj)
        self.logger.notice("SI %s config upgraded for interfaces" %
                           (si_obj.get_fq_name_str()))
示例#3
0
    def _sandesh_populate_vn_info(self, si_info, sandesh_si):
        for if_str in svc_info.get_if_str_list():
            if_set = set()
            if_str_vn = if_str + '-vn'
            if not if_str_vn in si_info.keys():
                continue

            vn_fq_str = str(si_info[if_str_vn])
            vn_uuid = str(si_info[vn_fq_str])
            vn_str = ("VN [%s : %s]" % (vn_fq_str, vn_uuid))
            if_set.add(vn_str)

            iip_uuid_str = if_str + '-iip-uuid'
            if iip_uuid_str in si_info.keys():
                vn_iip_uuid = str(si_info[iip_uuid_str])
                iip_addr_str = if_str + '-iip-addr'
                vn_iip_addr = str(si_info[iip_addr_str])
                iip_str = ("IIP [%s : %s]" % (vn_iip_addr, vn_iip_uuid))
                if_set.add(iip_str)

            if if_str == svc_info.get_left_if_str():
                sandesh_si.left_vn = list(if_set)
            if if_str == svc_info.get_right_if_str():
                sandesh_si.right_vn = list(if_set)
            if if_str == svc_info.get_management_if_str():
                sandesh_si.management_vn = list(if_set)

            si_info['done'] = True
    def sandesh_si_handle_request(self, req):
        si_resp = sandesh.ServiceInstanceListResp(si_names=[])
        for si in ServiceInstanceSM.values():
            if req.si_name and req.si_name != si.name:
                continue

            st = ServiceTemplateSM.get(si.service_template)
            sandesh_si = sandesh.ServiceInstance(
                name=(':').join(si.fq_name),
                si_type=st.virtualization_type,
                si_state=si.state)

            sandesh_vm_list = []
            for vm_id in si.virtual_machines:
                vm = VirtualMachineSM.get(vm_id)
                if not vm:
                    continue
                vm_str = ("%s: %s" % (vm.name, vm.uuid))

                vr_name = 'None'
                vr = VirtualRouterSM.get(vm.virtual_router)
                if vr:
                    vr_name = vr.name

                ha_str = "active"
                if vm.index < len(si.local_preference):
                    if vm.index >= 0:
                        ha = si.local_preference[vm.index]
                        if ha and int(ha) == svc_info.get_standby_preference():
                            ha_str = "standby"
                        if ha:
                            ha_str = ha_str + ': ' + str(ha)
                    else:
                        ha_str = "unknown"

                vm = sandesh.ServiceInstanceVM(name=vm_str,
                                               vr_name=vr_name,
                                               ha=ha_str)
                sandesh_vm_list.append(vm)
            sandesh_si.vm_list = list(sandesh_vm_list)

            for nic in si.vn_info:
                vn = VirtualNetworkSM.get(nic['net-id'])
                if not vn:
                    continue
                if nic['type'] == svc_info.get_left_if_str():
                    sandesh_si.left_vn = [vn.name, vn.uuid]
                if nic['type'] == svc_info.get_right_if_str():
                    sandesh_si.right_vn = [vn.name, vn.uuid]
                if nic['type'] == svc_info.get_management_if_str():
                    sandesh_si.management_vn = [vn.name, vn.uuid]

            si_resp.si_names.append(sandesh_si)

        si_resp.response(req.context())
示例#5
0
    def sandesh_si_handle_request(self, req):
        si_resp = sandesh.ServiceInstanceListResp(si_names=[])
        for si in ServiceInstanceSM.values():
            if req.si_name and req.si_name != si.name:
                continue

            st = ServiceTemplateSM.get(si.service_template)
            sandesh_si = sandesh.ServiceInstance(
                name=(':').join(si.fq_name), si_type=st.virtualization_type,
                si_state=si.state)

            sandesh_vm_list = []
            for vm_id in si.virtual_machines:
                vm = VirtualMachineSM.get(vm_id)
                if not vm:
                    continue
                vm_str = ("%s: %s" % (vm.name, vm.uuid))

                vr_name = 'None'
                vr = VirtualRouterSM.get(vm.virtual_router)
                if vr:
                    vr_name = vr.name

                ha_str = "active"
                if vm.index < len(si.local_preference):
                    if vm.index >= 0:
                        ha = si.local_preference[vm.index]
                        if ha and int(ha) == svc_info.get_standby_preference():
                            ha_str = "standby"
                        if ha:
                            ha_str = ha_str + ': ' + str(ha)
                    else:
                        ha_str = "unknown"

                vm = sandesh.ServiceInstanceVM(
                        name=vm_str, vr_name=vr_name, ha=ha_str)
                sandesh_vm_list.append(vm)
            sandesh_si.vm_list = list(sandesh_vm_list)

            for nic in si.vn_info:
                vn = VirtualNetworkSM.get(nic['net-id'])
                if not vn:
                    continue
                if nic['type'] == svc_info.get_left_if_str():
                    sandesh_si.left_vn = [vn.name, vn.uuid]
                if nic['type'] == svc_info.get_right_if_str():
                    sandesh_si.right_vn = [vn.name, vn.uuid]
                if nic['type'] == svc_info.get_management_if_str():
                    sandesh_si.management_vn = [vn.name, vn.uuid]

            si_resp.si_names.append(sandesh_si)

        si_resp.response(req.context())
示例#6
0
    def sandesh_si_handle_request(self, req):
        si_resp = sandesh.ServiceInstanceListResp(si_names=[])
        if req.si_name is None:
            si_list = self._db.service_instance_list()

            for si_fq_name_str, si in si_list or []:
                sandesh_si = sandesh.ServiceInstance(
                    name=si_fq_name_str,
                    si_type=si.get('instance_type', ''),
                    si_state=si.get('state', ''))

                sandesh_vm_list = []
                for idx in range(0, int(si.get('max-instances', '0'))):
                    prefix = self._db.get_vm_db_prefix(idx)
                    if not (prefix + 'name') in si.keys():
                        continue
                    vm_name = si.get(prefix + 'name', '')
                    vm_uuid = si.get(prefix + 'uuid', '')
                    vm_str = ("%s: %s" % (vm_name, vm_uuid))
                    vr_name = si.get(prefix + 'vrouter', '')
                    ha = si.get(prefix + 'preference', '')
                    if int(ha) == svc_info.get_standby_preference():
                        ha_str = ("standby: %s" % (ha))
                    else:
                        ha_str = ("active: %s" % (ha))
                    vm = sandesh.ServiceInstanceVM(name=vm_str,
                                                   vr_name=vr_name,
                                                   ha=ha_str)
                    sandesh_vm_list.append(vm)
                sandesh_si.vm_list = list(sandesh_vm_list)

                for itf_type in svc_info.get_if_str_list():
                    key = itf_type + '-vn'
                    if key not in si.keys():
                        continue
                    vn_name = si[key]
                    vn_uuid = si[vn_name]
                    if itf_type == svc_info.get_left_if_str():
                        sandesh_si.left_vn = [vn_name, vn_uuid]
                    if itf_type == svc_info.get_right_if_str():
                        sandesh_si.right_vn = [vn_name, vn_uuid]
                    if itf_type == svc_info.get_management_if_str():
                        sandesh_si.management_vn = [vn_name, vn_uuid]

                si_resp.si_names.append(sandesh_si)

        si_resp.response(req.context())
示例#7
0
    def sandesh_si_handle_request(self, req):
        si_resp = sandesh.ServiceInstanceListResp(si_names=[])
        if req.si_name is None:
            si_list = self._db.service_instance_list()

            for si_fq_name_str, si in si_list or []:
                sandesh_si = sandesh.ServiceInstance(
                    name=si_fq_name_str, si_type=si.get('instance_type', ''),
                    si_state=si.get('state', ''))

                sandesh_vm_list = []
                for idx in range(0, int(si.get('max-instances', '0'))):
                    prefix = self._db.get_vm_db_prefix(idx)
                    if not (prefix + 'name') in si.keys():
                        continue
                    vm_name = si.get(prefix + 'name', '')
                    vm_uuid = si.get(prefix + 'uuid', '')
                    vm_str = ("%s: %s" % (vm_name, vm_uuid))
                    vr_name = si.get(prefix + 'vrouter', '')
                    ha = si.get(prefix + 'preference', '')
                    if int(ha) == svc_info.get_standby_preference():
                        ha_str = ("standby: %s" % (ha))
                    else:
                        ha_str = ("active: %s" % (ha))
                    vm = sandesh.ServiceInstanceVM(name=vm_str,
                        vr_name=vr_name, ha=ha_str)
                    sandesh_vm_list.append(vm)
                sandesh_si.vm_list = list(sandesh_vm_list)

                for itf_type in svc_info.get_if_str_list():
                    key = itf_type + '-vn'
                    if key not in si.keys():
                        continue
                    vn_name = si[key]
                    vn_uuid = si[vn_name]
                    if itf_type == svc_info.get_left_if_str():
                        sandesh_si.left_vn = [vn_name, vn_uuid]
                    if itf_type == svc_info.get_right_if_str():
                        sandesh_si.right_vn = [vn_name, vn_uuid]
                    if itf_type == svc_info.get_management_if_str():
                        sandesh_si.management_vn = [vn_name, vn_uuid]

                si_resp.si_names.append(sandesh_si)

        si_resp.response(req.context())