| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.softlayer; |
| 20 | |
| 21 | import static org.jclouds.Constants.PROPERTY_API_VERSION; |
| 22 | import static org.jclouds.Constants.PROPERTY_ENDPOINT; |
| 23 | import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; |
| 24 | import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX; |
| 25 | import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE; |
| 26 | import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY; |
| 27 | import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME; |
| 28 | import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED; |
| 29 | import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES; |
| 30 | |
| 31 | import java.util.Properties; |
| 32 | |
| 33 | import org.jclouds.PropertiesBuilder; |
| 34 | |
| 35 | import com.google.common.base.Joiner; |
| 36 | import com.google.common.collect.ImmutableSet; |
| 37 | import com.google.common.collect.ImmutableSet.Builder; |
| 38 | |
| 39 | /** |
| 40 | * Builds properties used in SoftLayer Clients |
| 41 | * |
| 42 | * @author Adrian Cole |
| 43 | */ |
| 44 | public class SoftLayerPropertiesBuilder extends PropertiesBuilder { |
| 45 | @Override |
| 46 | protected Properties defaultProperties() { |
| 47 | Properties properties = super.defaultProperties(); |
| 48 | properties.setProperty(PROPERTY_ENDPOINT, "https://api.softlayer.com/rest"); |
| 49 | properties.setProperty(PROPERTY_API_VERSION, "3"); |
| 50 | properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY, "" + 60 * 60 * 1000); |
| 51 | properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME, "Cloud Server"); |
| 52 | // ex: for private (ex. don't share hardware) use "Private [0-9]+ x ([.0-9]+) GHz Core[s]?" |
| 53 | // ex: for private and public use ".*[0-9]+ x ([.0-9]+) GHz Core[s]?" |
| 54 | properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "[0-9]+ x ([0-9.]+) GHz Core[s]?"); |
| 55 | // SAN or LOCAL |
| 56 | properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE, "LOCAL"); |
| 57 | // 10, 100, 1000 |
| 58 | properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "10"); |
| 59 | properties.setProperty(PROPERTY_ISO3166_CODES, "SG,US-CA,US-TX,US-VA,US-WA,US-TX"); |
| 60 | Builder<String> prices = ImmutableSet.<String> builder(); |
| 61 | prices.add("21"); // 1 IP Address |
| 62 | prices.add("55"); // Host Ping: categoryCode: monitoring, notification |
| 63 | prices.add("57"); // Email and Ticket: categoryCode: notification |
| 64 | prices.add("58"); // Automated Notification: categoryCode: response |
| 65 | prices.add("1800"); // 0 GB Bandwidth: categoryCode: bandwidth |
| 66 | prices.add("905"); // Reboot / Remote Console: categoryCode: remote_management |
| 67 | prices.add("418"); // Nessus Vulnerability Assessment & Reporting: categoryCode: |
| 68 | // vulnerability_scanner |
| 69 | prices.add("420"); // Unlimited SSL VPN Users & 1 PPTP VPN User per account: categoryCode: |
| 70 | // vpn_management |
| 71 | properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PRICES, Joiner.on(',').join(prices.build())); |
| 72 | return properties; |
| 73 | } |
| 74 | |
| 75 | public SoftLayerPropertiesBuilder(Properties properties) { |
| 76 | super(properties); |
| 77 | } |
| 78 | |
| 79 | } |