달력

6

« 2025/6 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
2012. 10. 25. 16:34

yast2 storage API 카테고리 없음2012. 10. 25. 16:34


https://github.com/openSUSE/libstorage/blob/master/examples/TestLvm.cc

yast2 partition system API

#include<iostream>

#include<storage/StorageInterface.h>


using namespace std;

using namespace storage;


void installInfoCb(const string& info)

{

    cout << "INFO : " << info << endl;

}



StorageInterface *s;



int main(int argc, char **argv)

{

    int ret;


    initDefaultLogger();

    s = createStorageInterface(Environment(false));


    s->setCallbackShowInstallInfo(installInfoCb);


    //Lvm의 타켓은 /dev/sdb

    string disk = "sdc";

    string device;


    deque<string> devs;

    deque<PartitionInfo> infos;

    s->getPartitionInfo(disk, infos);


    {

        if(i->partitionType != EXTENDED)

        {   devs.push_back(i->v.name);

            cout << "NOT EXTENDED " << i->v.name << endl;

        }

    }


    //volume group == container create

//  ret = s->createLvmVg("testVg", 8 * 1024, false, devs);

//  s->commit();


    //Logical Volume create testVg/test1

//  ret = s->createLvmLv("testVg", "test1", 4* 1024 , 1, device);

//  s->commit();


//  cout << "createLvmLv : " << device << endl;


    /*

    if(ret == 0 && devs.size() > 0)

    {

        deque<string> ds;

        ds.push_back(devs.back());


        ret = s->shrinkLvmVg("testVg", ds);

    }


    s->commit();

*/

    //volume resize

//  s->resizeVolume(device, 2900 * 1024);

//  s->commit();


    //disk에서 seq순으로 partition을 만듦

    s->createPartitionAny(disk, 1 * 1024 * 1024, device);

    s->commit();


/*  string ext_device;


    if(ret ==0)

    {

        deque<string> ds;

        ds.push_back(device);

        ext_device = device;


        ret = s->extendLvmVg("testVg", ds);


    }

*/

    //Logical Volume create

    //create Volume Group : devs에 있는 device들을 가지고

    s->createLvmVg("testVg",1024 * 1024, false, devs);

    s->commit();


    //test2 volume을 생성한다.

    s->createLvmLv("testVg", "test2", 500 * 1024, 1, device);

    s->commit();


    cout << "device : " << device << endl;


    //deivce에서 Lvm에 있는 logical volume를 제거

    //s->removeLvmLvByDevice(device);

    s->commit();



    delete(s);




    return 0;

}

:
Posted by НooпeУ


Code Start Code End