www.cnblogs.com/ruiyqinrui

开源、架构、Linux C/C++/python AI BI 运维开发自动化运维。 春风桃李花 秋雨梧桐叶。“力尽不知热 但惜夏日长”。夏不惜,秋不获。@ruiY--秦瑞

python爬虫,C编程,嵌入式开发.hadoop大数据,桉树,onenebula云计算架构.linux运维及驱动开发.

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
Identity
// V2 authentication
OSClientV2 os = OSFactory.builderV2()
                  .endpoint("http://127.0.0.1:5000/v2.0")
                  .credentials("admin","secret")
                  .tenantName("admin")
                  .authenticate();

// V3 authentication
OSClientV3 os = OSFactory.builderV3()
                  .endpoint("http://127.0.0.1:5000/v3")
                  .credentials("admin", "secret", Identifier.byName("Default"))
                  .scopeToProject(Identifier.byName("admin"))
                  .authenticate();
Compute
// Create a Server Model Object
Server server = Builders.server()
                        .name("Ubuntu 2")
                        .flavor("large")
                        .image("imageId")
                        .build();

// Boot the Server
Server server = os.compute().servers().boot(server);

// Create a Snapshot
os.compute().servers().createSnapshot("id", "name");
Image
// Create an Image
Image image = os.images().create(Builders.image()
                .name("Cirros 0.3.0 x64")
                .isPublic(true)
                .containerFormat(ContainerFormat.BARE)
                .diskFormat(DiskFormat.QCOW2)
                .build()
                ), Payloads.create(new File("cirros.img")));
Network
// Create a Port
Port port = os.networking().port()
              .create(Builders.port()
              .name("port1")
              .networkId("networkId")
              .fixedIp("52.51.1.253", "subnetId")
              .build());
posted on 2016-11-15 14:04  秦瑞It行程实录  阅读(1283)  评论(1)    收藏  举报
www.cnblogs.com/ruiyqinrui