I want to insert the following entry into the /etc/hosts file somehow using Ansible.
10.33.5.44 ip-10-33-5-44
Run Code Online (Sandbox Code Playgroud)
Here, the schema is that the ip should have an alias corresponding to the IP, prefixed with ip- and where the dot . would be replaced by dash -.
But to get this IP, I can only think of doing the host command on a DNS name e.g.
host euwest2-test-box.company.com
> euwest2-test-box.company.com has address 10.33.5.44
Run Code Online (Sandbox Code Playgroud)
Can anyone suggest how to get that to …
我正在使用JsonUnit的assertJsonEquals
我在代码中执行以下操作:
assertJsonEquals(resource("ExpecedResponse.json"),
ActualResponse, when(IGNORING_ARRAY_ORDER));
Run Code Online (Sandbox Code Playgroud)
的ActualResponse具有从HTTP POST的响应。
该ExpectedResponse.json是一些字段的JSON文件如如下:
{
"columnNames": [
"date",
"signalType",
"userId",
],
"values": [
[
222555888,
"OUT",
"000-000-111-444"
],
[
333666999,
"IN",
"000-000-222-333"
],
],
"lastUpdatedTimestamp": "2018-01-26T00:00:00Z"
}
Run Code Online (Sandbox Code Playgroud)
我将这两个响应与assertJsonEquals进行比较。
我的问题是:如何告诉它忽略检查lastUpdatedTimestamp字段,而是使用assertJsonEquals或您推荐的任何其他库检查其他所有内容?
如果我从ExpectedResponse.json中删除了lastUpdatedTimestamp,那么它会抱怨它丢失了!
谢谢您的帮助,谢谢。
我正在使用docker-compose命令来创建和启动我的容器.
我的Docker版本
docker --version
Docker version 17.09.0-ce, build afdb6d4
我的Docker-Compose版本
docker-compose --version
docker-compose version 1.16.1, build 6d1ac21
我正在使用的.yml文件看起来像这样:(请注意,我只是缩短它以将敏感的东西拿出来)
---
services:
zookeeper:
image: "zookeeper"
server-1:
cap_add:
- "NET_ADMIN"
server-0:
cap_add:
- "NET_ADMIN"
dns:
- 8.8.8.8
- 9.9.9.9
environment:
SERVER_ID: 0
NETEM_HOSTS: ""
LOSS_VALUES: ""
MAX_RATE_VALUES: ""
DELAY_VALUES: ""
image: "cloud.mycompany.com:5000/server-0:latest"
fakedns:
image: "cloud.mycompany.com:5000/fakedns:latest"
version: "3.3"
Run Code Online (Sandbox Code Playgroud)
然后我开始使用:
docker-compose --file compose.yml up -d
我的问题是:
1)容器出现后......当我进入容器时,例如在这种情况下服务器-0,我没有看到/etc/resolv.conf文件已更新为使用这些名称服务器.相反,它使用docker的嵌入式dns,即127.0.0.11
2)如何确保它使用我在docker-compose使用的文件中指定的内容
3)我尝试使用命令执行此操作,它似乎工作,但我需要从compose-file
docker run -p 4000:53 --dns=8.8.8.8 cloud.mycompany.com:5000/server-0:latest
4)理想情况下,我希望它拥有容器'fakedns'的IP地址,以便它使用这个而不是嵌入式的@ 127.0.0.11
我有一些Java代码,它从给定的纪元时间返回ISO-8601时间格式.
public String getISO8601(String epochTime) {
long epoch = Long.parseLong(epochTs);
ZoneId zone = ZoneId.of("Europe/London");
LocalDate then = Instant.ofEpochMilli(epoch).atZone(zone).toLocalDate();
LocalDate today = LocalDate.now(zone);
Period diff = Period.between(then, today);
return diff.toString();
}
Run Code Online (Sandbox Code Playgroud)
当我将epochTime传递给它时: 1512259200000
此纪元时间是:2017年3月30日00:00:00
所以方法getISO8601将返回: P1Y
这很棒!但有没有什么方法可以确保它永远只会在几天内返回...例如:P365D(而不是:P1Y)
所以我有一个运行的docker容器,里面有几个文件夹/文件.
当我进入容器时,我可以看到它们是:
hostmachine $> docker exec -it testContainer bash
testContainer @ testContainer:〜$ ls -l
total 40200
-rw-r--r-- 1 root root 41156267 Apr 11 20:10 herp-4.2.2-SNAPSHOT-ap3.tar.gz
drwxr-xr-x 2 root root 4096 Apr 11 20:10 var
drwxr-xr-x 5 root root 4096 Apr 11 20:10 herp-4.2.2-SNAPSHOT
lrwxrwxrwx 1 root root 39 Apr 11 20:10 current -> /home/testContainer/herp-4.2.2-SNAPSHOT
Run Code Online (Sandbox Code Playgroud)
我的问题是:
什么脚本,如何在我的hostmachine上使用它:
1)从容器回送(返回)以下信息:
" current - > /home/testContainer/herp-4.2.2-SNAPSHOT "
2)然后再进一步,回顾最后一点:
HERP-4.2.2-SNAPSHOT
所以基本上它可能是这样的:
hostmachine $> ./getSnapshotName.sh
HERP-4.2.2-SNAPSHOT