Package com.netflix.simianarmy

Examples of com.netflix.simianarmy.CloudClient


    private final Map<String, String> securityGroupNames = Maps.newHashMap();

    @Override
    public CloudClient cloudClient() {
        return new CloudClient() {
            @Override
            public void terminateInstance(String instanceId) {
                terminated.add(instanceId);
            }
View Full Code Here


    /**
     * We can apply the strategy iff the blocked security group is configured.
     */
    @Override
    public boolean canApply(ChaosInstance instance) {
        CloudClient cloudClient = instance.getCloudClient();
        String instanceId = instance.getInstanceId();

        if (!cloudClient.canChangeInstanceSecurityGroups(instanceId)) {
            LOGGER.info("Not a VPC instance, can't change security groups");
            return false;
        }

        return super.canApply(instance);
View Full Code Here

    /**
     * Takes the instance off the network.
     */
    @Override
    public void apply(ChaosInstance instance) {
        CloudClient cloudClient = instance.getCloudClient();
        String instanceId = instance.getInstanceId();

        if (!cloudClient.canChangeInstanceSecurityGroups(instanceId)) {
            throw new IllegalStateException("canApply should have returned false");
        }

        String groupId = cloudClient.findSecurityGroup(instance.getInstanceId(), blockedSecurityGroupName);

        if (groupId == null) {
            LOGGER.info("Auto-creating security group {}", blockedSecurityGroupName);

            String description = "Empty security group for blocked instances";
            groupId = cloudClient.createSecurityGroup(instance.getInstanceId(), blockedSecurityGroupName, description);
        }

        LOGGER.info("Blocking network traffic by applying security group {} to instance {}", groupId, instanceId);

        List<String> groups = Lists.newArrayList();
        groups.add(groupId);
        cloudClient.setInstanceSecurityGroups(instanceId, groups);
    }
View Full Code Here

    /**
     * Strategy can be applied iff there are any EBS volumes attached.
     */
    @Override
    public boolean canApply(ChaosInstance instance) {
        CloudClient cloudClient = instance.getCloudClient();
        String instanceId = instance.getInstanceId();

        List<String> volumes = cloudClient.listAttachedVolumes(instanceId, false);
        if (volumes.isEmpty()) {
            LOGGER.debug("Can't apply strategy: no non-root EBS volumes");
            return false;
        }

View Full Code Here

    /**
     * Force-detaches all attached EBS volumes from the instance.
     */
    @Override
    public void apply(ChaosInstance instance) {
        CloudClient cloudClient = instance.getCloudClient();
        String instanceId = instance.getInstanceId();

        // IDEA: We could have a strategy where we detach some of the volumes...
        boolean force = true;
        for (String volumeId : cloudClient.listAttachedVolumes(instanceId, false)) {
            cloudClient.detachVolume(instanceId, volumeId, force);
        }
    }
View Full Code Here

    /**
     * Shuts down the instance.
     */
    @Override
    public void apply(ChaosInstance instance) {
        CloudClient cloudClient = instance.getCloudClient();
        String instanceId = instance.getInstanceId();

        cloudClient.terminateInstance(instanceId);
    }
View Full Code Here

     *
     * @param instance id of instance
     * @return true iff root is on EBS
     */
    protected boolean isRootVolumeEbs(ChaosInstance instance) {
        CloudClient cloudClient = instance.getCloudClient();
        String instanceId = instance.getInstanceId();

        List<String> withRoot = cloudClient.listAttachedVolumes(instanceId, true);
        List<String> withoutRoot = cloudClient.listAttachedVolumes(instanceId, false);

        return (withRoot.size() != withoutRoot.size());
    }
View Full Code Here

TOP

Related Classes of com.netflix.simianarmy.CloudClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.