Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Username and Password needed while backup/restore #437

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fi
cd cli/ && ./build-cli.sh
if [ $? -ne 0 ]; then
_notify_github failure "CLI build failed"
exit 1
exit 1
fi
cd $REPO_ROOT_DIR

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public static final CassandraData createBackupSchemaData(
context.getAccountId(),
context.getSecretKey(),
context.getUsesEmc(),
context.getRestoreType());
context.getRestoreType(),
context.getUsername(),
context.getPassword());
}

public static final CassandraData createBackupSchemaStatusData() {
Expand All @@ -113,7 +115,9 @@ public static final CassandraData createBackupSnapshotData(
context.getAccountId(),
context.getSecretKey(),
context.getUsesEmc(),
context.getRestoreType());
context.getRestoreType(),
context.getUsername(),
context.getPassword());
}

public static final CassandraData createBackupSnapshotStatusData() {
Expand All @@ -133,7 +137,9 @@ public static final CassandraData createBackupUploadData(
context.getAccountId(),
context.getSecretKey(),
context.getUsesEmc(),
context.getRestoreType());
context.getRestoreType(),
context.getUsername(),
context.getPassword());
}

public static final CassandraData createBackupUploadStatusData() {
Expand All @@ -153,7 +159,9 @@ public static final CassandraData createSnapshotDownloadData(
context.getAccountId(),
context.getSecretKey(),
context.getUsesEmc(),
context.getRestoreType());
context.getRestoreType(),
context.getUsername(),
context.getPassword());
}

public static final CassandraData createSnapshotDownloadStatusData() {
Expand All @@ -173,7 +181,9 @@ public static final CassandraData createRestoreSnapshotData(
context.getAccountId(),
context.getSecretKey(),
context.getUsesEmc(),
context.getRestoreType());
context.getRestoreType(),
context.getUsername(),
context.getPassword());
}

public static final CassandraData createRestoreSnapshotStatusData() {
Expand All @@ -193,7 +203,9 @@ public static final CassandraData createRestoreSchemaData(
context.getAccountId(),
context.getSecretKey(),
context.getUsesEmc(),
context.getRestoreType());
context.getRestoreType(),
context.getUsername(),
context.getPassword());
}

public static final CassandraData createRestoreSchemaStatusData() {
Expand Down Expand Up @@ -284,7 +296,9 @@ private CassandraData(final CassandraTask.TYPE type,
final String accountId,
final String secretKey,
final boolean usesEmc,
final String restoreType) {
final String restoreType,
final String username,
final String password) {

data = CassandraProtos.CassandraData.newBuilder()
.setType(type.ordinal())
Expand All @@ -298,6 +312,8 @@ private CassandraData(final CassandraTask.TYPE type,
.setState(Protos.TaskState.TASK_STAGING.ordinal())
.setUsesEmc(usesEmc)
.setRestoreType(restoreType)
.setUsername(username)
.setPassword(password)
.build();

}
Expand Down Expand Up @@ -412,7 +428,9 @@ public BackupRestoreContext getBackupRestoreContext() {
data.getAccoundId(),
data.getSecretKey(),
data.getUsesEmc(),
data.getRestoreType());
data.getRestoreType(),
data.getUsername(),
data.getPassword());
}

public UpgradeSSTableContext getUpgradeSSTableContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public static final BackupRestoreContext create(
@JsonProperty("uses_emc")
final boolean usesEmc,
@JsonProperty("restore_type")
final String restoreType) {
final String restoreType,
@JsonProperty("username")
final String username,
@JsonProperty("password")
final String password) {

return new BackupRestoreContext(
nodeId,
Expand All @@ -56,7 +60,9 @@ public static final BackupRestoreContext create(
accountId,
secretKey,
usesEmc,
restoreType);
restoreType,
username,
password);
}

@JsonProperty("node_id")
Expand All @@ -82,6 +88,12 @@ public static final BackupRestoreContext create(

@JsonProperty("restore_type")
private final String restoreType;

@JsonProperty("username")
private final String username;

@JsonProperty("password")
private final String password;

public BackupRestoreContext(final String nodeId,
final String name,
Expand All @@ -90,7 +102,7 @@ public BackupRestoreContext(final String nodeId,
final String accountId,
final String secretKey,
final boolean usesEmc,
final String restoreType) {
final String restoreType, final String username, final String password) {
this.nodeId = nodeId;
this.externalLocation = externalLocation;
this.name = name;
Expand All @@ -99,6 +111,8 @@ public BackupRestoreContext(final String nodeId,
this.secretKey = secretKey;
this.usesEmc = usesEmc;
this.restoreType = restoreType;
this.username = username;
this.password = password;
}

/**
Expand Down Expand Up @@ -179,6 +193,12 @@ public String getNodeId() {
*/
@JsonProperty("restore_type")
public String getRestoreType() { return restoreType; }

@JsonProperty("username")
public String getUsername() { return username; }

@JsonProperty("password")
public String getPassword() { return password; }

@Override
public String toString() {
Expand All @@ -198,7 +218,9 @@ public boolean equals(Object o) {
that.getLocalLocation()) &&
Objects.equals(getAccountId(), that.getAccountId()) &&
Objects.equals(getSecretKey(), that.getSecretKey()) &&
Objects.equals(getRestoreType(), that.getRestoreType());
Objects.equals(getRestoreType(), that.getRestoreType()) &&
Objects.equals(getUsername(), that.getUsername()) &&
Objects.equals(getPassword(), that.getPassword());
}

@Override
Expand All @@ -217,7 +239,9 @@ public BackupRestoreContext forNode(final String nodeId){
accountId,
secretKey,
usesEmc,
restoreType);
restoreType,
username,
password);
}

@JsonIgnore
Expand All @@ -230,6 +254,8 @@ public BackupRestoreContext withLocalLocation(final String localLocation){
accountId,
secretKey,
usesEmc,
restoreType);
restoreType,
username,
password);
}
}
4 changes: 4 additions & 0 deletions cassandra-commons/src/main/proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,8 @@ message CassandraData{
optional bool usesEmc = 17;

optional string restoreType = 18;

optional string username = 19;

optional string password = 20;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#DCOS got yo Cassandra!
#Tue Jan 17 16:20:57 PST 2017
dc=dc1
rack=rac1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* using Datastax Java Driver.
*/
public class BackupSchema implements ExecutorTask {
private static final Logger LOGGER = LoggerFactory.getLogger(
private static final Logger LOGGER = LoggerFactory.getLogger(
BackupSchema.class);
private CassandraDaemonProcess daemon;
private ExecutorDriver driver;
Expand Down Expand Up @@ -81,7 +81,7 @@ public void run() {
sendStatus(driver, Protos.TaskState.TASK_RUNNING,
"Started taking schema backup");

cluster = Cluster.builder().addContactPoint(daemon.getProbe().getEndpoint()).build();
cluster = Cluster.builder().addContactPoint(daemon.getProbe().getEndpoint()).withCredentials(context.getUsername(), context.getPassword()).build();
final List<String> keyspaces = StorageUtil.filterSystemKeyspaces(daemon.getNonSystemKeySpaces());

if (keyspaces.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public void run() {
sendStatus(driver, Protos.TaskState.TASK_RUNNING,
"Started restoring schema");

cluster = Cluster.builder().addContactPoint(daemon.getProbe().getEndpoint()).build();
//cluster = Cluster.builder().addContactPoint(daemon.getProbe().getEndpoint()).build();
cluster = Cluster.builder().addContactPoint(daemon.getProbe().getEndpoint()).withCredentials(context.getUsername(), context.getPassword()).build();
session = cluster.connect();
read = new Scanner(backupStorageDriver.downloadSchema(context));
read.useDelimiter(";");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void run() {

final String columnFamilyPath = columnFamily.getAbsolutePath();
final List<String> command = Arrays.asList(
ssTableLoaderBinary, "-d", libProcessAddress, "-f",
ssTableLoaderBinary, "-d", libProcessAddress, "-u",context.getUsername(),"-pw",context.getPassword(),"-f",
cassandraYaml, columnFamilyPath);
LOGGER.info("Executing command: {}", command);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public void testGetBucketNameS3Protocol() throws URISyntaxException {
"account-id",
"secret-key",
false,
"existing");
"existing",
"username",
"password");
Assert.assertEquals(bucketName, s3StorageDriver.getBucketName(backupRestoreContext));
}

Expand All @@ -45,7 +47,9 @@ public void testGetBucketNameHTTPSProtocol() throws URISyntaxException {
"account-id",
"secret-key",
false,
"existing");
"existing",
"username",
"password");
Assert.assertEquals(bucketName, s3StorageDriver.getBucketName(backupRestoreContext));
}

Expand All @@ -60,7 +64,9 @@ public void testGetBucketNameHTTPProtocolIPPort() throws URISyntaxException {
"account-id",
"secret-key",
false,
"existing");
"existing",
"username",
"password");
Assert.assertEquals(bucketName, s3StorageDriver.getBucketName(backupRestoreContext));
}

Expand All @@ -75,7 +81,9 @@ public void testGetEmptyPrefixKeyS3Protocol() throws URISyntaxException {
"account-id",
"secret-key",
false,
"existing");
"existing",
"username",
"password");
Assert.assertEquals(backupName, s3StorageDriver.getPrefixKey(backupRestoreContext));
}

Expand All @@ -91,7 +99,9 @@ public void testGetNestedPrefixKeyS3Protocol() throws URISyntaxException {
"account-id",
"secret-key",
false,
"existing");
"existing",
"username",
"password");
Assert.assertEquals(nestedPath + "/" + backupName, s3StorageDriver.getPrefixKey(backupRestoreContext));
}

Expand All @@ -106,7 +116,9 @@ public void testGetEmptyPrefixKeyHTTPSProtocol() throws URISyntaxException {
"account-id",
"secret-key",
false,
"existing");
"existing",
"username",
"password");
Assert.assertEquals(backupName, s3StorageDriver.getPrefixKey(backupRestoreContext));
}

Expand All @@ -122,7 +134,9 @@ public void testGetNestedPrefixKeyHTTPSProtocol() throws URISyntaxException {
"account-id",
"secret-key",
false,
"existing");
"existing",
"username",
"password");
Assert.assertEquals(nestedPath + "/" + backupName, s3StorageDriver.getPrefixKey(backupRestoreContext));
}

Expand All @@ -136,7 +150,9 @@ public void testGetEndpointS3Protocol() throws URISyntaxException {
"account-id",
"secret-key",
false,
"existing");
"existing",
"username",
"password");
Assert.assertEquals(Constants.S3_HOSTNAME, s3StorageDriver.getEndpoint(backupRestoreContext));
}

Expand All @@ -151,7 +167,9 @@ public void testGetEndpointHTTPSProtocol() throws URISyntaxException {
"account-id",
"secret-key",
false,
"existing");
"existing",
"username",
"password");
Assert.assertEquals(endpoint, s3StorageDriver.getEndpoint(backupRestoreContext));
}

Expand All @@ -166,7 +184,9 @@ public void testGetEndpointHTTPProtocolHostPort() throws URISyntaxException {
"account-id",
"secret-key",
false,
"existing");
"existing",
"username",
"password");
Assert.assertEquals(endpoint, s3StorageDriver.getEndpoint(backupRestoreContext));
}

Expand All @@ -181,7 +201,9 @@ public void testGetEndpointHTTPProtocolHost() throws URISyntaxException {
"account-id",
"secret-key",
false,
"existing");
"existing",
"username",
"password");
Assert.assertEquals(endpoint, s3StorageDriver.getEndpoint(backupRestoreContext));
}
}
Loading