当前位置: 首页>>代码示例>>Java>>正文


Java Snapshot类代码示例

本文整理汇总了Java中com.woorea.openstack.cinder.model.Snapshot的典型用法代码示例。如果您正苦于以下问题:Java Snapshot类的具体用法?Java Snapshot怎么用?Java Snapshot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Snapshot类属于com.woorea.openstack.cinder.model包,在下文中一共展示了Snapshot类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreateSnapshot

import com.woorea.openstack.cinder.model.Snapshot; //导入依赖的package包/类
@Test(timeout = TIMEOUT)
public void testCreateSnapshot() {
    final String volumeId = createVolume("test_create").getId();

    Timer timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
        public void run() {
            Volume volume = getVolumeById(volumeId);
            switch (CinderVolumeStatus.forValue(volume.getStatus())) {
                case Available:
                    cancel();
                    Snapshot snapshot = createSnapshot("test_create", volume.getId());
                    Assert.assertNotNull(snapshot);
                    log.info(getSnapshotById(snapshot.getId()));
                    completedMap.put("testCreateSnapshot", true);
                    break;
            }
        }
    }, 0, 1000);
    while (completedMap.get("testCreateSnapshot") == null);
}
 
开发者ID:danielerez,项目名称:openstack-java-sdk-cinder-tests,代码行数:22,代码来源:CinderSnapshotsTest.java

示例2: testUpdateSnapshot

import com.woorea.openstack.cinder.model.Snapshot; //导入依赖的package包/类
@Test(timeout = TIMEOUT)
public void testUpdateSnapshot() {
    final String volumeId = createVolume("test_update").getId();

    Timer timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
        public void run() {
            Volume volume = getVolumeById(volumeId);
            switch (CinderVolumeStatus.forValue(volume.getStatus())) {
                case Available:
                    cancel();
                    Snapshot snapshot = createSnapshot("test_update", volume.getId());
                    String newName = "test_update_new_name";
                    String newDesc = "test_update_new_desc";

                    updateSnapshot(snapshot.getId(), newName, newDesc);
                    snapshot = getSnapshotById(snapshot.getId());
                    Assert.assertTrue(snapshot.getName().equals(newName) && snapshot.getDescription().equals(newDesc));
                    completedMap.put("testUpdateSnapshot", true);
                    break;
            }
        }
    }, 0, 1000);
    while (completedMap.get("testUpdateSnapshot") == null);
}
 
开发者ID:danielerez,项目名称:openstack-java-sdk-cinder-tests,代码行数:26,代码来源:CinderSnapshotsTest.java

示例3: testGetSnapshots

import com.woorea.openstack.cinder.model.Snapshot; //导入依赖的package包/类
@Test
public void testGetSnapshots() {
    Snapshots snapshots = getSnapshots();
    Assert.assertNotNull(snapshots);
    for (Snapshot snapshot : snapshots) {
        log.info(snapshot);
    }
}
 
开发者ID:danielerez,项目名称:openstack-java-sdk-cinder-tests,代码行数:9,代码来源:CinderSnapshotsTest.java

示例4: testDeleteSnapshot

import com.woorea.openstack.cinder.model.Snapshot; //导入依赖的package包/类
@Test(timeout = TIMEOUT)
public void testDeleteSnapshot() throws InterruptedException {
    final String volumeId = createVolume("test_delete").getId();

    Timer timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
        Snapshot snapshot = null;

        public void run() {
            if (snapshot == null) {
                Volume volume = getVolumeById(volumeId);
                switch (CinderVolumeStatus.forValue(volume.getStatus())) {
                    case Available:
                        snapshot = createSnapshot("test_create", volume.getId());
                        break;
                }
            } else {
                try {
                    snapshot = getSnapshotById(snapshot.getId());
                    switch (CinderVolumeStatus.forValue(snapshot.getStatus())) {
                        case Available:
                            deleteSnaphsot(snapshot.getId());
                            break;
                    }
                } catch (OpenStackResponseException e) {
                    cancel();
                    Assert.assertEquals(e.getStatus(), HttpStatus.SC_NOT_FOUND);
                    completedMap.put("testDeleteSnapshot", true);
                }
            }
        }
    }, 0, 1000);
    while (completedMap.get("testDeleteSnapshot") == null);
}
 
开发者ID:danielerez,项目名称:openstack-java-sdk-cinder-tests,代码行数:35,代码来源:CinderSnapshotsTest.java

示例5: testShowMetadata

import com.woorea.openstack.cinder.model.Snapshot; //导入依赖的package包/类
@Test(timeout = TIMEOUT)
public void testShowMetadata() throws InterruptedException {
    final String volumeId = createVolume("test_metadata").getId();

    Timer timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
        public void run() {
            Volume volume = getVolumeById(volumeId);
            switch (CinderVolumeStatus.forValue(volume.getStatus())) {
                case Available:
                    cancel();
                    Snapshot snapshot = createSnapshot("test_metadata", volumeId);

                    Map<String, String> map = new HashMap<String, String>();
                    map.put("test_key1", "test_value1");
                    map.put("test_key2", "test_value2");
                    Metadata metadata = new Metadata();
                    metadata.setMetadata(map);
                    updateSnapshotMetadata(snapshot.getId(), metadata);

                    Metadata updatedMetadata = getSnapshotMetadata(snapshot.getId());
                    log.info(updatedMetadata);
                    completedMap.put("testShowMetadata", true);
                    break;
            }
        }
    }, 0, 1000);
    while (completedMap.get("testShowMetadata") == null);
}
 
开发者ID:danielerez,项目名称:openstack-java-sdk-cinder-tests,代码行数:30,代码来源:CinderSnapshotsTest.java

示例6: createSnapshot

import com.woorea.openstack.cinder.model.Snapshot; //导入依赖的package包/类
private Snapshot createSnapshot(String name, String volumeId) {
    SnapshotForCreate snapshotForCreate = new SnapshotForCreate();
    snapshotForCreate.setName(name);
    snapshotForCreate.setDescription("test_description");
    snapshotForCreate.setVolumeId(volumeId);
    return getClient(getTenantId()).snapshots().create(snapshotForCreate).execute();
}
 
开发者ID:danielerez,项目名称:openstack-java-sdk-cinder-tests,代码行数:8,代码来源:CinderSnapshotsTest.java

示例7: getSnapshotById

import com.woorea.openstack.cinder.model.Snapshot; //导入依赖的package包/类
private Snapshot getSnapshotById(String id) {
    return getClient(getTenantId()).snapshots().show(id).execute();
}
 
开发者ID:danielerez,项目名称:openstack-java-sdk-cinder-tests,代码行数:4,代码来源:CinderSnapshotsTest.java


注:本文中的com.woorea.openstack.cinder.model.Snapshot类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。