Search in sources :

Example 21 with Instance

use of com.google.cloud.redis.v1.Instance in project java-redis by googleapis.

the class ITSystemTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    CloudRedisSettings.Builder cloudRedisSettingsBuilder = CloudRedisSettings.newBuilder();
    cloudRedisSettingsBuilder.getInstanceSettings().setRetrySettings(cloudRedisSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder().setTotalTimeout(Duration.ofSeconds(900)).build());
    CloudRedisSettings cloudRedisSettings = cloudRedisSettingsBuilder.build();
    client = CloudRedisClient.create(cloudRedisSettings);
    /* Creates a Redis instance based on the specified tier and memory size. */
    Instance instance = Instance.newBuilder().setTier(TIER).setMemorySizeGb(1).setAuthorizedNetwork(AUTHORIZED_NETWORK).build();
    client.createInstanceAsync(PARENT, INSTANCE, instance).get();
    LOG.info("redis instance created successfully.");
}
Also used : Instance(com.google.cloud.redis.v1beta1.Instance) CloudRedisSettings(com.google.cloud.redis.v1beta1.CloudRedisSettings) BeforeClass(org.junit.BeforeClass)

Example 22 with Instance

use of com.google.cloud.redis.v1.Instance in project omegat by omegat-org.

the class FilterMaster method getDefaultSettingsFromFilter.

/**
 * Create default filter's config.
 *
 * @param filterClassname
 *            filter's classname
 * @return default filter's config
 */
public static Filter getDefaultSettingsFromFilter(final String filterClassname) {
    IFilter f = getFilterInstance(filterClassname);
    if (f == null) {
        return null;
    }
    Filter fc = new Filter();
    fc.setClassName(f.getClass().getName());
    fc.setEnabled(true);
    for (Instance ins : f.getDefaultInstances()) {
        Files ff = new Files();
        ff.setSourceEncoding(ins.getSourceEncoding());
        ff.setSourceFilenameMask(ins.getSourceFilenameMask());
        ff.setTargetEncoding(ins.getTargetEncoding());
        ff.setTargetFilenamePattern(ins.getTargetFilenamePattern());
        fc.getFiles().add(ff);
    }
    return fc;
}
Also used : IFilter(org.omegat.filters2.IFilter) IFilter(org.omegat.filters2.IFilter) Filter(gen.core.filters.Filter) AbstractFilter(org.omegat.filters2.AbstractFilter) Instance(org.omegat.filters2.Instance) Files(gen.core.filters.Files)

Example 23 with Instance

use of com.google.cloud.redis.v1.Instance in project TOSCAna by StuPro-TOSCAna.

the class CloudFormationVisitor method createSqlEc2.

/**
 *     Creates a EC2 for a {@link MysqlDatabase} that runs an initial sql query.
 *
 *     @param mysqlDatabase the {@link MysqlDatabase} this sql query should be run on
 *     @param sqlQuery      the sql query to run
 *     @return the instance name of the created EC2 Instance
 */
protected String createSqlEc2(MysqlDatabase mysqlDatabase, String sqlQuery) {
    String ec2Name = toAlphanumerical(mysqlDatabase.getEntityName()) + "TmpSqlServer";
    SecurityGroup webServerSecurityGroup = cfnModule.resource(SecurityGroup.class, ec2Name + SECURITY_GROUP).groupDescription("Temporary group for accessing mysqlDatabase" + toAlphanumerical(mysqlDatabase.getEntityName()) + " with SQLRequest");
    cfnModule.resource(Instance.class, ec2Name).securityGroupIds(webServerSecurityGroup).imageId("ami-79873901").instanceType("t2.micro").instanceInitiatedShutdownBehavior("terminate").userData(new UserData(StackUtils.getUserDataDBConnFn(mysqlDatabase, sqlQuery)));
    return ec2Name;
}
Also used : Instance(com.scaleset.cfbuilder.ec2.Instance) UserData(com.scaleset.cfbuilder.ec2.UserData) SecurityGroup(com.scaleset.cfbuilder.ec2.SecurityGroup)

Example 24 with Instance

use of com.google.cloud.redis.v1.Instance in project TOSCAna by StuPro-TOSCAna.

the class CloudFormationModule method build.

/**
 *     Build the template.
 *     <br>
 *     Following steps are taken:
 *     <ol>
 *     <li>Add CFNInit to corresponding instance resource </li>
 *     <li>Check if EC2 instances need access to S3. If yes, then
 *     <ol>
 *     <li>Add necessary IAM resources to the module</li>
 *     <li>Add <tt>Authentication<tt> and <tt>IamInstanceProfile<tt> to corresponding instance resource</li>
 *     </ol>
 *     </li>
 *     <li>Add the KeyPair to the template if it is needed</li>
 *     </ol>
 */
@Override
public void build() {
    for (Map.Entry<String, CFNInit> pair : cfnInitMap.entrySet()) {
        Resource res = this.getResource(pair.getKey());
        if (res instanceof Instance) {
            Instance instance = (Instance) res;
            if (!pair.getValue().getConfigs().isEmpty()) {
                instance.addCFNInit(pair.getValue()).userData(new UserData(getUserDataFn(pair.getKey(), CONFIG_SETS, this)));
            }
        }
    }
    if (!fileUploadList.isEmpty()) {
        Role instanceRole = getS3InstanceRole(this);
        getS3Policy(this).roles(instanceRole);
        getS3InstanceProfile(this).roles(instanceRole);
        Authentication s3authentication = getS3Authentication(bucketName);
        for (String instanceName : authenticationSet) {
            Resource res = this.getResource(instanceName);
            if (res instanceof Instance) {
                Instance instance = (Instance) res;
                instance.authentication(s3authentication).iamInstanceProfile(ref(INSTANCE_PROFILE));
            }
        }
    }
    if (this.hasKeyPair()) {
        strParam(KEYNAME).type(KEYNAME_TYPE).description(KEYNAME_DESCRIPTION).constraintDescription(KEYNAME_CONSTRAINT_DESCRIPTION);
    }
}
Also used : AuthenticationUtils.getS3InstanceRole(org.opentosca.toscana.plugins.cloudformation.util.AuthenticationUtils.getS3InstanceRole) Role(com.scaleset.cfbuilder.iam.Role) Instance(com.scaleset.cfbuilder.ec2.Instance) UserData(com.scaleset.cfbuilder.ec2.UserData) AuthenticationUtils.getS3Authentication(org.opentosca.toscana.plugins.cloudformation.util.AuthenticationUtils.getS3Authentication) Authentication(com.scaleset.cfbuilder.cloudformation.Authentication) Resource(com.scaleset.cfbuilder.core.Resource) CFNInit(com.scaleset.cfbuilder.ec2.metadata.CFNInit) HashMap(java.util.HashMap) Map(java.util.Map)

Example 25 with Instance

use of com.google.cloud.redis.v1.Instance in project java-docs-samples by GoogleCloudPlatform.

the class ListInstance method listInstances.

// List all instances in the given zone in the specified project ID.
public static void listInstances(String project, String zone) throws IOException {
    // safely clean up any remaining background resources.
    try (InstancesClient instancesClient = InstancesClient.create()) {
        // Set the project and zone to retrieve instances present in the zone.
        System.out.printf("Listing instances from %s in %s:", project, zone);
        for (Instance zoneInstance : instancesClient.list(project, zone).iterateAll()) {
            System.out.println(zoneInstance.getName());
        }
        System.out.println("####### Listing instances complete #######");
    }
}
Also used : Instance(com.google.cloud.compute.v1.Instance) InstancesClient(com.google.cloud.compute.v1.InstancesClient)

Aggregations

Test (org.junit.Test)18 Instance (com.google.cloud.compute.v1.Instance)11 InstancesClient (com.google.cloud.compute.v1.InstancesClient)11 Instance (com.google.bigtable.admin.v2.Instance)10 ByteString (com.google.protobuf.ByteString)9 AbstractMessage (com.google.protobuf.AbstractMessage)8 Operation (com.google.cloud.compute.v1.Operation)7 InsertInstanceRequest (com.google.cloud.compute.v1.InsertInstanceRequest)6 AttachedDisk (com.google.cloud.compute.v1.AttachedDisk)5 NetworkInterface (com.google.cloud.compute.v1.NetworkInterface)5 Instance (com.google.cloud.redis.v1.Instance)5 HashMap (java.util.HashMap)5 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)4 Cluster (com.google.bigtable.admin.v2.Cluster)4 Instance (com.google.cloud.redis.v1beta1.Instance)4 FieldMask (com.google.protobuf.FieldMask)4 Instance (com.scaleset.cfbuilder.ec2.Instance)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4 Operation (com.google.longrunning.Operation)3 CreateInstanceRequest (com.google.bigtable.admin.v2.CreateInstanceRequest)2