Package org.openstack.model.compute

Examples of org.openstack.model.compute.SecurityGroup


        if (server == null) {
          log.warn("Could not find assigned server: " + instanceId + ", ignoring");
          continue;
        }

        SecurityGroup securityGroup = null;

        if (supportsSecurityGroups) {
          securityGroup = openstackHelpers.getMachineSecurityGroup(computeClient, server);
        }

        AsyncServerOperation terminateOperation = openstack.terminateInstance(cloud, instanceId);

        if (securityGroup != null) {
          // We need to terminate the instance before we delete the security group it uses
          if (terminateOperation != null) {
            waitOperation(terminateOperation);
          }

          try {
            log.info("Deleting security group: " + securityGroup.getId());
            computeClient.root().securityGroups().securityGroup(securityGroup.getId()).delete();
          } catch (OpenstackNotFoundException e) {
            log.info("Ignoring not-found error while deleting security group: " + securityGroup.getId());
          }
        }
      }
    }
View Full Code Here


        if (foundImage == null) {
          throw new IllegalArgumentException("Could not find image: " + imageId);
        }
      }

      SecurityGroup createdSecurityGroup = null;
      if (cloudBehaviours.supportsSecurityGroups()) {
        SecurityGroup createTemplate = new SecurityGroup();
        createTemplate.setName(SECURITY_GROUP_PREFIX + serverName);
        createTemplate.setDescription("Security group for instance: " + serverName);
        try {
          log.info("Creating security group: " + createTemplate.getName());
          createdSecurityGroup = computeClient.root().securityGroups().create(createTemplate);
        } catch (OpenstackException e) {
          for (SecurityGroup candidate : computeClient.root().securityGroups().list()) {
            if (Objects.equal(candidate.getName(), createTemplate.getName())) {
              createdSecurityGroup = candidate;
              break;
            }
          }
View Full Code Here

    // Find the public address, although the OpenStack firewall may be blocking it
    publicAddress = machine.getNetworkPoint().getBestAddress(NetworkPoint.forPublicInternet());

    if (cloudBehaviours.supportsSecurityGroups()) {
      Server server = machine.getServer();
      SecurityGroup securityGroup = openstackHelpers.getMachineSecurityGroup(openstackComputeClient, server);

      securityGroup = openstackComputeClient.root().securityGroups().securityGroup(securityGroup.getId()).show();

      SecurityGroupRule matchingRule = findMatchingRule(securityGroup);

      if (OpsContext.isConfigure()) {
        if (matchingRule == null) {
          CreateSecurityGroupRuleRequest rule = new CreateSecurityGroupRuleRequest();
          rule.setCidr("0.0.0.0/0");
          rule.setIpProtocol("tcp");
          rule.setFromPort(model.publicPort);
          rule.setToPort(model.publicPort);
          rule.setParentGroupId(securityGroup.getId());

          openstackComputeClient.root().securityGroupRules().create(rule);
        }
      }
View Full Code Here

      securityGroups = openstackComputeClient.root().securityGroups().list();
    } catch (OpenstackException e) {
      throw new OpsException("Error getting security groups for server", e);
    }

    SecurityGroup securityGroup = null;
    if (securityGroups != null && securityGroups.getList() != null) {
      for (SecurityGroup candidate : securityGroups.getList()) {
        if (candidate.getName() == null) {
          continue;
        }
View Full Code Here

TOP

Related Classes of org.openstack.model.compute.SecurityGroup

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.