Beispiel #1
0
 def create_source(self, journal, source_request, file_ops_executor):
     source_tree = AnsibleRmSourceTree()
     file_ops = []
     descriptor_content = 'description: descriptor for {0}'.format(
         source_request.source_config.name)
     file_ops.append(
         handlers_api.CreateFileOp(
             source_tree.gen_descriptor_file_path(
                 source_request.source_config.name), descriptor_content,
             handlers_api.EXISTING_IGNORE))
     file_ops.append(
         handlers_api.CreateDirectoryOp(source_tree.lifecycle_path,
                                        handlers_api.EXISTING_IGNORE))
     install_content = '---\n- name: Install\n  hosts: all\n  gather_facts: False'
     file_ops.append(
         handlers_api.CreateFileOp(
             source_tree.gen_lifecycle_file('Install'), install_content,
             handlers_api.EXISTING_IGNORE))
     file_ops.append(
         handlers_api.CreateDirectoryOp(source_tree.meta_inf_path,
                                        handlers_api.EXISTING_IGNORE))
     manifest_content = 'resource-manager: ansible'
     file_ops.append(
         handlers_api.CreateFileOp(source_tree.meta_inf_manifest_file_path,
                                   manifest_content,
                                   handlers_api.EXISTING_IGNORE))
     file_ops.append(
         handlers_api.CreateDirectoryOp(source_tree.tests_path,
                                        handlers_api.EXISTING_IGNORE))
     file_ops_executor(file_ops)
Beispiel #2
0
    def _do_create_source(self, journal, source_request):
        source_tree = AssemblySourceTree()
        file_ops = []
        descriptor_content = 'description: descriptor for {0}'.format(
            source_request.source_config.name)
        file_ops.append(
            handlers_api.CreateFileOp(source_tree.descriptor_file_path,
                                      descriptor_content,
                                      handlers_api.EXISTING_IGNORE))
        file_ops.append(
            handlers_api.CreateDirectoryOp(source_tree.service_behaviour_path,
                                           handlers_api.EXISTING_IGNORE))
        file_ops.append(
            handlers_api.CreateDirectoryOp(
                source_tree.service_behaviour_configurations_path,
                handlers_api.EXISTING_IGNORE))
        file_ops.append(
            handlers_api.CreateDirectoryOp(
                source_tree.service_behaviour_runtime_path,
                handlers_api.EXISTING_IGNORE))
        file_ops.append(
            handlers_api.CreateDirectoryOp(
                source_tree.service_behaviour_tests_path,
                handlers_api.EXISTING_IGNORE))

        include_template = source_request.param_values.get_value(
            INCLUDE_TEMPLATE_PARAM_NAME)
        if type(include_template) == str:
            include_template = include_template in INCLUDE_TEMPLATE_YES_VALUES
        if include_template:
            file_ops.append(
                handlers_api.CreateFileOp(
                    source_tree.descriptor_template_file_path,
                    TEMPLATE_CONTENT, handlers_api.EXISTING_IGNORE))
        self._execute_file_ops(file_ops, source_request.target_path, journal)
Beispiel #3
0
 def __create_lifecycle(self, journal, source_request, file_ops, source_tree, lifecycle_type, descriptor, had_inf=False):
     file_ops.append(handlers_api.CreateDirectoryOp(source_tree.lifecycle_path, handlers_api.EXISTING_IGNORE))
     if lifecycle_type == LIFECYCLE_TYPE_KUBERNETES:
         file_ops.append(handlers_api.CreateDirectoryOp(source_tree.kubernetes_lifecycle_path, handlers_api.EXISTING_IGNORE))
         kube_tree = KubernetesLifecycleTree(source_tree.kubernetes_lifecycle_path)
         file_ops.append(handlers_api.CreateDirectoryOp(kube_tree.objects_path, handlers_api.EXISTING_IGNORE))
         file_ops.append(handlers_api.CreateDirectoryOp(kube_tree.helm_path, handlers_api.EXISTING_IGNORE))
         file_ops.append(handlers_api.CreateFileOp(kube_tree.kegd_file_path, KEGD_LIFECYCLE_TEMPLATE, handlers_api.EXISTING_IGNORE))
         if not had_inf:
             file_ops.append(handlers_api.CreateFileOp(kube_tree.gen_object_file_path('config-map'), CONFIG_MAP_TEMPLATE, handlers_api.EXISTING_IGNORE))
             descriptor.insert_lifecycle('Create')
             descriptor.insert_lifecycle('Delete')
             descriptor.infrastructure['Kubernetes'] = {}
         file_ops.append(handlers_api.CreateFileOp(kube_tree.gen_object_file_path('deployment'), DEPLOYMENT_TEMPLATE, handlers_api.EXISTING_IGNORE))
         descriptor.insert_lifecycle('Install')
         descriptor.insert_default_driver('kubernetes', infrastructure_types=['*'])
     elif lifecycle_type == LIFECYCLE_TYPE_ANSIBLE:
         file_ops.append(handlers_api.CreateDirectoryOp(source_tree.ansible_lifecycle_path, handlers_api.EXISTING_IGNORE))
         ansible_tree = AnsibleLifecycleTree(source_tree.ansible_lifecycle_path)
         file_ops.append(handlers_api.CreateDirectoryOp(ansible_tree.config_path, handlers_api.EXISTING_IGNORE))
         file_ops.append(handlers_api.CreateDirectoryOp(ansible_tree.hostvars_path, handlers_api.EXISTING_IGNORE))
         file_ops.append(handlers_api.CreateDirectoryOp(ansible_tree.scripts_path, handlers_api.EXISTING_IGNORE))
         install_content = '---\n- name: Install\n  hosts: all\n  gather_facts: False'
         file_ops.append(handlers_api.CreateFileOp(ansible_tree.gen_script_file_path('Install'), install_content, handlers_api.EXISTING_IGNORE))
         descriptor.insert_lifecycle('Install')
         inventory_content = '[example]\nexample-host'
         file_ops.append(handlers_api.CreateFileOp(ansible_tree.inventory_file_path, inventory_content, handlers_api.EXISTING_IGNORE))
         host_var_content = '---\nansible_host: {{ properties.host }}\nansible_ssh_user: {{ properties.ssh_user }}\nansible_ssh_pass: {{ properties.ssh_pass }}'
         file_ops.append(handlers_api.CreateFileOp(ansible_tree.gen_hostvars_file_path('example-host'), host_var_content, handlers_api.EXISTING_IGNORE))
         descriptor.insert_default_driver('ansible', infrastructure_types=['*'])
     elif lifecycle_type == LIFECYCLE_TYPE_SOL003:
         file_ops.append(handlers_api.CreateDirectoryOp(source_tree.sol003_lifecycle_path, handlers_api.EXISTING_IGNORE))
         sol003_tree = Sol003LifecycleTree(source_tree.sol003_lifecycle_path)
         file_ops.append(handlers_api.CreateDirectoryOp(sol003_tree.scripts_path, handlers_api.EXISTING_IGNORE))
         current_path = os.path.abspath(__file__)
         dir_path = os.path.dirname(current_path)
         sol003_scripts_template_path = os.path.join(dir_path, 'sol003', 'scripts')
         for script_name in SOL003_SCRIPT_NAMES:
             orig_script_path = os.path.join(sol003_scripts_template_path, script_name)
             with open(orig_script_path, 'r') as f:
                 content = f.read()
             file_ops.append(handlers_api.CreateFileOp(os.path.join(sol003_tree.scripts_path, script_name), content, handlers_api.EXISTING_IGNORE))
         descriptor.insert_default_driver('sol003', infrastructure_types=['*'])
         descriptor.add_property('vnfdId', description='Identifier for the VNFD to use for this VNF instance', ptype='string', required=True)
         descriptor.add_property('vnfInstanceId', description='Identifier for the VNF instance, as provided by the vnfInstanceName', ptype='string', read_only=True)
         descriptor.add_property('vnfInstanceName', description='Name for the VNF instance', ptype='string', value='${name}')
         descriptor.add_property('vnfInstanceDescription', description='Optional description for the VNF instance', ptype='string')
         descriptor.add_property('vnfPkgId', description='Identifier for the VNF package to be used for this VNF instance', ptype='string', required=True)
         descriptor.add_property('vnfProvider', description='Provider of the VNF and VNFD', ptype='string', read_only=True)
         descriptor.add_property('vnfProductName', description='VNF Product Name', ptype='string', read_only=True)
         descriptor.add_property('vnfSoftwareVersion', description='VNF Software Version', ptype='string', read_only=True)
         descriptor.add_property('vnfdVersion', description='Version of the VNFD', ptype='string', read_only=True)
         descriptor.add_property('flavourId', description='Identifier of the VNF DF to be instantiated', ptype='string', required=True)
         descriptor.add_property('instantiationLevelId', description='Identifier of the instantiation level of the deployment flavour to be instantiated. If not present, the default instantiation level as declared in the VNFD is instantiated', \
             ptype='string')
         descriptor.add_property('localizationLanguage', description='Localization language of the VNF to be instantiated', ptype='string')    
         descriptor.insert_lifecycle('Install')
         descriptor.insert_lifecycle('Configure')
         descriptor.insert_lifecycle('Uninstall')
Beispiel #4
0
 def __create_infrastructure(self, journal, source_request, file_ops, source_tree, inf_type, descriptor):
     if inf_type == INFRASTRUCTURE_TYPE_OPENSTACK:
         create_driver_entry = {
             'openstack': {
                 'selector': {
                     'infrastructure-type': [
                         '*'
                     ]
                 }
             }
         }
         descriptor.insert_lifecycle('Create', drivers=create_driver_entry)
         delete_driver_entry = {
             'openstack': {
                 'selector': {
                     'infrastructure-type': [
                         '*'
                     ]
                 }
             }
         }
         descriptor.insert_lifecycle('Delete', drivers=delete_driver_entry)
         file_ops.append(handlers_api.CreateDirectoryOp(source_tree.openstack_lifecycle_path, handlers_api.EXISTING_IGNORE))
         openstack_tree = OpenstackTree(source_tree.openstack_lifecycle_path)
         file_ops.append(handlers_api.CreateFileOp(openstack_tree.heat_file_path, OPENSTACK_EXAMPLE_HEAT, handlers_api.EXISTING_IGNORE))
         descriptor.infrastructure['Openstack'] = {}
     elif inf_type == LIFECYCLE_TYPE_KUBERNETES:
         file_ops.append(handlers_api.CreateDirectoryOp(source_tree.kubernetes_lifecycle_path, handlers_api.EXISTING_IGNORE))
         kube_tree = KubernetesLifecycleTree(source_tree.kubernetes_lifecycle_path)
         file_ops.append(handlers_api.CreateDirectoryOp(kube_tree.objects_path, handlers_api.EXISTING_IGNORE))
         file_ops.append(handlers_api.CreateDirectoryOp(kube_tree.helm_path, handlers_api.EXISTING_IGNORE))
         file_ops.append(handlers_api.CreateFileOp(kube_tree.kegd_file_path, KEGD_INF_TEMPLATE, handlers_api.EXISTING_IGNORE))
         file_ops.append(handlers_api.CreateFileOp(kube_tree.gen_object_file_path('config-map'), CONFIG_MAP_TEMPLATE, handlers_api.EXISTING_IGNORE))
         create_driver_entry = {
             'kubernetes': {
                 'selector': {
                     'infrastructure-type': [
                         '*'
                     ]
                 }
             }
         }
         descriptor.insert_lifecycle('Create', drivers=create_driver_entry)
         delete_driver_entry = {
             'kubernetes': {
                 'selector': {
                     'infrastructure-type': [
                         '*'
                     ]
                 }
             }
         }
         descriptor.insert_lifecycle('Delete', drivers=delete_driver_entry)
         descriptor.infrastructure['Kubernetes'] = {}
Beispiel #5
0
 def create_source(self, journal, source_request, file_ops_executor):
     source_tree = BrentSourceTree()
     file_ops = []
     descriptor = descriptor_utils.Descriptor({})
     descriptor.description = 'descriptor for {0}'.format(source_request.source_config.name)
     had_inf = False
     file_ops.append(handlers_api.CreateDirectoryOp(source_tree.definitions_path, handlers_api.EXISTING_IGNORE))
     driver_type = source_request.param_values.get_value(DRIVER_PARAM_NAME)
     driver_type_set_to_default = False
     if driver_type is None:
         driver_type = source_request.param_values.get_value(LIFECYCLE_PARAM_NAME)
         if driver_type is None:
             driver_type = LIFECYCLE_TYPE_ANSIBLE
             driver_type_set_to_default = True
     inf_type = source_request.param_values.get_value(INFRASTRUCTURE_PARAM_NAME)
     if inf_type is None:
         if driver_type == LIFECYCLE_TYPE_ANSIBLE and driver_type_set_to_default:
             inf_type = INFRASTRUCTURE_TYPE_OPENSTACK
     if inf_type is not None:
         had_inf = True
         self.__create_infrastructure(journal, source_request, file_ops, source_tree, inf_type, descriptor)
     
     self.__create_lifecycle(journal, source_request, file_ops, source_tree, driver_type, descriptor, had_inf=had_inf)
     self.__create_descriptor(journal, source_request, file_ops, source_tree, descriptor)
     
     file_ops_executor(file_ops)
Beispiel #6
0
 def __create_infrastructure(self, journal, source_request, file_ops, source_tree, inf_type, descriptor):
     file_ops.append(handlers_api.CreateDirectoryOp(source_tree.infrastructure_definitions_path, handlers_api.EXISTING_IGNORE))
     if inf_type == INFRASTRUCTURE_TYPE_OPENSTACK:
         descriptor.insert_lifecycle('Create')
         descriptor.insert_lifecycle('Delete')
         templates_tree = OpenstackTemplatesTree(source_tree.infrastructure_definitions_path)
         file_ops.append(handlers_api.CreateFileOp(templates_tree.gen_tosca_template('example'), OPENSTACK_EXAMPLE_TOSCA, handlers_api.EXISTING_IGNORE))
         descriptor.insert_infrastructure_template('Openstack', 'example.yaml', template_type='HEAT')
Beispiel #7
0
 def __create_descriptor(self, journal, source_request, file_ops,
                         source_tree, descriptor):
     file_ops.append(
         handlers_api.CreateDirectoryOp(source_tree.lm_definitions_path,
                                        handlers_api.EXISTING_IGNORE))
     descriptor_content = descriptor_utils.DescriptorParser().write_to_str(
         descriptor)
     file_ops.append(
         handlers_api.CreateFileOp(source_tree.descriptor_file_path,
                                   descriptor_content,
                                   handlers_api.EXISTING_IGNORE))
Beispiel #8
0
 def _do_create_source(self, journal, source_request):
     source_tree = TypeSourceTree()
     file_ops = []
     descriptor_content = 'description: descriptor for {0}'.format(
         source_request.source_config.name)
     file_ops.append(
         handlers_api.CreateFileOp(source_tree.descriptor_file_path,
                                   descriptor_content,
                                   handlers_api.EXISTING_IGNORE))
     file_ops.append(
         handlers_api.CreateDirectoryOp(source_tree.service_behaviour_path,
                                        handlers_api.EXISTING_IGNORE))
     file_ops.append(
         handlers_api.CreateDirectoryOp(
             source_tree.service_behaviour_configurations_path,
             handlers_api.EXISTING_IGNORE))
     file_ops.append(
         handlers_api.CreateDirectoryOp(
             source_tree.service_behaviour_tests_path,
             handlers_api.EXISTING_IGNORE))
     self._execute_file_ops(file_ops, source_request.target_path, journal)
Beispiel #9
0
    def create_source(self, journal, source_request, file_ops_executor):
        source_tree = BrentSourceTree()
        file_ops = []
        descriptor = descriptor_utils.Descriptor({}, is_2_dot_1=True)
        descriptor.description = 'descriptor for {0}'.format(source_request.source_config.name)

        file_ops.append(handlers_api.CreateDirectoryOp(source_tree.definitions_path, handlers_api.EXISTING_IGNORE))

        inf_type = source_request.param_values.get_value(INFRASTRUCTURE_PARAM_NAME)
        self.__create_infrastructure(journal, source_request, file_ops, source_tree, inf_type, descriptor)
        
        lifecycle_type = source_request.param_values.get_value(LIFECYCLE_PARAM_NAME)
        self.__create_lifecycle(journal, source_request, file_ops, source_tree, lifecycle_type, descriptor)
        
        self.__create_descriptor(journal, source_request, file_ops, source_tree, descriptor)
        
        file_ops_executor(file_ops)