// Graph returns a current Graph. func (obj *MyGAPI) Graph() (*pgraph.Graph, error) { if !obj.initialized { return nil, fmt.Errorf("libmgmt: MyGAPI is not initialized") } n1, err := resources.NewNoopRes("noop1") if err != nil { return nil, fmt.Errorf("Can't create resource: %v", err) } // we can still build a graph via the yaml method gc := &yamlgraph.GraphConfig{ Graph: obj.Name, Resources: yamlgraph.Resources{ // must redefine anonymous struct :( // in alphabetical order Exec: []*resources.ExecRes{}, File: []*resources.FileRes{}, Msg: []*resources.MsgRes{}, Noop: []*resources.NoopRes{n1}, Pkg: []*resources.PkgRes{}, Svc: []*resources.SvcRes{}, Timer: []*resources.TimerRes{}, Virt: []*resources.VirtRes{}, }, //Collector: []collectorResConfig{}, //Edges: []Edge{}, Comment: "comment!", } g, err := gc.NewGraphFromConfig(obj.data.Hostname, obj.data.EmbdEtcd, obj.data.Noop) return g, err }
// Graph returns a current Graph. func (obj *MyGAPI) Graph() (*pgraph.Graph, error) { if !obj.initialized { return nil, fmt.Errorf("libmgmt: MyGAPI is not initialized") } g := pgraph.NewGraph(obj.Name) var vertex *pgraph.Vertex for i := uint(0); i < obj.Count; i++ { n, err := resources.NewNoopRes(fmt.Sprintf("noop%d", i)) if err != nil { return nil, fmt.Errorf("Can't create resource: %v", err) } v := pgraph.NewVertex(n) g.AddVertex(v) if i > 0 { g.AddEdge(vertex, v, pgraph.NewEdge(fmt.Sprintf("e%d", i))) } vertex = v // save } //g, err := config.NewGraphFromConfig(obj.data.Hostname, obj.data.World, obj.data.Noop) return g, nil }