I\xe2\x80\x99m 尝试通过 IAP 连接到 GCP 计算实例。我有一个具有权限的服务帐户。
\n\n我尝试过以下方法
\n\nansible -vvvv GCP -m ping
由于找不到主机名而出现错误,因为我没有外部 IPssh_executeable=wrapper.sh
像这里一样设置了2 号几乎可以工作,但正则化命令很糟糕。
\n\n有原生的ansible解决方案吗?
\n\n编辑: gcp_compute 动态清单确实适用于 ping 实例,但不适用于管理实例。
\n\nAnsible 在通过 IAP 进行隧道传输时不支持包或系统管理。
\n我有一个 spring 应用程序,它正在拉一个公用罐。这个 jar 有带注释的 DTO 类。运行 mvn clean build 命令运行成功并构建 jar。一旦我运行 java -jar target/MyApp-1.0.0.BUILD-SNAPSHOT.jar 我会得到以下错误。
我打开了 MyApp-1.0.0.BUILD-SNAPSHOT.jar 并在该 jar 中找到了我的所有类。
我已经在我的快照中打开了包含 MyApplicationJobDTO 的 jar 并验证了文件在那里。
似乎在运行时 java 找不到该类,即使该类在那里。我不相信我应该向 java 类路径添加任何内容,因为 jar 位于快照 jar 内。我被卡住了,不确定为什么我会收到运行时错误。
Caused by: java.lang.IllegalArgumentException: Not an managed type: class com...MyApplicationJobDTO
Run Code Online (Sandbox Code Playgroud)
带有注释的类
@Component
@Entity
public class MyApplicationJobDTO implements Serializable {
Run Code Online (Sandbox Code Playgroud)
我的运行命令
mvn clean package && java -jar target/MyApp-1.0.0.BUILD-SNAPSHOT.jar
Run Code Online (Sandbox Code Playgroud)
我的主课
@EnableJpaRepositories
@ComponentScan
@EntityScan
@Configuration
@EnableAutoConfiguration
public class Application {
public static void main(String[] args) {
ApplicationContext context = …
Run Code Online (Sandbox Code Playgroud) 我有1323648000,这是int(10).我需要能够将其转换为某种日期格式.像dd/hh/yy hh:mm:ss.我在这里尝试了几个例子,但我似乎无法让它工作.我试图把它作为varchar(10)投射并转换但没有.Excel还输出########.这个数字不正确吗?
SELECT
engine4_openid_statusstats.openidstat_id,
CONVERT(datetime,CAST(engine4_openid_statusstats.openidstat_time AS varchar(10),3),
engine4_openid_services.openidservice_id,
engine4_openid_services.openidservice_name
FROM
engine4_openid_statusstats ,
engine4_openid_services
Run Code Online (Sandbox Code Playgroud) 我有一个创建连接的类。我可以在通道关闭之前连接并执行 1 个命令。在另一个系统上,我可以执行多个命令并且通道不会关闭。显然,这是我尝试连接的系统的配置问题。
class connect:
newconnection = ''
def __init__(self,username,password):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect('somehost', username=username,password=password,port=2222,timeout=5)
except:
print "Count not connect"
sys.exit()
self.newconnection = ssh
def con(self):
return self.newconnection
Run Code Online (Sandbox Code Playgroud)
然后我使用'ls'命令只是为了打印一些输出
sshconnection = connect('someuser','somepassword').con()
stdin, stdout, stderr = sshconnection.exec_command("ls -lsa")
print stdout.readlines()
print stdout
stdin, stdout, stderr = sshconnection.exec_command("ls -lsa")
print stdout.readlines()
print stdout
sshconnection.close()
sys.exit()
Run Code Online (Sandbox Code Playgroud)
在第一个 exec_command 运行后,它会打印目录列表的预期输出。当我在第一个 exec_command 之后打印 stdout 时,看起来通道已关闭
<paramiko.ChannelFile from <paramiko.Channel 1 (closed) -> <paramiko.Transport at 0x2400f10L (cipher aes128-ctr, 128 bits) (active; 0 open channel(s))>>> …
Run Code Online (Sandbox Code Playgroud) 我有一个excel文件,我希望用户能够从我的服务器下载.我在这里看了很多问题,但我找不到正确下载没有腐败的文件的方法.我假设它是标题但我还没有它们的工作组合.这就是我现在所拥有的,在我收到的损坏文件中,我可以看到我想要的电子表格的列名,但它全部搞砸了.
$filename = '/var/www/web1/web/public/temporary/Spreadsheet.xls';
header("Content-type: application/octet-stream");
header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=ExcelFile.xls;");
header("Pragma: no-cache");
header("Expires: 0");
readfile($filename);
Run Code Online (Sandbox Code Playgroud)
编辑:解决方案我忘了添加我正在使用Zend,它在尝试使用本机php方法时破坏了文件.我的finsihed代码是在我的控制器中放置一个链接到另一个动作,并从那里下载文件
public function downloadAction(){
$file = '/var/www/web1/web/public/temporary/Spreadsheet.xls';
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="Spreadsheet.xls"');
readfile($file);
// disable the view ... and perhaps the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
Run Code Online (Sandbox Code Playgroud) 我想从我的网站下载单个.mp3文件,但在使用此代码时,它会在Firefox和Safari中强制使用.php.但是在Chrome中,它会强制将文件作为内联并在页面上播放.我怎样才能让他们真正下载.mp3文件?
$track = $_SERVER['QUERY_STRING'];
if (file_exists("/home/user/gets/" .$track)) {
header("Content-Type: audio/mpeg");
header('Content-Length: ' . filesize($track));
header('Content-Disposition: attachment; filename="test.mp3"');
$str = "/home/user/gets/".$track;
readfile($str);
exit;
} else {
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404);
echo "no file";
}
Run Code Online (Sandbox Code Playgroud)
我也尝试下载.zip文件并将Content-Type更改为application/ocetet-stream,但它会强制所有浏览器上的.php文件.
//$track = $_SERVER['QUERY_STRING'];
$track = 'testfile.zip';
if (file_exists("/home/user/gets/" .$track)) {
header("Content-Type: application/octet-stream");
header('Content-Length: ' . filesize($track));
header('Content-Disposition: attachment; filename="test.mp3"');
$str = "/home/user/gets/".$track;
readfile($str);
exit;
} else {
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404);
echo "no file";
}
Run Code Online (Sandbox Code Playgroud)