小编rub*_*bio的帖子

Ansible GCP IAP 隧道

I\xe2\x80\x99m 尝试通过 IAP 连接到 GCP 计算实例。我有一个具有权限的服务帐户。

\n\n

我尝试过以下方法

\n\n
    \n
  1. 基本 ansible ping,ansible -vvvv GCP -m ping由于找不到主机名而出现错误,因为我没有外部 IP
  2. \n
  3. 我已经ssh_executeable=wrapper.sh这里一样设置了
  4. \n
\n\n

2 号几乎可以工作,但正则化命令很糟糕。

\n\n

有原生的ansible解决方案吗?

\n\n

编辑: gcp_compute 动态清单确实适用于 ping 实例,但不适用于管理实例。

\n\n

Ansible 在通过 IAP 进行隧道传输时不支持包或系统管理。

\n

ansible google-cloud-platform

9
推荐指数
2
解决办法
4461
查看次数

带有外部 jar 的 Spring Boot 'Not a Managed Type'

我有一个 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)

java spring jar maven

6
推荐指数
2
解决办法
7174
查看次数

SQL将INT转换为datetime

我有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)

sql int datetime

5
推荐指数
1
解决办法
7288
查看次数

使用多个命令的 Python paramiko 模块

我有一个创建连接的类。我可以在通道关闭之前连接并执行 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)

python ssh paramiko

4
推荐指数
1
解决办法
1万
查看次数

PHP下载excel文件变得腐败

我有一个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)

php excel corrupt download

3
推荐指数
1
解决办法
1万
查看次数

PHP标头内容 - 处置:附件强制.php文件或内联

我想从我的网站下载单个.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)

php mp3 header cross-browser download

3
推荐指数
1
解决办法
2万
查看次数