Examples of IaasProvider


Examples of org.apache.stratos.cloud.controller.pojo.IaasProvider

    buildTemplate();

  }

  public void buildTemplate() {
    IaasProvider iaasInfo = getIaasProvider();
   
    if (iaasInfo.getComputeService() == null) {
      throw new CloudControllerException(
          "Compute service is null for IaaS provider: "
              + iaasInfo.getName());
    }

    TemplateBuilder templateBuilder = iaasInfo.getComputeService()
        .templateBuilder();
    templateBuilder.imageId(iaasInfo.getImage());
        if(!(iaasInfo instanceof IaasProvider)) {
           templateBuilder.locationId(iaasInfo.getType());
        }
       
        // to avoid creation of template objects in each and every time, we
        // create all at once!

    String instanceType;

    // set instance type
    if (((instanceType = iaasInfo.getProperty(CloudControllerConstants.INSTANCE_TYPE)) != null)) {

      templateBuilder.hardwareId(instanceType);
    }

    Template template = templateBuilder.build();

    // In Openstack the call to IaaS should be blocking, in order to retrieve
    // IP addresses.
    boolean blockUntilRunning = true;
    if(iaasInfo.getProperty(CloudControllerConstants.BLOCK_UNTIL_RUNNING) != null) {
      blockUntilRunning = Boolean.parseBoolean(iaasInfo.getProperty(
          CloudControllerConstants.BLOCK_UNTIL_RUNNING));
    }
    template.getOptions().as(TemplateOptions.class)
        .blockUntilRunning(blockUntilRunning);

    // this is required in order to avoid creation of additional security
    // groups by Jclouds.
    template.getOptions().as(TemplateOptions.class)
        .inboundPorts(new int[] {});

    if (iaasInfo.getProperty(CloudControllerConstants.SECURITY_GROUPS) != null) {
      template.getOptions()
          .as(NovaTemplateOptions.class)
          .securityGroupNames(
              iaasInfo.getProperty(CloudControllerConstants.SECURITY_GROUPS).split(
                  CloudControllerConstants.ENTRY_SEPARATOR));
    }

    if (iaasInfo.getProperty(CloudControllerConstants.KEY_PAIR) != null) {
      template.getOptions().as(NovaTemplateOptions.class)
          .keyPairName(iaasInfo.getProperty(CloudControllerConstants.KEY_PAIR));
    }
   
        if (iaasInfo.getNetworkInterfaces() != null) {
            Set<Network> novaNetworksSet = new LinkedHashSet<Network>(iaasInfo.getNetworkInterfaces().length);
            for (NetworkInterface ni:iaasInfo.getNetworkInterfaces()) {
                novaNetworksSet.add(Network.builder().networkUuid(ni.getNetworkUuid()).fixedIp(ni.getFixedIp())
                        .portUuid(ni.getPortUuid()).build());
            }
            template.getOptions().as(NovaTemplateOptions.class).novaNetworks(novaNetworksSet);
        }
   
    if (iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) != null) {
      template.getOptions().as(NovaTemplateOptions.class)
          .availabilityZone(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE));
    }
   
    //TODO
//    if (iaas.getProperty(CloudControllerConstants.HOST) != null) {
//            template.getOptions().as(NovaTemplateOptions.class)
//                    .(CloudControllerConstants.HOST);
//        }

    // set Template
    iaasInfo.setTemplate(template);
  }
View Full Code Here

Examples of org.apache.stratos.cloud.controller.pojo.IaasProvider

  }

    @Override
  public void setDynamicPayload() {

      IaasProvider iaasInfo = getIaasProvider();
     
    if (iaasInfo.getTemplate() != null && iaasInfo.getPayload() != null) {

      iaasInfo.getTemplate().getOptions().as(NovaTemplateOptions.class)
          .userData(iaasInfo.getPayload());
    }

  }
View Full Code Here

Examples of org.apache.stratos.cloud.controller.pojo.IaasProvider

  @Override
  public synchronized boolean createKeyPairFromPublicKey(String region, String keyPairName,
      String publicKey) {

    IaasProvider iaasInfo = getIaasProvider();
   
    String openstackNovaMsg = " Openstack-nova. Region: " + region
        + " - Name: ";

    ComputeServiceContext context = iaasInfo.getComputeService()
        .getContext();
    RestContext<NovaApi, NovaAsyncApi> nova = context.unwrap();
    KeyPairApi api = nova.getApi().getKeyPairExtensionForZone(region).get();

    KeyPair keyPair = api.createWithPublicKey(keyPairName, publicKey);

    if (keyPair != null) {

      iaasInfo.getTemplate().getOptions().as(NovaTemplateOptions.class)
          .keyPairName(keyPair.getName());

      log.info(SUCCESSFUL_LOG_LINE + openstackNovaMsg + keyPair.getName());
      return true;
    }
View Full Code Here

Examples of org.apache.stratos.cloud.controller.pojo.IaasProvider

  }

  @Override
  public synchronized String associateAddress(NodeMetadata node) {
   
    IaasProvider iaasInfo = getIaasProvider();

    ComputeServiceContext context = iaasInfo.getComputeService()
        .getContext();

    String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);

    RestContext<NovaApi, NovaAsyncApi> nova = context.unwrap();
View Full Code Here

Examples of org.apache.stratos.cloud.controller.pojo.IaasProvider

  public synchronized String associatePredefinedAddress (NodeMetadata node, String ip) {
    if(log.isDebugEnabled()) {
      log.debug("OpenstackNovaIaas:associatePredefinedAddress:ip:" + ip);
    }
   
    IaasProvider iaasInfo = getIaasProvider();
   
    ComputeServiceContext context = iaasInfo.getComputeService()
        .getContext();

    @SuppressWarnings("deprecation")
        NovaApi novaClient = context.unwrap(NovaApiMetadata.CONTEXT_TOKEN).getApi();
    String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
View Full Code Here

Examples of org.apache.stratos.cloud.controller.pojo.IaasProvider

 

  @Override
  public synchronized void releaseAddress(String ip) {

    IaasProvider iaasInfo = getIaasProvider();
   
    ComputeServiceContext context = iaasInfo.getComputeService()
        .getContext();

    String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);

    @SuppressWarnings("deprecation")
View Full Code Here

Examples of org.apache.stratos.cloud.controller.pojo.IaasProvider

    }
  }

    @Override
    public boolean isValidRegion(String region) throws InvalidRegionException {
      IaasProvider iaasInfo = getIaasProvider();
     
        // jclouds' zone = region in openstack
        if (region == null || iaasInfo == null) {
            String msg =
                         "Region or IaaSProvider is null: region: " + region + " - IaaSProvider: " +
                                 iaasInfo;
            log.error(msg);
            throw new InvalidRegionException(msg);
        }
       
        ComputeServiceContext context = iaasInfo.getComputeService().getContext();
        RestContext<NovaApi, NovaAsyncApi> nova = context.unwrap();
        Set<String> zones = nova.getApi().getConfiguredZones();
        for (String configuredZone : zones) {
            if (region.equalsIgnoreCase(configuredZone)) {
                if (log.isDebugEnabled()) {
                    log.debug("Found a matching region: " + region);
                }
                return true;
            }
        }
       
        String msg = "Invalid region: " + region +" in the iaas: "+iaasInfo.getType();
        log.error(msg);
        throw new InvalidRegionException(msg);
    }
View Full Code Here

Examples of org.apache.stratos.cloud.controller.pojo.IaasProvider

        throw new InvalidRegionException(msg);
    }

    @Override
    public boolean isValidZone(String region, String zone) throws InvalidZoneException {
      IaasProvider iaasInfo = getIaasProvider();
     
      // jclouds availability zone = stratos zone
      if (region == null || zone == null || iaasInfo == null) {
            String msg = "Host or Zone or IaaSProvider is null: region: " + region + " - zone: " +
                    zone + " - IaaSProvider: " + iaasInfo;
            log.error(msg);
            throw new InvalidZoneException(msg);
        }
        ComputeServiceContext context = iaasInfo.getComputeService().getContext();
        RestContext<NovaApi, NovaAsyncApi> nova = context.unwrap();
        AvailabilityZoneAPI zoneApi = nova.getApi().getAvailabilityZoneApi(region);
        for (AvailabilityZone z : zoneApi.list()) {
     
          if (zone.equalsIgnoreCase(z.getName())) {
            if (log.isDebugEnabled()) {
              log.debug("Found a matching availability zone: " + zone);
            }
            return true;
          }
    }
       
        String msg = "Invalid zone: " + zone +" in the region: "+region+ " and of the iaas: "+iaasInfo.getType();
        log.error(msg);
        throw new InvalidZoneException(msg);
       
    }
View Full Code Here

Examples of org.apache.stratos.cloud.controller.pojo.IaasProvider

       
    }

    @Override
    public boolean isValidHost(String zone, String host) throws InvalidHostException {
      IaasProvider iaasInfo = getIaasProvider();
     
        if (host == null || zone == null || iaasInfo == null) {
            String msg = "Host or Zone or IaaSProvider is null: host: " + host + " - zone: " +
                    zone + " - IaaSProvider: " + iaasInfo;
            log.error(msg);
            throw new InvalidHostException(msg);
        }
        ComputeServiceContext context = iaasInfo.getComputeService().getContext();
        RestContext<NovaApi, NovaAsyncApi> nova = context.unwrap();
        HostAggregateApi hostApi = nova.getApi().getHostAggregateExtensionForZone(zone).get();
        for (HostAggregate hostAggregate : hostApi.list()) {
            for (String configuredHost : hostAggregate.getHosts()) {
                if (host.equalsIgnoreCase(configuredHost)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Found a matching host: " + host);
                    }
                    return true;
                }
            }
        }
       
        String msg = "Invalid host: " + host +" in the zone: "+zone+ " and of the iaas: "+iaasInfo.getType();
        log.error(msg);
        throw new InvalidHostException(msg);
    }
View Full Code Here

Examples of org.apache.stratos.cloud.controller.pojo.IaasProvider

        return new OpenstackNovaPartitionValidator();
    }

  @Override
  public String createVolume(int sizeGB) {
    IaasProvider iaasInfo = getIaasProvider();
    String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
    String zone = ComputeServiceBuilderUtil.extractZone(iaasInfo);
   
        if (region == null || iaasInfo == null) {
          log.fatal("Cannot create a new volume in the [region] : "+region
          +" of Iaas : "+iaasInfo);
            return null;
        }
        ComputeServiceContext context = iaasInfo.getComputeService().getContext();
       
        RestContext<NovaApi, NovaAsyncApi> nova = context.unwrap();
        VolumeApi api = nova.getApi().getVolumeExtensionForZone(region).get();
        Volume volume = api.create(sizeGB, CreateVolumeOptions.Builder.availabilityZone(zone));
        if (volume == null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.