Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
agent
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
7
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5132c367
authored
Jul 29, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix mount_store()
parent
724d775a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
18 deletions
+27
-18
agent.py
+27
-18
No files found.
agent.py
View file @
5132c367
...
@@ -12,7 +12,7 @@ import fileinput
...
@@ -12,7 +12,7 @@ import fileinput
import
platform
import
platform
import
sys
import
sys
import
tarfile
import
tarfile
from
os.path
import
expanduser
,
join
from
os.path
import
expanduser
,
join
,
exists
from
os
import
mkdir
from
os
import
mkdir
from
glob
import
glob
from
glob
import
glob
from
StringIO
import
StringIO
from
StringIO
import
StringIO
...
@@ -30,10 +30,17 @@ logger = logging.getLogger()
...
@@ -30,10 +30,17 @@ logger = logging.getLogger()
SSH_DIR
=
expanduser
(
'~cloud/.ssh'
)
SSH_DIR
=
expanduser
(
'~cloud/.ssh'
)
AUTHORIZED_KEYS
=
join
(
SSH_DIR
,
'authorized_keys'
)
AUTHORIZED_KEYS
=
join
(
SSH_DIR
,
'authorized_keys'
)
fstab_template
=
(
'sshfs#
%(username)
s@
%(host)
s:home /home/cloud/sshfs '
STORE_DIR
=
'/store'
'fuse defaults,idmap=user,reconnect,_netdev,uid=1000,'
'gid=1000,allow_other,StrictHostKeyChecking=no,'
mount_template_linux
=
(
'IdentityFile=/home/cloud/.ssh/id_rsa 0 0
\n
'
)
'//
%(host)
s/u-1
%(dir)
s cifs username=
%(username)
s'
',password=
%(password)
s,iocharset=utf8,uid=cloud 0 0
\n
'
)
mount_template_windows
=
(
'net use * /delete /yes
\r\n
'
'timeout 5
\r\n
'
'net use z:
\\
%(host)
s
\\
%(username)
s "
%(password)
s" '
'/user:
%(username)
s
\r\n
'
)
system
=
platform
.
system
()
system
=
platform
.
system
()
...
@@ -141,24 +148,26 @@ class Context(object):
...
@@ -141,24 +148,26 @@ class Context(object):
wmi
.
WMI
()
.
Win32_ComputerSystem
()[
0
]
.
Rename
(
hostname
)
wmi
.
WMI
()
.
Win32_ComputerSystem
()[
0
]
.
Rename
(
hostname
)
@staticmethod
@staticmethod
def
mount_store
(
host
,
username
,
password
,
key
):
def
mount_store
(
host
,
username
,
password
):
data
=
{
'host'
:
host
,
'username'
:
username
,
'password'
:
password
}
if
system
==
'Linux'
:
if
system
==
'Linux'
:
for
line
in
fileinput
.
input
(
'/etc/fstab'
,
inplace
=
1
):
data
[
'dir'
]
=
STORE_DIR
if
line
.
startswith
(
'sshfs#'
):
if
not
exists
(
STORE_DIR
):
line
=
''
mkdir
(
STORE_DIR
)
# TODO
for
line
in
fileinput
.
input
(
'/etc/fstab'
,
inplace
=
True
):
if
not
(
line
.
startswith
(
'//'
)
and
' cifs '
in
line
):
print
line
.
rstrip
()
with
open
(
'/etc/fstab'
,
'a'
)
as
f
:
with
open
(
'/etc/fstab'
,
'a'
)
as
f
:
f
.
write
(
fstab_template
%
{
'host'
:
host
,
'username'
:
username
,
f
.
write
(
mount_template_linux
%
data
)
'password'
:
password
})
subprocess
.
call
(
'mount -a'
,
shell
=
True
)
elif
system
==
'Windows'
:
elif
system
==
'Windows'
:
data
=
(
'net use * /delete /yes
\r\n
'
with
open
(
r'c:\Windows\System32\Repl\Import\Scripts\%s.bat'
'timeout 5
\r\n
'
%
username
,
'w'
)
as
f
:
'net use z:
\\
%(hostname)
s
\\
%(username)
s "
%(password)
s" '
f
.
write
(
mount_template_windows
%
data
)
'/user:
%(username)
s'
)
with
open
(
r'c:\Windows\System32\Repl\Import\Scripts'
r'
%
s.bat'
%
username
,
'w'
)
as
f
:
f
.
write
(
data
)
@staticmethod
@staticmethod
def
get_keys
():
def
get_keys
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment