我想知道是否可以自动分配到便携式私有子网?理想情况下,这将是供应时间。
我一直在关注此主题,但似乎您只能使用此方法指定主子网: https://forums.softlayer.com/forum/softlayer-developer-network/general-discussion/84021-create-vm-with-ip-addresses-assigned-to-the-specified-subnets
我们希望通过将服务器放在不同的子网上来实现网络分离(使用防火墙规则来删除这些子网之间的连接)。
这是否必须通过API在后期配置中完成?
提前致谢!
编辑: 以下是我配置设备的方法:
curl -X POST --data @baseOS.json https://${SL_USERNAME}:${SL_API_KEY}@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/createObject
baseOS.json:
{
"parameters":[
{
"hostname": "test03",
"domain": "test.com",
"primaryBackendNetworkComponent": {
"networkVlan": {
"id": <SUBNET_ID>,
"primarySubnetId": <SUBNET_ID>
}
},
"datacenter": {
"name": "mon01"
},
"startCpus": 1,
"maxMemory": 1024,
"hourlyBillingFlag": true,
"localDiskFlag": false,
"networkComponents": [
{
"maxSpeed": 10
}
],
"blockDeviceTemplateGroup": {
"globalIdentifier": "<ID>"
}
}
]
}
答案 0 :(得分:0)
IP assignment for new servers is done out of the primary front end/backend subnets. There is no way to influence which IPs are chosen for the primaries.
If you wanted to keep security to a subnet level, you would need to assign an IP to each server from the portable subnet as a secondary and package ch7;
public class Chapter_07_E22_EightQueens64bool {
public static void main(String[] args) {
int queenCount = 0;
int attemptCount = 0;
boolean[] board = new boolean[8 * 8];
final long TIME_LIMIT = 1; //Milliseconds
long startTime = System.currentTimeMillis();
while (queenCount < 8) {
int position = placeQueen(board.length);
if(checkPosition(position, board) && !board[position]) {
board[position] = true;
queenCount++;
}
long timeCheck = System.currentTimeMillis();
if (timeCheck - startTime > TIME_LIMIT) {
clearBoard(board);
queenCount = 0;
startTime = System.currentTimeMillis();
}
System.out.println("Attempt #" + ++attemptCount);
System.out.println(queenCount + " queens placed.");
printBoard(board);
}
}
public static void printBoard(boolean[] board) {
for (int i = 0; i < board.length; i++) {
if (board[i])
System.out.print("|Q");
else
System.out.print("| ");
if ((i + 1) % 8 == 0)
System.out.println("|");
}
}
public static int placeQueen(int boardSize) {
return (int)(Math.random() * boardSize);
}
public static boolean[] clearBoard(boolean[] board) {
for (int i = 0; i < board.length; i++)
board[i] = false;
return board;
}
public static boolean checkPosition(int position, boolean[] board) {
return checkTop(position, board) && checkBottom(position, board) && checkLeft(position, board) &&
checkRight(position, board) && checkTopLeft(position, board) && checkTopRight(position, board) &&
checkBottomLeft(position, board) && checkBottomRight(position, board);
}
public static boolean checkTop(int position, boolean[] board) {
// Checks each field above the current position while i >= 8
for (int i = position; i >= 8; i -= 8) {
if (board[i - 8])
return false;
}
return true;
}
public static boolean checkBottom(int position, boolean[] board) {
// Checks each field below the current position while i <= 55;
for (int i = position; i <= 55; i += 8) {
if (board[i + 8])
return false;
}
return true;
}
public static boolean checkRight(int position, boolean[] board) {
// Checks each field to the right of the current position while i % 8 < 7
for (int i = position; i % 8 < 7; i += 1) {
if (board[i + 1])
return false;
}
return true;
}
public static boolean checkLeft(int position, boolean[] board) {
// Checks each field to the left of the current position while i % 8 != 0
for (int i = position; i % 8 != 0; i -= 1) {
if (board[i - 1])
return false;
}
return true;
}
public static boolean checkTopLeft(int position, boolean[] board) {
// Checks each field top left of the current position while i >= 9
for (int i = position; i >= 9; i -= 9) {
if (board[i - 9])
return false;
}
return true;
}
public static boolean checkTopRight(int position, boolean[] board) {
// Checks each field top right of the current position while i >= 7
for (int i = position; i >= 7; i -= 7) {
if (board[i - 7])
return false;
}
return true;
}
public static boolean checkBottomRight(int position, boolean[] board) {
// Checks each field below the current position while i <= 54
for (int i = position; i <= 54; i += 9) {
if (board[i + 9])
return false;
}
return true;
}
public static boolean checkBottomLeft(int position, boolean[] board) {
// Checks each field below the current position while i <= 56
for (int i = position; i <= 56; i += 7) {
if (board[i + 7])
return false;
}
return true;
}
}
traffic from the primary subnet.
Using subnets may not be the best approach if you are not fully utilizing all available IPs you will run into IP justification issues. This may result in not having enough subnets for the desired config.
While it is more to manage, it may be better to have a more robust set of firewall rules that address communication on the primary subnet.