Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CreateVNF = func(csarID string, cloudRegionID string, namespace string, kubeclient *kubernetes.Clientset) (string, map[string][]string, error) { namespacePlugin, ok := krd.LoadedPlugins["namespace"] if !ok { return "", nil, pkgerrors.New("No plugin for namespace resource found") } symGetNamespaceFunc, err := namespacePlugin.Lookup("GetResource") if err != nil { return "", nil, pkgerrors.Wrap(err, "Error fetching namespace plugin") } present, err := symGetNamespaceFunc.(func(string, *kubernetes.Clientset) (bool, error))( namespace, kubeclient) if err != nil { return "", nil, pkgerrors.Wrap(err, "Error in plugin namespace plugin") } if present == false { symGetNamespaceFunc, err := namespacePlugin.Lookup("CreateResource") if err != nil { return "", nil, pkgerrors.Wrap(err, "Error fetching namespace plugin") } err = symGetNamespaceFunc.(func(string, *kubernetes.Clientset) error)( namespace, kubeclient) if err != nil { return "", nil, pkgerrors.Wrap(err, "Error creating "+namespace+" namespace") } } var path string externalVNFID := string(uuid.NewUUID()) internalVNFID := cloudRegionID + "-" + namespace + "-" + externalVNFID csarDirPath := os.Getenv("CSAR_DIR") + "/" + csarID metadataYAMLPath := csarDirPath + "/metadata.yaml" seqFile, err := ReadMetadataFile(metadataYAMLPath) if err != nil { return "", nil, pkgerrors.Wrap(err, "Error while reading Metadata File: "+metadataYAMLPath) } resourceYAMLNameMap := make(map[string][]string) for _, resource := range seqFile.ResourceTypePathMap { for resourceName, resourceFileNames := range resource { var resourceNameList []string for _, filename := range resourceFileNames { path = csarDirPath + "/" + filename _, err = os.Stat(path) if os.IsNotExist(err) { return "", nil, pkgerrors.New("File " + path + "does not exists") } log.Println("Processing file: " + path) genericKubeData := &krd.GenericKubeResourceData{ YamlFilePath: path, Namespace: namespace, InternalVNFID: internalVNFID, } typePlugin, ok := krd.LoadedPlugins[resourceName] if !ok { return "", nil, pkgerrors.New("No plugin for resource " + resourceName + " found") } symCreateResourceFunc, err := typePlugin.Lookup("CreateResource") if err != nil { return "", nil, pkgerrors.Wrap(err, "Error fetching "+resourceName+" plugin") } internalResourceName, err := symCreateResourceFunc.(func(*krd.GenericKubeResourceData, *kubernetes.Clientset) (string, error))( genericKubeData, kubeclient) if err != nil { return "", nil, pkgerrors.Wrap(err, "Error in plugin "+resourceName+" plugin") } resourceNameList = append(resourceNameList, internalResourceName) resourceYAMLNameMap[resourceName] = resourceNameList } } } return externalVNFID, resourceYAMLNameMap, nil }
CreateVNF reads the CSAR files from the files system and creates them one by one
View Source
var DestroyVNF = func(data map[string][]string, namespace string, kubeclient *kubernetes.Clientset) error { for resourceName, resourceList := range data { typePlugin, ok := krd.LoadedPlugins[resourceName] if !ok { return pkgerrors.New("No plugin for resource " + resourceName + " found") } symDeleteResourceFunc, err := typePlugin.Lookup("DeleteResource") if err != nil { return pkgerrors.Wrap(err, "Error fetching "+resourceName+" plugin") } for _, resourceName := range resourceList { log.Println("Deleting resource: " + resourceName) err = symDeleteResourceFunc.(func(string, string, *kubernetes.Clientset) error)( resourceName, namespace, kubeclient) if err != nil { return pkgerrors.Wrap(err, "Error destroying "+resourceName) } } } return nil }
DestroyVNF deletes VNFs based on data passed
View Source
var ReadMetadataFile = func(yamlFilePath string) (MetadataFile, error) { var seqFile MetadataFile if _, err := os.Stat(yamlFilePath); err == nil { log.Println("Reading metadata YAML: " + yamlFilePath) rawBytes, err := ioutil.ReadFile(yamlFilePath) if err != nil { return seqFile, pkgerrors.Wrap(err, "Metadata YAML file read error") } err = yaml.Unmarshal(rawBytes, &seqFile) if err != nil { return seqFile, pkgerrors.Wrap(err, "Metadata YAML file read error") } } return seqFile, nil }
ReadMetadataFile reads the metadata yaml to return the order or reads
Functions ¶
This section is empty.
Types ¶
type MetadataFile ¶
MetadataFile stores the metadata of execution
Click to show internal directories.
Click to hide internal directories.