Author: aschnell
Date: Fri Jan 16 13:54:58 2009
New Revision: 54699
URL: http://svn.opensuse.org/viewcvs/yast?rev=54699&view=rev
Log:
- backup
Added:
branches/tmp/aschnell/graph/storage/libstorage/examples/SaveGraph.cc
branches/tmp/aschnell/graph/storage/libstorage/src/Graph.cc
branches/tmp/aschnell/graph/storage/libstorage/src/Graph.h
Modified:
branches/tmp/aschnell/graph/storage/libstorage/examples/Makefile.am
branches/tmp/aschnell/graph/storage/libstorage/src/Makefile.am
branches/tmp/aschnell/graph/storage/libstorage/src/Storage.h
branches/tmp/aschnell/graph/storage/libstorage/src/StorageInterface.h
branches/tmp/aschnell/graph/storage/storage/src/include/ep-graph.ycp
branches/tmp/aschnell/graph/storage/storage/src/modules/Storage.ycp
Modified: branches/tmp/aschnell/graph/storage/libstorage/examples/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/storage/libstorage/examples/Makefile.am?rev=54699&r1=54698&r2=54699&view=diff
==============================================================================
--- branches/tmp/aschnell/graph/storage/libstorage/examples/Makefile.am (original)
+++ branches/tmp/aschnell/graph/storage/libstorage/examples/Makefile.am Fri Jan 16 13:54:58 2009
@@ -9,7 +9,8 @@
AM_CXXFLAGS =
-noinst_PROGRAMS = TestDisk TestDiskLog TestStorage TestProbing TestLvm TestMd TestLoop TestLock
+noinst_PROGRAMS = TestDisk TestDiskLog TestStorage TestProbing TestLvm \
+ TestMd TestLoop TestLock SaveGraph
TestDisk_SOURCES = TestDisk.cc
@@ -27,9 +28,12 @@
TestLock_SOURCES = TestLock.cc
+SaveGraph_SOURCES = SaveGraph.cc
+
exampledir = $(docdir)/examples/libstorage
-example_DATA = TestDisk.cc TestDiskLog.cc TestProbing.cc TestLvm.cc TestMd.cc TestLoop.cc
+example_DATA = TestDisk.cc TestDiskLog.cc TestProbing.cc TestLvm.cc TestMd.cc \
+ TestLoop.cc SaveGraph.cc
EXTRA_DIST = $(example_DATA) Makefile.example
Added: branches/tmp/aschnell/graph/storage/libstorage/examples/SaveGraph.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/storage/libstorage/examples/SaveGraph.cc?rev=54699&view=auto
==============================================================================
--- branches/tmp/aschnell/graph/storage/libstorage/examples/SaveGraph.cc (added)
+++ branches/tmp/aschnell/graph/storage/libstorage/examples/SaveGraph.cc Fri Jan 16 13:54:58 2009
@@ -0,0 +1,17 @@
+
+#include
+
+#include
+
+using namespace storage;
+
+int
+main (int argc, char** argv)
+{
+ initDefaultLogger();
+ StorageInterface* s = createStorageInterface (true, false, true);
+
+ s->saveGraph("storage.dot");
+
+ exit(EXIT_SUCCESS);
+}
Added: branches/tmp/aschnell/graph/storage/libstorage/src/Graph.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/storage/libstorage/src/Graph.cc?rev=54699&view=auto
==============================================================================
--- branches/tmp/aschnell/graph/storage/libstorage/src/Graph.cc (added)
+++ branches/tmp/aschnell/graph/storage/libstorage/src/Graph.cc Fri Jan 16 13:54:58 2009
@@ -0,0 +1,118 @@
+/*
+ Textdomain "storage"
+*/
+
+
+#include <string>
+#include <fstream>
+
+#include "y2storage/Graph.h"
+
+
+using namespace std;
+using namespace storage;
+
+
+namespace storage
+{
+ struct Node
+ {
+ Node(const string& id, const string& label)
+ : id(id), label(label)
+ {}
+
+ const string id;
+ const string label;
+ };
+
+ struct Edge
+ {
+ Edge(const string& node1, const string& node2)
+ : node1(node1), node2(node2)
+ {}
+
+ const string node1;
+ const string node2;
+ };
+
+ string dotQuote(const string& s)
+ {
+ return '"' + s + '"';
+ }
+
+ std::ostream& operator<<(std::ostream& s, const Node& node)
+ {
+ return s << dotQuote(node.id) << " [label=" << dotQuote(node.label) << "];";
+ }
+
+ std::ostream& operator<<(std::ostream& s, const Edge& edge)
+ {
+ return s << dotQuote(edge.node1) << " -> " << dotQuote(edge.node2) << ";";
+ }
+}
+
+
+int
+Storage::saveGraph(const string& filename)
+{
+ list<Node> nodes;
+ list<Edge> edges;
+
+
+ deque<ContainerInfo> containers;
+ getContainers(containers);
+ for (deque<ContainerInfo>::iterator i1 = containers.begin();
+ i1 != containers.end(); ++i1)
+ {
+ switch (i1->type)
+ {
+ case DISK: {
+
+ Node disk_node("device:" + i1->device, i1->device);
+ nodes.push_back(disk_node);
+
+ deque<PartitionInfo> partitions;
+ getPartitionInfo (i1->name, partitions);
+ for (deque<PartitionInfo>::iterator i2 = partitions.begin();
+ i2 != partitions.end(); ++i2)
+ {
+ Node partition_node("device:" + i2->v.device, i2->v.device);
+ nodes.push_back(partition_node);
+
+ edges.push_back(Edge(disk_node.id, partition_node.id));
+
+ if (!i2->v.mount.empty())
+ {
+ Node mountpoint_node("mountpoint:" + i2->v.mount, i2->v.mount);
+ nodes.push_back(mountpoint_node);
+
+ edges.push_back(Edge(partition_node.id, mountpoint_node.id));
+ }
+ }
+
+ } break;
+ }
+ }
+
+
+ ofstream out(filename.c_str());
+
+ out << "digraph storage" << endl;
+ out << "{" << endl;
+ out << " node [ shape=rectangle ];" << endl;
+ out << endl;
+
+ for (list<Node>::const_iterator node = nodes.begin(); node != nodes.end(); ++node)
+ out << " " << (*node) << endl;
+
+ out << endl;
+
+ for (list<Edge>::const_iterator edge = edges.begin(); edge != edges.end(); ++edge)
+ out << " " << (*edge) << endl;
+
+ out << "}" << endl;
+
+ out.close();
+
+ return 0;
+}
Added: branches/tmp/aschnell/graph/storage/libstorage/src/Graph.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/storage/libstorage/src/Graph.h?rev=54699&view=auto
==============================================================================
--- branches/tmp/aschnell/graph/storage/libstorage/src/Graph.h (added)
+++ branches/tmp/aschnell/graph/storage/libstorage/src/Graph.h Fri Jan 16 13:54:58 2009
@@ -0,0 +1,16 @@
+#ifndef GRAPH_H
+#define GRAPH_H
+
+
+#include "y2storage/Storage.h"
+
+
+namespace storage
+{
+
+ bool saveGraph(Storage* storage, const string& filename);
+
+}
+
+
+#endif
Modified: branches/tmp/aschnell/graph/storage/libstorage/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/storage/libstorage/src/Makefile.am?rev=54699&r1=54698&r2=54699&view=diff
==============================================================================
--- branches/tmp/aschnell/graph/storage/libstorage/src/Makefile.am (original)
+++ branches/tmp/aschnell/graph/storage/libstorage/src/Makefile.am Fri Jan 16 13:54:58 2009
@@ -46,6 +46,7 @@
Md.cc Md.h \
Loop.cc Loop.h \
Nfs.cc Nfs.h \
+ Graph.cc Graph.h \
SystemCmd.cc SystemCmd.h \
OutputProcessor.cc OutputProcessor.h \
Regex.cc Regex.h \
Modified: branches/tmp/aschnell/graph/storage/libstorage/src/Storage.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/storage/libstorage/src/Storage.h?rev=54699&r1=54698&r2=54699&view=diff
==============================================================================
--- branches/tmp/aschnell/graph/storage/libstorage/src/Storage.h (original)
+++ branches/tmp/aschnell/graph/storage/libstorage/src/Storage.h Fri Jan 16 13:54:58 2009
@@ -471,6 +471,7 @@
bool checkDmMapsTo( const string& dev );
void updateDmEmptyPeMap();
void dumpObjectList();
+ int saveGraph(const string& filename);
string byteToHumanString(unsigned long long size, bool classic, int precision, bool omit_zeroes) const;
bool humanStringToByte(const string& str, bool classic, unsigned long long& size) const;
Modified: branches/tmp/aschnell/graph/storage/libstorage/src/StorageInterface.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/storage/libstorage/src/StorageInterface.h?rev=54699&r1=54698&r2=54699&view=diff
==============================================================================
--- branches/tmp/aschnell/graph/storage/libstorage/src/StorageInterface.h (original)
+++ branches/tmp/aschnell/graph/storage/libstorage/src/StorageInterface.h Fri Jan 16 13:54:58 2009
@@ -2118,6 +2118,14 @@
virtual void dumpObjectList() = 0;
/**
+ * Saves a graph of the storage devices as DOT file for graphviz.
+ *
+ * @param filename filename of graph
+ * @return zero if all is ok, negative number to indicate an error
+ */
+ virtual int saveGraph(const string& filename) = 0;
+
+ /**
* Split volume device name up into container name and a volume
* name. For Containers where this is appropriate (e.g. disks,
* MD, loop) also a volume number is provided.
Modified: branches/tmp/aschnell/graph/storage/storage/src/include/ep-graph.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/storage/storage/src/include/ep-graph.ycp?rev=54699&r1=54698&r2=54699&view=diff
==============================================================================
--- branches/tmp/aschnell/graph/storage/storage/src/include/ep-graph.ycp (original)
+++ branches/tmp/aschnell/graph/storage/storage/src/include/ep-graph.ycp Fri Jan 16 13:54:58 2009
@@ -10,12 +10,14 @@
void CreateGraphPanel(any user_data)
{
+ Storage::SaveGraph("storage.dot"); // TODO
+
UI::ReplaceWidget(`tree_panel,
Greasemonkey::Transform(
`VBox(
// dialog heading
`IconAndHeading(_("Storage Graph"), graph_icon),
- `Graph("graph.dot", "dot")) // TODO
+ `Graph("storage.dot", "dot"))
)
);
Modified: branches/tmp/aschnell/graph/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/graph/storage/storage/src/modules/Storage.ycp?rev=54699&r1=54698&r2=54699&view=diff
==============================================================================
--- branches/tmp/aschnell/graph/storage/storage/src/modules/Storage.ycp (original)
+++ branches/tmp/aschnell/graph/storage/storage/src/modules/Storage.ycp Fri Jan 16 13:54:58 2009
@@ -6465,6 +6465,13 @@
}
+global integer SaveGraph(string filename)
+{
+ integer ret = LibStorage::StorageInterface::saveGraph(sint, filename);
+ return ret;
+}
+
+
global boolean DeviceMatchFstab( string device, string fstab_spec )
{
boolean ret = false;
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org